Exemple #1
0
  /** Called by ItemBlocks after a block is set in the world, to allow post-place logic */
  public void onBlockPlacedBy(
      World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);

    if (stack.hasDisplayName()) {
      TileEntity tileentity = worldIn.getTileEntity(pos);

      if (tileentity instanceof TileEntityBeacon) {
        ((TileEntityBeacon) tileentity).setName(stack.getDisplayName());
      }
    }
  }
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {

    int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;

    if (l == 0) {
      world.setBlockMetadataWithNotify(x, y, z, 2, 2);
    }
    if (l == 1) {
      world.setBlockMetadataWithNotify(x, y, z, 5, 2);
    }
    if (l == 2) {
      world.setBlockMetadataWithNotify(x, y, z, 3, 2);
    }
    if (l == 3) {
      world.setBlockMetadataWithNotify(x, y, z, 4, 2);
    }
    super.onBlockPlacedBy(world, x, y, z, player, itemstack);
  }