public boolean interact( World var1, BlockPosition var2, IBlockData var3, EntityHuman var4, EnumUsedHand var5, ItemStack var6, EnumDirection var7, float var8, float var9, float var10) { class_yu var11 = var4.cq(); TileEntity var12 = var1.getTileEntity(var2); if (var11 != null && var12 instanceof TileEntityEnderChest) { if (var1.getType(var2.up()).getBlock().isOccluding()) { return true; } else if (var1.isClientSide) { return true; } else { var11.a((TileEntityEnderChest) var12); var4.openContainer((IInventory) var11); var4.b(StatisticList.V); return true; } } else { return true; } }
public void postPlace( World var1, BlockPosition var2, IBlockData var3, EntityLiving var4, ItemStack var5) { super.postPlace(var1, var2, var3, var4, var5); if (var5.hasDisplayName()) { TileEntity var6 = var1.getTileEntity(var2); if (var6 instanceof TileEntityEnchantTable) { ((TileEntityEnchantTable) var6).a(var5.getDisplayName()); } } }
public static boolean addToRandomPipeEntry(TileEntity var0, Orientations var1, ItemStack var2) { World var3 = var0.world; // APIProxy.getWorld(); LinkedList var4 = new LinkedList(); int var5; Position var6; for (var5 = 0; var5 < 6; ++var5) { if (var1.reverse().ordinal() != var5) { var6 = new Position( (double) var0.x, (double) var0.y, (double) var0.z, Orientations.values()[var5]); var6.moveForwards(1.0D); TileEntity var7 = var3.getTileEntity((int) var6.x, (int) var6.y, (int) var6.z); if (var7 instanceof IPipeEntry && ((IPipeEntry) var7).acceptItems()) { var4.add(Orientations.values()[var5]); } } } if (var4.size() > 0) { var5 = var3.random.nextInt(var4.size()); var6 = new Position( (double) var0.x, (double) var0.y, (double) var0.z, (Orientations) var4.get(var5)); Position var10 = new Position( (double) var0.x, (double) var0.y, (double) var0.z, (Orientations) var4.get(var5)); var6.x += 0.5D; var6.y += (double) getPipeFloorOf(var2); var6.z += 0.5D; var6.moveForwards(0.5D); var10.moveForwards(1.0D); IPipeEntry var8 = (IPipeEntry) var3.getTileEntity((int) var10.x, (int) var10.y, (int) var10.z); EntityPassiveItem var9 = new EntityPassiveItem(var3, var6.x, var6.y, var6.z, var2); var8.entityEntering(var9, var6.orientation); var2.count = 0; return true; } else { return false; } }
public static IAreaProvider getNearbyAreaProvider(World var0, int var1, int var2, int var3) { TileEntity var4 = var0.getTileEntity(var1 + 1, var2, var3); TileEntity var5 = var0.getTileEntity(var1 - 1, var2, var3); TileEntity var6 = var0.getTileEntity(var1, var2, var3 + 1); TileEntity var7 = var0.getTileEntity(var1, var2, var3 - 1); TileEntity var8 = var0.getTileEntity(var1, var2 + 1, var3); TileEntity var9 = var0.getTileEntity(var1, var2 - 1, var3); return var4 instanceof IAreaProvider ? (IAreaProvider) var4 : (var5 instanceof IAreaProvider ? (IAreaProvider) var5 : (var6 instanceof IAreaProvider ? (IAreaProvider) var6 : (var7 instanceof IAreaProvider ? (IAreaProvider) var7 : (var8 instanceof IAreaProvider ? (IAreaProvider) var8 : (var9 instanceof IAreaProvider ? (IAreaProvider) var9 : null))))); }
/** Called whenever the block is removed. */ @Override public void remove(World par1World, int par2, int par3, int par4) { if (!c) { TileEntityIronFurnace tileentityfurnace = (TileEntityIronFurnace) par1World.getTileEntity(par2, par3, par4); if (tileentityfurnace != null) { label0: for (int i = 0; i < tileentityfurnace.getSize(); i++) { ItemStack itemstack = tileentityfurnace.getItem(i); if (itemstack == null) { continue; } float f = a.nextFloat() * 0.8F + 0.1F; float f1 = a.nextFloat() * 0.8F + 0.1F; float f2 = a.nextFloat() * 0.8F + 0.1F; do { if (itemstack.count <= 0) { continue label0; } int j = a.nextInt(21) + 10; if (j > itemstack.count) { j = itemstack.count; } itemstack.count -= j; EntityItem entityitem = new EntityItem( par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.id, j, itemstack.getData())); if (itemstack.hasTag()) { entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone()); } float f3 = 0.05F; entityitem.motX = (float) a.nextGaussian() * f3; entityitem.motY = (float) a.nextGaussian() * f3 + 0.2F; entityitem.motZ = (float) a.nextGaussian() * f3; par1World.addEntity(entityitem); } while (true); } } } super.remove(par1World, par2, par3, par4); }
public static void preDestroyBlock(World var0, int var1, int var2, int var3) { TileEntity var4 = var0.getTileEntity(var1, var2, var3); if (var4 instanceof IInventory && !APIProxy.isClient(var0)) { dropItems(var0, (IInventory) var4, var1, var2, var3); } if (var4 instanceof TileBuildCraft) { ((TileBuildCraft) var4).destroy(); } }
/** * Called upon block activation (left or right click on the block.). The three integers represent * x,y,z of the block. */ @Override public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) { if (world.isStatic) { return true; } TileEntityIronFurnace tileentityfurnace = (TileEntityIronFurnace) world.getTileEntity(i, j, k); if (tileentityfurnace != null) { entityhuman.openGui(MhoDilandau.getInstance(), 0, world, i, j, k); } return true; }
public boolean interactWith( ItemStack var1, EntityHuman var2, World var3, BlockPosition var4, EnumDirection var5, float var6, float var7, float var8) { if (var5 == EnumDirection.DOWN) { return false; } else if (!var3.getType(var4).getBlock().getMaterial().isBuildable()) { return false; } else { var4 = var4.shift(var5); if (!var2.a(var4, var5, var1)) { return false; } else if (!Blocks.STANDING_SIGN.canPlace(var3, var4)) { return false; } else if (var3.isClientSide) { return true; } else { if (var5 == EnumDirection.UP) { int var9 = MathHelper.floor((double) ((var2.yaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15; var3.setTypeAndData( var4, Blocks.STANDING_SIGN .getBlockData() .set(BlockFloorSign.ROTATION, Integer.valueOf(var9)), 3); } else { var3.setTypeAndData( var4, Blocks.WALL_SIGN.getBlockData().set(BlockWallSign.FACING, var5), 3); } --var1.count; TileEntity var10 = var3.getTileEntity(var4); if (var10 instanceof TileEntitySign && !ItemBlock.a(var3, var2, var4, var1)) { var2.openSign((TileEntitySign) var10); } return true; } } }
/** Update which block ID the furnace is using depending on whether or not it is burning */ public static void a(boolean par0, World par1World, int par2, int par3, int par4) { int i = par1World.getData(par2, par3, par4); TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); c = true; if (par0) { par1World.setTypeId(par2, par3, par4, MhoDilandau.BlockIronFurnaceActive.id); } else { par1World.setTypeId(par2, par3, par4, MhoDilandau.BlockIronFurnaceIdle.id); } c = false; par1World.setData(par2, par3, par4, i); if (tileentity != null) { tileentity.m(); par1World.setTileEntity(par2, par3, par4, tileentity); } }
public boolean interact( World var1, BlockPosition var2, IBlockData var3, EntityHuman var4, EnumUsedHand var5, ItemStack var6, EnumDirection var7, float var8, float var9, float var10) { if (var1.isClientSide) { return true; } else { TileEntity var11 = var1.getTileEntity(var2); if (var11 instanceof TileEntityEnchantTable) { var4.a((ITileEntityContainer) ((TileEntityEnchantTable) var11)); } return true; } }
@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 TileEntity getTarget(World var1) { return var1.getTileEntity(this.posX, this.posY, this.posZ); }
public static TileEntity getTile(World var0, Position var1, Orientations var2) { Position var3 = new Position(var1); var3.orientation = var2; var3.moveForwards(1.0D); return var0.getTileEntity((int) var3.x, (int) var3.y, (int) var3.z); }
@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(); } } }