public void doBreakShovel(
      World var1, EntityHuman var2, ItemStack var3, int var4, int var5, int var6, int var7) {
    int typeId = var1.getTypeId(var5, var6, var7);
    int var8 = var1.getData(var5, var6, var7);
    ArrayList var9 = Block.byId[var4].getBlockDropped(var1, var5, var6, var7, var8, 0);
    Iterator var10 = var9.iterator();

    if (!breakBlock(null, var2, var1, var5, var6, var7, typeId, var8)) return;

    while (var10.hasNext()) {
      ItemStack var11 = (ItemStack) var10.next();
      addToDroplist(var3, var11);
    }

    BigWorldHook.setTypeIdHooked(var1, var5, var6, var7, 0);

    for (int var14 = -1; var14 <= 1; var14++) {
      for (int var13 = -1; var13 <= 1; var13++) {
        for (int var12 = -1; var12 <= 1; var12++) {
          if (var1.getTypeId(var5 + var14, var6 + var13, var7 + var12) != var4) continue;
          doBreakShovelAdd(var1, var2, var3, var4, var5 + var14, var6 + var13, var7 + var12);
        }
      }
    }

    if (var1.random.nextInt(8) == 0) {
      var1.a("largesmoke", var5, var6 + 1, var7, 0.0D, 0.0D, 0.0D);
    }

    if (var1.random.nextInt(8) == 0) {
      var1.a("explode", var5, var6 + 1, var7, 0.0D, 0.0D, 0.0D);
    }
    ejectDropList(var1, var3, var5, var6, var7);
  }
  /** set a blocks direction */
  private void g(World par1World, int par2, int par3, int par4) {
    if (par1World.isStatic) {
      return;
    }

    int i = par1World.getTypeId(par2, par3, par4 - 1);
    int j = par1World.getTypeId(par2, par3, par4 + 1);
    int k = par1World.getTypeId(par2 - 1, par3, par4);
    int l = par1World.getTypeId(par2 + 1, par3, par4);
    byte byte0 = 3;

    if (Block.n[i] && !Block.n[j]) {
      byte0 = 3;
    }

    if (Block.n[j] && !Block.n[i]) {
      byte0 = 2;
    }

    if (Block.n[k] && !Block.n[l]) {
      byte0 = 5;
    }

    if (Block.n[l] && !Block.n[k]) {
      byte0 = 4;
    }

    par1World.setData(par2, par3, par4, byte0);
  }
  public void doTallImpact(
      World var1, ItemStack var2, EntityHuman var3, int var4, int var5, int var6, double var7) {
    cleanDroplist(var2);

    for (int var9 = -1; var9 <= 1; var9++) {
      int var10 = var4;
      int var11 = var5;
      int var12 = var6;

      if (var9 == 0) continue;
      if ((var7 != 0.0D) && (var7 != 1.0D)) {
        var11 = var5 + var9;
      } else if ((EEBase.heading(var3) != 2.0D) && (EEBase.heading(var3) != 4.0D)) {
        var10 = var4 + var9;
      } else {
        var12 = var6 + var9;
      }

      int var13 = var1.getTypeId(var10, var11, var12);
      int var14 = var1.getData(var10, var11, var12);

      if (!canBreak(var13, var14)) continue;
      scanBlockAndBreak(var3, var1, var2, var10, var11, var12);
    }

    ejectDropList(var1, var2, var4, var5 + 0.5D, var6);
  }
  public void doMegaImpact(
      EntityHuman ply, ItemStack var2, int var3, int var4, int var5, double var6) {
    World var1 = ply.world;
    cleanDroplist(var2);
    for (int var8 = -1; var8 <= 1; var8++) {
      for (int var9 = -1; var9 <= 1; var9++) {
        int var10 = var3;
        int var11 = var4;
        int var12 = var5;
        if (var8 != 0 || var9 != 0) {
          if (var6 != 0.0D && var6 != 1.0D) {
            if (var6 != 2D && var6 != 4D) {
              if (var6 == 3D || var6 == 5D) {
                var11 = var4 + var8;
                var12 = var5 + var9;
              }
            } else {
              var10 = var3 + var8;
              var11 = var4 + var9;
            }
          } else {
            var10 = var3 + var8;
            var12 = var5 + var9;
          }
          int var13 = var1.getTypeId(var10, var11, var12);
          int var14 = var1.getData(var10, var11, var12);
          if (canBreak(var13, var14) && attemptBreak(ply, var10, var11, var12))
            scanBlockAndBreak(var1, var2, var10, var11, var12);
        }
      }
    }

    ejectDropList(var1, var2, var3, (double) var4 + 0.5D, var5);
  }
  public boolean a(World var1, Random var2, int var3, int var4, int var5) {
    if (ExtrabiomesBlock.quickSand != null) {
      while (var1.isEmpty(var3, var4, var5) && var4 > 2) {
        --var4;
      }

      if (var1.getTypeId(var3, var4, var5) != Block.GRASS.id) {
        return false;
      }

      int var6;
      int var7;

      for (var6 = -2; var6 <= 2; ++var6) {
        for (var7 = -2; var7 <= 2; ++var7) {
          if (var1.isEmpty(var3 + var6, var4 - 1, var5 + var7)
              && var1.isEmpty(var3 + var6, var4 - 2, var5 + var7)) {
            return false;
          }
        }
      }

      for (var6 = -1; var6 <= 1; ++var6) {
        for (var7 = -1; var7 <= 1; ++var7) {
          for (int var8 = -2; var8 <= 0; ++var8) {
            var1.setRawTypeId(var3 + var6, var4 + var8, var5 + var7, ExtrabiomesBlock.quickSand.id);
          }
        }
      }
    }

    return true;
  }
  private static boolean ObjectCanSpawn(World world, int x, int y, int z, CustomObject obj) {
    if ((world.getTypeId(x, y - 5, z) == 0) && (obj.needsFoundation)) return false;

    boolean abort = false;
    int checkBlock = world.getTypeId(x, y + 2, z);
    if (!obj.spawnWater)
      abort = ((checkBlock == Block.WATER.id) || (checkBlock == Block.STATIONARY_WATER.id));
    if (!obj.spawnLava)
      abort = ((checkBlock == Block.LAVA.id) || (checkBlock == Block.STATIONARY_LAVA.id));

    checkBlock = world.getLightLevel(x, y + 2, z);
    if (!obj.spawnSunlight) abort = (checkBlock > 8);
    if (!obj.spawnDarkness) abort = (checkBlock < 9);

    if ((y < obj.spawnElevationMin) || (y > obj.spawnElevationMax)) abort = true;

    if (!obj.spawnOnBlockType.contains(world.getTypeId(x, y - 1, z))) abort = true;

    return !abort;
  }
  public void scanBlockAndBreak(World var1, ItemStack var2, int var3, int var4, int var5) {
    int var6 = var1.getTypeId(var3, var4, var5);
    int var7 = var1.getData(var3, var4, var5);
    ArrayList var8 = Block.byId[var6].getBlockDropped(var1, var3, var4, var5, var7, 0);
    ItemStack var10;
    for (Iterator var9 = var8.iterator(); var9.hasNext(); addToDroplist(var2, var10))
      var10 = (ItemStack) var9.next();

    var1.setTypeId(var3, var4, var5, 0);
    if (var1.random.nextInt(8) == 0) var1.a("largesmoke", var3, var4, var5, 0.0D, 0.0D, 0.0D);
    if (var1.random.nextInt(8) == 0) var1.a("explode", var3, var4, var5, 0.0D, 0.0D, 0.0D);
  }
  public boolean interactWith(
      ItemStack var1, EntityHuman var2, World var3, int var4, int var5, int var6, int var7) {
    if (EEProxy.isClient(var3)) return false;
    boolean var8 = true;
    if (chargeLevel(var1) > 0) {
      cleanDroplist(var1);
      var2.C_();
      var3.makeSound(var2, "flash", 0.8F, 1.5F);
      for (int var9 = -(chargeLevel(var1) * (var7 != 5 ? (byte) (var7 != 4 ? 1 : 0) : 2));
          var9 <= chargeLevel(var1) * (var7 != 5 ? var7 != 4 ? 1 : 2 : 0);
          var9++) {
        for (int var10 = -(chargeLevel(var1) * (var7 != 1 ? (byte) (var7 != 0 ? 1 : 0) : 2));
            var10 <= chargeLevel(var1) * (var7 != 1 ? var7 != 0 ? 1 : 2 : 0);
            var10++) {
          for (int var11 = -(chargeLevel(var1) * (var7 != 3 ? (byte) (var7 != 2 ? 1 : 0) : 2));
              var11 <= chargeLevel(var1) * (var7 != 3 ? var7 != 2 ? 1 : 2 : 0);
              var11++) {
            int var12 = var4 + var9;
            int var13 = var5 + var10;
            int var14 = var6 + var11;
            int var15 = var3.getTypeId(var12, var13, var14);
            int var16 = var3.getData(var12, var13, var14);
            if (canBreak(var15, var16) && attemptBreak(var2, var12, var13, var14)) {
              if (getFuelRemaining(var1) < 1) {
                ConsumeReagent(var1, var2, var8);
                var8 = false;
              }
              if (getFuelRemaining(var1) > 0) {
                ArrayList var17 =
                    Block.byId[var15].getBlockDropped(var3, var12, var13, var14, var16, 0);
                ItemStack var19;
                for (Iterator var18 = var17.iterator(); var18.hasNext(); addToDroplist(var1, var19))
                  var19 = (ItemStack) var18.next();

                var3.setTypeId(var12, var13, var14, 0);
                if (var3.random.nextInt(8) == 0)
                  var3.a("largesmoke", var12, var13, var14, 0.0D, 0.0D, 0.0D);
                if (var3.random.nextInt(8) == 0)
                  var3.a("explode", var12, var13, var14, 0.0D, 0.0D, 0.0D);
                setShort(var1, "fuelRemaining", getFuelRemaining(var1) - 1);
              }
            }
          }
        }
      }

      ejectDropList(var3, var1, var4, var5, var6);
    }
    return false;
  }
  public void doLongImpact(
      EntityHuman player, World var1, ItemStack var2, int var3, int var4, int var5, double var6) {
    cleanDroplist(var2);

    for (int var8 = 1; var8 <= 2; var8++) {
      int var9 = var3;
      int var10 = var4;
      int var11 = var5;

      if (var6 == 0.0D) {
        var10 = var4 - var8;
      }

      if (var6 == 1.0D) {
        var10 = var4 + var8;
      }

      if (var6 == 2.0D) {
        var11 = var5 + var8;
      }

      if (var6 == 3.0D) {
        var9 = var3 - var8;
      }

      if (var6 == 4.0D) {
        var11 = var5 - var8;
      }

      if (var6 == 5.0D) {
        var9 = var3 + var8;
      }

      int var12 = var1.getTypeId(var9, var10, var11);
      int var13 = var1.getData(var9, var10, var11);

      if (!canBreak(var12, var13)) continue;
      scanBlockAndBreak(player, var1, var2, var9, var10, var11);
    }

    ejectDropList(var1, var2, var3, var4 + 0.5D, var5);
  }
  public void scanBlockAndBreak(
      EntityHuman player, World var1, ItemStack var2, int var3, int var4, int var5) {
    int var6 = var1.getTypeId(var3, var4, var5);
    int var7 = var1.getData(var3, var4, var5);
    ArrayList var8 = Block.byId[var6].getBlockDropped(var1, var3, var4, var5, var7, 0);
    Iterator var9 = var8.iterator();

    if (!breakBlock(null, player, var1, var3, var4, var5, var6, var7)) return;

    while (var9.hasNext()) {
      ItemStack var10 = (ItemStack) var9.next();
      addToDroplist(var2, var10);
    }

    if (var1.random.nextInt(8) == 0) {
      var1.a("largesmoke", var3, var4, var5, 0.0D, 0.0D, 0.0D);
    }

    if (var1.random.nextInt(8) == 0) {
      var1.a("explode", var3, var4, var5, 0.0D, 0.0D, 0.0D);
    }
  }
  public void doBreakShovelAdd(
      World var1, EntityHuman var2, ItemStack var3, int var4, int var5, int var6, int var7) {
    if (getFuelRemaining(var3) < 1) {
      ConsumeReagent(var3, var2, false);
    }

    if (getFuelRemaining(var3) > 0) {
      int var8 = var1.getData(var5, var6, var7);
      ArrayList var9 = Block.byId[var4].getBlockDropped(var1, var5, var6, var7, var8, 0);
      Iterator var10 = var9.iterator();

      while (var10.hasNext()) {
        ItemStack var11 = (ItemStack) var10.next();
        addToDroplist(var3, var11);
      }

      BigWorldHook.setTypeIdHooked(var1, var5, var6, var7, 0);
      setShort(var3, "fuelRemaining", getFuelRemaining(var3) - 1);

      for (int var14 = -1; var14 <= 1; var14++) {
        for (int var13 = -1; var13 <= 1; var13++) {
          for (int var12 = -1; var12 <= 1; var12++) {
            if (var1.getTypeId(var5 + var14, var6 + var13, var7 + var12) != var4) continue;
            doBreakShovelAdd(var1, var2, var3, var4, var5 + var14, var6 + var13, var7 + var12);
          }
        }
      }

      if (var1.random.nextInt(8) == 0) {
        var1.a("largesmoke", var5, var6 + 1, var7, 0.0D, 0.0D, 0.0D);
      }

      if (var1.random.nextInt(8) == 0) {
        var1.a("explode", var5, var6 + 1, var7, 0.0D, 0.0D, 0.0D);
      }
    }
  }
  public void doWideImpact(
      EntityHuman player, World var1, ItemStack var2, int var3, int var4, int var5, double var6) {
    cleanDroplist(var2);

    for (int var8 = -1; var8 <= 1; var8++) {
      int var9 = var3;
      int var11 = var5;

      if (var8 == 0) continue;
      if ((var6 != 2.0D) && (var6 != 4.0D)) {
        var11 = var5 + var8;
      } else {
        var9 = var3 + var8;
      }

      int var12 = var1.getTypeId(var9, var4, var11);
      int var13 = var1.getData(var9, var4, var11);

      if (!canBreak(var12, var13)) continue;
      scanBlockAndBreak(player, var1, var2, var9, var4, var11);
    }

    ejectDropList(var1, var2, var3, var4 + 0.5D, var5);
  }
  @EventHandler(priority = EventPriority.MONITOR)
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.useInteractedBlock() == Result.DENY)
      return;

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
        && event.getClickedBlock().getState() instanceof Chest) {
      boolean silentchest = false;
      boolean anychest = false;
      int x = event.getClickedBlock().getX();
      int y = event.getClickedBlock().getY();
      int z = event.getClickedBlock().getZ();

      if (PermissionRelay.hasPermission(event.getPlayer(), "silent")
          && OpenInv.GetPlayerSilentChestStatus(event.getPlayer().getName())) {
        silentchest = true;
      }

      if (PermissionRelay.hasPermission(event.getPlayer(), "anychest")
          && OpenInv.GetPlayerAnyChestStatus(event.getPlayer().getName())) {
        try {
          // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
          EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
          World world = player.world;
          // If block on top
          if (world.e(x, y + 1, z)) anychest = true;

          // If block next to chest is chest and has a block on top
          if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.e(x - 1, y + 1, z)))
            anychest = true;
          if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.e(x + 1, y + 1, z)))
            anychest = true;
          if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.e(x, y + 1, z - 1)))
            anychest = true;
          if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.e(x, y + 1, z + 1)))
            anychest = true;
        } catch (Exception e) {
          event
              .getPlayer()
              .sendMessage(
                  ChatColor.RED + "Error while executing openinv. Unsupported CraftBukkit.");
          e.printStackTrace();
        }
      }

      // If the anychest or silentchest is active
      if (anychest || silentchest) {
        EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
        World world = player.world;
        Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
        if (chest == null) return;

        if (!anychest) {
          if (world.e(x, y + 1, z)) return;
          if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.e(x - 1, y + 1, z)))
            return;
          if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.e(x + 1, y + 1, z)))
            return;
          if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.e(x, y + 1, z - 1)))
            return;
          if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.e(x, y + 1, z + 1)))
            return;
        }

        if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
          chest =
              new InventoryLargeChest(
                  "Large chest",
                  (TileEntityChest) world.getTileEntity(x - 1, y, z),
                  (IInventory) chest);
        if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
          chest =
              new InventoryLargeChest(
                  "Large chest",
                  (IInventory) chest,
                  (TileEntityChest) world.getTileEntity(x + 1, y, z));
        if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
          chest =
              new InventoryLargeChest(
                  "Large chest",
                  (TileEntityChest) world.getTileEntity(x, y, z - 1),
                  (IInventory) chest);
        if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
          chest =
              new InventoryLargeChest(
                  "Large chest",
                  (IInventory) chest,
                  (TileEntityChest) world.getTileEntity(x, y, z + 1));

        if (!silentchest) {
          player.a((IInventory) chest);
        } else {
          try {
            Field windowID;
            try {
              windowID = player.getClass().getDeclaredField("cl");
            } catch (NoSuchFieldException e) {
              windowID = player.getClass().getDeclaredField("ci");
            }
            windowID.setAccessible(true);
            int id = windowID.getInt(player);
            id = id % 100 + 1;
            windowID.setInt(player, id);
            player.netServerHandler.sendPacket(
                new Packet100OpenWindow(
                    id, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize()));
            player.activeContainer =
                new SilentContainerChest(player.inventory, ((IInventory) chest));
            player.activeContainer.windowId = id;
            player.activeContainer.a((ICrafting) player);
            event.getPlayer().sendMessage("You are opening a chest silently.");
            event.setUseInteractedBlock(Result.DENY);
            event.setCancelled(true);
          } catch (Exception e) {
            e.printStackTrace();
            event.getPlayer().sendMessage(ChatColor.RED + "Error while sending silent chest.");
          }
        }

        if (anychest) event.getPlayer().sendMessage("You are opening a blocked chest.");
      }
    }

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
        && event.getClickedBlock().getState() instanceof Sign) {
      Player player = event.getPlayer();
      try {
        Sign sign = ((Sign) event.getClickedBlock().getState());
        if (PermissionRelay.hasPermission(player, "openinv")
            && sign.getLine(0).equalsIgnoreCase("[openinv]")) {
          String text = sign.getLine(1).trim() + sign.getLine(2).trim() + sign.getLine(3).trim();
          player.performCommand("openinv " + text);
        }
      } catch (Exception ex) {
        player.sendMessage("Internal Error.");
        ex.printStackTrace();
      }
    }

    if (event.getAction() == Action.RIGHT_CLICK_AIR
        || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
      Player player = event.getPlayer();

      if (!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem())
          || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName()))
          || !PermissionRelay.hasPermission(player, "openinv")) {
        return;
      }

      player.performCommand("openinv");
    }
  }
 public boolean isBlockTransparent(World world, int x, int y, int z) {
   int blockType = world.getTypeId(x, y, z);
   return XmasMiraclePlugin.exceptions.contains(blockType);
 }
  @Override
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.useInteractedBlock() == Result.DENY || event.isCancelled()) return;

    boolean silentchest = false;
    boolean anychest = false;
    int x = event.getClickedBlock().getX();
    int y = event.getClickedBlock().getY();
    int z = event.getClickedBlock().getZ();

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
        && event.getClickedBlock().getState() instanceof Chest
        && PermissionRelay.hasPermission(event.getPlayer(), "OpenInv.silent")
        && OpenInv.GetPlayerSilentChestStatus(event.getPlayer().getName())) {
      silentchest = true;
    }

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
        && event.getClickedBlock().getState() instanceof Chest
        && PermissionRelay.hasPermission(event.getPlayer(), "OpenInv.anychest")) {
      try {
        EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
        World world = player.world;
        // If block on top
        if (world.e(x, y + 1, z)) anychest = true;

        // If block next to chest is chest and has a block on top
        if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.e(x - 1, y + 1, z)))
          anychest = true;
        if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.e(x + 1, y + 1, z)))
          anychest = true;
        if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.e(x, y + 1, z - 1)))
          anychest = true;
        if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.e(x, y + 1, z + 1)))
          anychest = true;
      } catch (Exception e) // Incompatible CraftBukkit?
      {
        e.printStackTrace();
        event
            .getPlayer()
            .sendMessage(ChatColor.RED + "Error while executing openinv. Unsupported CraftBukkit.");
      }
    }

    // If the chest is blocked
    if (anychest || silentchest) {
      EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
      World world = player.world;
      Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
      if (chest == null) return;

      if (!anychest) {
        if (world.e(x, y + 1, z)) return;
        if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.e(x - 1, y + 1, z))) return;
        if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.e(x + 1, y + 1, z))) return;
        if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.e(x, y + 1, z - 1))) return;
        if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.e(x, y + 1, z + 1))) return;
      }

      if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
        chest =
            new InventoryLargeChest(
                "Large chest",
                (TileEntityChest) world.getTileEntity(x - 1, y, z),
                (IInventory) chest);
      if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
        chest =
            new InventoryLargeChest(
                "Large chest",
                (IInventory) chest,
                (TileEntityChest) world.getTileEntity(x + 1, y, z));
      if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
        chest =
            new InventoryLargeChest(
                "Large chest",
                (TileEntityChest) world.getTileEntity(x, y, z - 1),
                (IInventory) chest);
      if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
        chest =
            new InventoryLargeChest(
                "Large chest",
                (IInventory) chest,
                (TileEntityChest) world.getTileEntity(x, y, z + 1));

      if (!silentchest) {
        player.a((IInventory) chest);
      } else {
        try {
          Field ciField = player.getClass().getDeclaredField("ci");
          ciField.setAccessible(true);
          int ci = ciField.getInt(player);
          ci = ci % 100 + 1;
          ciField.setInt(player, ci);
          player.netServerHandler.sendPacket(
              new Packet100OpenWindow(
                  ci, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize()));
          player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
          System.out.println(player.activeContainer.toString());
          player.activeContainer.windowId = ci;
          player.activeContainer.a((ICrafting) player);
          event.getPlayer().sendMessage("You are opening a silent chest.");
        } catch (Exception e) {
          e.printStackTrace();
          event.getPlayer().sendMessage(ChatColor.RED + "Error while sending silent chest.");
        }
      }

      if (anychest) event.getPlayer().sendMessage("You are opening a blocked chest.");
    }

    if (event.getAction() == Action.RIGHT_CLICK_BLOCK
        && (event.getClickedBlock() == Block.CHEST
            || event.getClickedBlock() == Block.FURNACE
            || event.getClickedBlock() == Block.DISPENSER)) {
      return;
    }

    if (event.getAction() == Action.RIGHT_CLICK_AIR
        || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
      Player player = event.getPlayer();

      if (!(player.getItemInHand().getType() == Material.STICK)
          || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName()))
          || !PermissionRelay.hasPermission(player, "openinv")) {
        return;
      }

      player.performCommand("openinv");
    }

    if (event.getAction() == Action.LEFT_CLICK_BLOCK
        && event.getClickedBlock().getState() instanceof Sign) {
      Player player = event.getPlayer();
      try {
        if (PermissionRelay.hasPermission(player, "openinv")
            && ((Sign) event.getClickedBlock().getState())
                .getLine(0)
                .equalsIgnoreCase("[openinv]")) {
          if (plugin.getServer().getPlayer(((Sign) event.getClickedBlock().getState()).getLine(1))
              != null) {
            Sign sign = ((Sign) event.getClickedBlock().getState());
            String text = sign.getLine(1).trim() + sign.getLine(2).trim() + sign.getLine(2).trim();
            player.performCommand("openinv " + text);
          } else {
            player.sendMessage("Player not found.");
          }
        }
      } catch (Exception ex) {
        player.sendMessage("Internal Error.");
        ex.printStackTrace();
      }
    }
  }
 /**
  * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
  */
 public boolean canPlace(World var1, int var2, int var3, int var4) {
   return super.canPlace(var1, var2, var3, var4)
       && this.canThisPlantGrowOnThisBlockID(var1.getTypeId(var2, var3 - 1, var4));
 }
 /**
  * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with
  * plants.
  */
 public boolean f(World var1, int var2, int var3, int var4) {
   return (var1.m(var2, var3, var4) >= 8 || var1.isChunkLoaded(var2, var3, var4))
       && this.canThisPlantGrowOnThisBlockID(var1.getTypeId(var2, var3 - 1, var4));
 }
  public static boolean GenerateCustomObject(
      World world,
      Random rand,
      WorldConfig worldSettings,
      int x,
      int y,
      int z,
      CustomObject workObject,
      boolean notify) {
    /*
     * 1) ground check (moved to ObjectCanSpawn)
     * 2) add branches and copy all data to work array (dont change default CustomObject object)
     * 3) collision check and rotation
     * 4) spawn
     */

    // 1)

    // 2)

    int index = 0;
    int branchLimit = 0;
    ArrayList<CustomObject> branchGroup = worldSettings.BranchGroups.get(workObject.groupId);
    ArrayList<Coordinate> workingData = new ArrayList<Coordinate>();
    while (index < workObject.Data.size()) {
      Coordinate DataPoint = workObject.Data.get(index);
      workingData.add(DataPoint.GetCopy());

      if ((DataPoint.branchDirection != -1)
          && (branchGroup != null)
          && (branchLimit < workObject.branchLimit)) {
        CustomObject workingBranch = branchGroup.get(rand.nextInt(branchGroup.size()));
        int counter = 0;
        while (counter < workingBranch.Data.size()) {
          Coordinate untranslatedCoordinate = workingBranch.Data.get(counter).GetCopy();
          int directionCounter = 0;
          while (directionCounter < (DataPoint.branchDirection)) {
            untranslatedCoordinate.Rotate();
            directionCounter++;
          }

          workingData.add(untranslatedCoordinate.GetSumm(DataPoint));
          counter++;
        }
      }
      index++;
    }

    // 3)
    int RotationAmount = 0;
    index = 0;
    int faultCounter = 0;

    if (workObject.randomRotation) {
      RotationAmount = rand.nextInt(3);
    }

    while (index < workingData.size()) {
      int counter = 0;
      Coordinate point = workingData.get(index);
      while (counter < RotationAmount) {
        point.Rotate();
        counter++;
      }
      if (!world.isLoaded(point.getX() + x, point.getY() + y, point.getZ() + z)) return false;

      if (!workObject.dig) {
        if (world.getTypeId((x + point.getX()), (y + point.getY()), (z + point.getZ())) > 0) {
          faultCounter++;
          if (faultCounter > (workingData.size() * (workObject.collisionPercentage / 100))) {
            return false;
          }
        }
      }
      index++;
    }

    // 4)

    index = 0;
    while (index < workingData.size()) {
      Coordinate DataPoint = workingData.get(index);
      if (world.getTypeId(x + DataPoint.getX(), y + DataPoint.getY(), z + DataPoint.getZ()) == 0) {
        ChangeWorld(
            world,
            notify,
            (x + DataPoint.getX()),
            y + DataPoint.getY(),
            z + DataPoint.getZ(),
            DataPoint.workingData,
            DataPoint.workingExtra);
      } else if (DataPoint.Digs) {
        ChangeWorld(
            world,
            notify,
            (x + DataPoint.getX()),
            y + DataPoint.getY(),
            z + DataPoint.getZ(),
            DataPoint.workingData,
            DataPoint.workingExtra);
      }
      if ((!worldSettings.denyObjectsUnderFill)
          && (workObject.underFill)
          && (world.getTypeId(x + DataPoint.getX(), y, z + DataPoint.getZ()) > 0)) {
        int depthScanner = 0;
        int blockForFill = world.getTypeId(x, y - 1, z);
        while (depthScanner < 64) {
          if (DataPoint.getY() < depthScanner) {
            int countdown = depthScanner;
            while ((world.getTypeId(
                        x + DataPoint.getX(),
                        y + DataPoint.getY() - countdown,
                        z + DataPoint.getZ())
                    == 0)
                && (countdown < 64)) {
              ChangeWorld(
                  world,
                  notify,
                  (x + DataPoint.getX()),
                  y + DataPoint.getY() - countdown,
                  z + DataPoint.getZ(),
                  blockForFill,
                  0);
              countdown++;
            }
          }
          depthScanner++;
        }
      }
      index++;
    }
    return true;
  }
  public boolean interactWithSpecial(
      ItemStack var1, EntityHuman var2, World var3, int var4, int var5, int var6, int var7) {
    if (EEProxy.isClient(var3)) {
      return false;
    }

    if (chargeLevel(var1) >= 1) {
      cleanDroplist(var1);
      int var8 = var3.getTypeId(var4, var5, var6);

      if (var8 == Block.GRAVEL.id) {
        startSearch(var3, var2, var1, var8, var4, var5, var6, false);
        return true;
      }
    }

    if (chargeLevel(var1) <= 0) {
      return false;
    }

    boolean var19 = true;
    cleanDroplist(var1);
    var2.C_();
    var3.makeSound(var2, "flash", 0.8F, 1.5F);

    for (int var9 = -chargeLevel(var1); var9 <= chargeLevel(var1); var9++) {
      for (int var10 = -chargeLevel(var1); var10 <= chargeLevel(var1); var10++) {
        int var11 = var4 + var9;
        int var13 = var6 + var10;

        if (var7 == 2) {
          var13 += chargeLevel(var1);
        } else if (var7 == 3) {
          var13 -= chargeLevel(var1);
        } else if (var7 == 4) {
          var11 += chargeLevel(var1);
        } else if (var7 == 5) {
          var11 -= chargeLevel(var1);
        }

        int var14 = var3.getTypeId(var11, var5, var13);
        int var15 = var3.getData(var11, var5, var13);

        if (!canBreak(var14, var15)) continue;

        ArrayList var16 = Block.byId[var14].getBlockDropped(var3, var11, var5, var13, var15, 0);
        Iterator var17 = var16.iterator();

        if (!breakBlock(null, var2, var3, var11, var5, var13, var14, var15)) continue;

        while (var17.hasNext()) {
          ItemStack var18 = (ItemStack) var17.next();
          addToDroplist(var1, var18);
        }

        if (var3.random.nextInt(8) == 0) {
          var3.a("largesmoke", var11, var5, var13, 0.0D, 0.0D, 0.0D);
        }

        if (var3.random.nextInt(8) != 0) continue;
        var3.a("explode", var11, var5, var13, 0.0D, 0.0D, 0.0D);
      }
    }

    ejectDropList(var3, var1, var4, var5, var6);
    return true;
  }