private static void setLootTable(TileEntityChest chestEntity, World world, int multiplier) { double common = 75 / multiplier; double uncommon = 15; double rare = 6; double legendary = 3; double exotic = 1; RandomCollection<ResourceLocation> loottables = new RandomCollection<ResourceLocation>(); loottables.add(common, ModLootTables.common_chest); loottables.add(uncommon, ModLootTables.uncommon_chest); loottables.add(rare, ModLootTables.rare_chest); loottables.add(legendary, ModLootTables.legendary_chest); loottables.add(exotic, ModLootTables.exotic_chest); ResourceLocation table = loottables.next(world.rand); chestEntity.setLootTable(table, world.rand.nextLong()); if (table == ModLootTables.common_chest) chestEntity.setCustomName("Common Chest"); else if (table == ModLootTables.uncommon_chest) chestEntity.setCustomName("Uncommon Chest"); else if (table == ModLootTables.rare_chest) chestEntity.setCustomName("Rare Chest"); else if (table == ModLootTables.legendary_chest) chestEntity.setCustomName("Legendary Chest"); else if (table == ModLootTables.exotic_chest) chestEntity.setCustomName("Exotic Chest"); }
@Override public boolean generate(World worldIn, Random rand, BlockPos position) { if(size.equals(BlockPos.ORIGIN) && rand.nextFloat() < this.chance) { worldIn.setBlockState(position, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[rand.nextInt(4)]), 3); ((TileEntityChest)worldIn.getTileEntity(position)).setLootTable(lootTable, rand.nextLong()); return false; } for(int x = 0; x < size.getX(); x++) for(int z = 0; z < size.getZ(); z++) if(rand.nextFloat() < this.chance) { BlockPos blockpos = new BlockPos(position.add(x, 0, z)); boolean flag = false; for(EnumFacing facing : EnumFacing.HORIZONTALS) if(worldIn.getBlockState(blockpos.offset(facing)).getBlock() == Blocks.CHEST) flag = true; if(flag || !worldIn.isAirBlock(blockpos)) continue; if(setBlock) worldIn.setBlockState(blockpos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[rand.nextInt(4)]), 3); ((TileEntityChest)worldIn.getTileEntity(blockpos)).setLootTable(lootTable, rand.nextLong()); } return false; }
@Override public void postAddition(World world, BlockPos pos, Random random) { pos = pos.subtract(originAddition); world.setBlockState(pos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[random.nextInt(4)]), 3); if(world instanceof WorldServer && world.getTileEntity(pos) != null) { TileEntityChest chest = (TileEntityChest)world.getTileEntity(pos); chest.setInventorySlotContents(13, HarshenUtils.getItemsFromLootTable(world, HarshenLootTables.shrine).get(0)); for(ItemStack stack : HarshenUtils.getItemsFromLootPool(world, HarshenLootTables.shrine, "extras")) for(int count = 0; count < stack.getCount(); count++) { int slot = new Random().nextInt(27); while(chest.getStackInSlot(slot).getItem() != Item.getItemFromBlock(Blocks.AIR)) slot = new Random().nextInt(27); ItemStack stack1 = stack.copy(); stack1.setCount(1); chest.setInventorySlotContents(slot, stack1); } } }
protected boolean generateChestContents(World worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, List<WeightedRandomChestContent> listIn, int max) { BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); if (boundingBoxIn.isVecInside(blockpos) && worldIn.getBlockState(blockpos).getBlock() != Blocks.chest) { IBlockState iblockstate = Blocks.chest.getDefaultState(); worldIn.setBlockState(blockpos, Blocks.chest.correctFacing(worldIn, blockpos, iblockstate), 2); TileEntity tileentity = worldIn.getTileEntity(blockpos); if (tileentity instanceof TileEntityChest) { WeightedRandomChestContent.generateChestContents(rand, listIn, (TileEntityChest)tileentity, max); } return true; } else { return false; } }
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side) { if (!this.canProvidePower()) { return 0; } else { int i = 0; TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityChest) { i = ((TileEntityChest)tileentity).numPlayersUsing; } return MathHelper.clamp_int(i, 0, 15); } }
private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer()); for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values()) { tileentityspecialrenderer.setRendererDispatcher(this); } }
public TileEntityChest getAttachedChest() { TileEntity ent = null; ent = this.worldObj.getTileEntity(this.pos.add(1, 0, 0)); if(ent != null && ent instanceof TileEntityChest) return (TileEntityChest)ent; ent = this.worldObj.getTileEntity(this.pos.add(-1, 0, 0)); if(ent != null && ent instanceof TileEntityChest) return (TileEntityChest)ent; ent = this.worldObj.getTileEntity(this.pos.add(0, 0, 1)); if(ent != null && ent instanceof TileEntityChest) return (TileEntityChest)ent; ent = this.worldObj.getTileEntity(this.pos.add(0, 0, -1)); if(ent != null && ent instanceof TileEntityChest) return (TileEntityChest)ent; return null; }
@EventTarget private void onRender(final Render3DEvent event) { GlStateManager.pushMatrix(); for (final Object o : this.mc.theWorld.loadedTileEntityList) { final TileEntity ent = (TileEntity)o; if (!(ent instanceof TileEntityChest) && !(ent instanceof TileEntityDispenser) && !(ent instanceof TileEntityEnderChest)) { continue; } if (ent instanceof TileEntityChest && !StorageEsp.chest) { continue; } if (ent instanceof TileEntityDispenser && !StorageEsp.dispenser) { continue; } if (ent instanceof TileEntityEnderChest && !StorageEsp.enderChest) { continue; } this.drawEsp(ent, event.partialTicks); } GlStateManager.popMatrix(); }
protected boolean func_191080_a(World p_191080_1_, StructureBoundingBox p_191080_2_, Random p_191080_3_, BlockPos p_191080_4_, ResourceLocation p_191080_5_, @Nullable IBlockState p_191080_6_) { if (p_191080_2_.isVecInside(p_191080_4_) && p_191080_1_.getBlockState(p_191080_4_).getBlock() != Blocks.CHEST) { if (p_191080_6_ == null) { p_191080_6_ = Blocks.CHEST.correctFacing(p_191080_1_, p_191080_4_, Blocks.CHEST.getDefaultState()); } p_191080_1_.setBlockState(p_191080_4_, p_191080_6_, 2); TileEntity tileentity = p_191080_1_.getTileEntity(p_191080_4_); if (tileentity instanceof TileEntityChest) { ((TileEntityChest)tileentity).setLootTable(p_191080_5_, p_191080_3_.nextLong()); } return true; } else { return false; } }
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { if (!blockState.canProvidePower()) { return 0; } else { int i = 0; TileEntity tileentity = blockAccess.getTileEntity(pos); if (tileentity instanceof TileEntityChest) { i = ((TileEntityChest)tileentity).numPlayersUsing; } return MathHelper.clamp(i, 0, 15); } }
private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer()); this.mapSpecialRenderers.put(TileEntityEndGateway.class, new TileEntityEndGatewayRenderer()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer()); this.mapSpecialRenderers.put(TileEntityStructure.class, new TileEntityStructureRenderer()); this.mapSpecialRenderers.put(TileEntityShulkerBox.class, new TileEntityShulkerBoxRenderer(new ModelShulker())); for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values()) { tileentityspecialrenderer.setRendererDispatcher(this); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; VanillaDoubleChestItemHandler that = (VanillaDoubleChestItemHandler) o; if (hashCode != that.hashCode) return false; final TileEntityChest otherChest = getOtherChest(); if (mainChestIsUpper == that.mainChestIsUpper) return Objects.equal(mainChest, that.mainChest) && Objects.equal(otherChest, that.getOtherChest()); else return Objects.equal(mainChest, that.getOtherChest()) && Objects.equal(otherChest, that.mainChest); }
/** * Adds chest to the structure and sets its contents */ protected boolean generateChest(World worldIn, StructureBoundingBox structurebb, Random randomIn, int x, int y, int z, ResourceLocation loot) { BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); if (structurebb.isVecInside(blockpos) && worldIn.getBlockState(blockpos).getBlock() != Blocks.CHEST) { IBlockState iblockstate = Blocks.CHEST.getDefaultState(); worldIn.setBlockState(blockpos, Blocks.CHEST.correctFacing(worldIn, blockpos, iblockstate), 2); TileEntity tileentity = worldIn.getTileEntity(blockpos); if (tileentity instanceof TileEntityChest) { ((TileEntityChest)tileentity).setLootTable(loot, randomIn.nextLong()); } return true; } else { return false; } }
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { if (!blockState.canProvidePower()) { return 0; } else { int i = 0; TileEntity tileentity = blockAccess.getTileEntity(pos); if (tileentity instanceof TileEntityChest) { i = ((TileEntityChest)tileentity).numPlayersUsing; } return MathHelper.clamp_int(i, 0, 15); } }
private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer()); this.mapSpecialRenderers.put(TileEntityEndGateway.class, new TileEntityEndGatewayRenderer()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer()); this.mapSpecialRenderers.put(TileEntityStructure.class, new TileEntityStructureRenderer()); for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values()) { tileentityspecialrenderer.setRendererDispatcher(this); } }
public static IInventory getInventory(final TileEntity tile) { if (tile instanceof IInventory) { if (tile instanceof TileEntityChest) { final int x = tile.xCoord; final int y = tile.yCoord; final int z = tile.zCoord; final Block blockID = tile.getWorldObj().getBlock(x, y, z); if (!tile.getWorldObj().isAirBlock(x, y, z) && blockID instanceof BlockChest) { if (tile.getWorldObj().getBlock(x - 1, y, z) == blockID) { return (IInventory)new InventoryLargeChest("container.chestDouble", (IInventory)tile.getWorldObj().getTileEntity(x - 1, y, z), (IInventory)tile); } if (tile.getWorldObj().getBlock(x + 1, y, z) == blockID) { return (IInventory)new InventoryLargeChest("container.chestDouble", (IInventory)tile, (IInventory)tile.getWorldObj().getTileEntity(x + 1, y, z)); } if (tile.getWorldObj().getBlock(x, y, z - 1) == blockID) { return (IInventory)new InventoryLargeChest("container.chestDouble", (IInventory)tile.getWorldObj().getTileEntity(x, y, z - 1), (IInventory)tile); } if (tile.getWorldObj().getBlock(x, y, z + 1) == blockID) { return (IInventory)new InventoryLargeChest("container.chestDouble", (IInventory)tile, (IInventory)tile.getWorldObj().getTileEntity(x, y, z + 1)); } } } return (IInventory)tile; } return null; }
public static IInventory getInventory(IInventory inv) { if (inv instanceof TileEntityChest) { TileEntityChest chest = (TileEntityChest) inv; TileEntityChest neighbour = null; if (chest.adjacentChestXNeg != null) { neighbour = chest.adjacentChestXNeg; } else if (chest.adjacentChestXPos != null) { neighbour = chest.adjacentChestXPos; } else if (chest.adjacentChestZNeg != null) { neighbour = chest.adjacentChestZNeg; } else if (chest.adjacentChestZPos != null) { neighbour = chest.adjacentChestZPos; } if (neighbour != null) { return new InventoryLargeChest("", (ILockableContainer)inv, (ILockableContainer)neighbour); } return inv; } return inv; }
/** * Generate trapped chests with items. */ public static void generateChestContents(ComponentGraveStone component, World world, Random random, int xCoord, int yCoord, int zCoord, EnumFacing facing, ResourceLocation loot, boolean trapped) { int x = component.getXWithOffset(xCoord, zCoord); int y = component.getYWithOffset(yCoord); int z = component.getZWithOffset(xCoord, zCoord); BlockPos pos = new BlockPos(x, y, z); IBlockState chest; if (trapped) { chest = StateHelper.getChest(StateHelper.TRAPPED_CHEST, facing); } else { chest = StateHelper.getChest(StateHelper.CHEST, facing); } world.setBlockState(pos, chest, 2); TileEntityChest tileentity = (TileEntityChest) world.getTileEntity(pos); if (tileentity != null) { tileentity.setLootTable(loot, random.nextLong()); } }
protected boolean placeChest(World world, StructureBoundingBox box, Random rand, int x, int y, int z, EnumFacing f, boolean a) { int i1 = this.getXWithOffset(x, z); int j1 = this.getYWithOffset(y); int k1 = this.getZWithOffset(x, z); BlockPos pos = new BlockPos(i1, j1, k1); if (f.getAxis() == Axis.Y) f = EnumFacing.NORTH; if (box.isVecInside(pos) && (world.getBlockState(pos).getBlock() != Blocks.CHEST)) { world.setBlockState(pos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, f), 2); TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileEntityChest) ((TileEntityChest) tile).setLootTable(a ? loot2 : rand.nextInt(10) < 2 ? lootB : loot, rand.nextLong()); return true; } else return false; }
private int getEmptySpace( final TileEntityChest chest, final ItemStack stack ) { int temp = -1; for ( int i = 0; i < chest.getSizeInventory(); i++ ) { final ItemStack stack2 = chest.getStackInSlot( i ); if ( temp < 0 && (stack2 == null || stack2.stackSize == 0) ) { temp = i; } else if ( stack2 != null && stack.getItem() == stack2.getItem() && stack2.stackSize > 0 && stack2.stackSize + stack.stackSize <= stack.getMaxStackSize() && !stack2.isItemDamaged() && !stack.isItemDamaged() && stack.getItemDamage() == stack2.getItemDamage() ) { stack.stackSize += stack2.stackSize; return i; } } return temp; }
public void renderChest(EntityBoatChest entity, float partialTicks) { TileEntitySpecialRenderer<TileEntityChest> renderer = TileEntityRendererDispatcher.instance.getSpecialRenderer(DUMMY_CHEST); if(renderer != null) { GlStateManager.pushMatrix(); GlStateManager.translate(-0.5, 0.125, -0.5); GlStateManager.rotate(180, 1, 0, 0); GlStateManager.rotate(90, 0, 1, 0); DUMMY_CHEST.numPlayersUsing = entity.getPlayersUsing(); DUMMY_CHEST.lidAngle = entity.getLidAngle(); DUMMY_CHEST.prevLidAngle = entity.getPrevLidAngle(); DUMMY_CHEST.setWorld(Boatifull.proxy.getClientWorld()); renderer.renderTileEntityAt(DUMMY_CHEST, 0, 0, 0, partialTicks, -1); GlStateManager.popMatrix(); } }
/** Generate chest contents */ public static void generateChestContents(Random random, List<WeightedRandomChestContent> listIn, TileEntityChest dispenser, int max) { for (int i = 0; i < max; ++i) { WeightedRandomChestContent weightedrandomchestcontent = WeightedRandom.getRandomItem(random, listIn); int j = weightedrandomchestcontent.minStackSize + random.nextInt(weightedrandomchestcontent.maxStackSize - weightedrandomchestcontent.minStackSize + 1); if (weightedrandomchestcontent.theItemId.getMaxStackSize() >= j) { ItemStack itemstack1 = weightedrandomchestcontent.theItemId.copy(); itemstack1.stackSize = j; dispenser.setInventorySlotContents(random.nextInt(dispenser.getSizeInventory()), itemstack1); } else { for (int k = 0; k < j; ++k) { ItemStack itemstack = weightedrandomchestcontent.theItemId.copy(); itemstack.stackSize = 1; dispenser.setInventorySlotContents(random.nextInt(dispenser.getSizeInventory()), itemstack); } } } }
public void checkRemoteStorage() { if (remoteX != 0 && remoteY != 0 && remoteZ != 0 && !inventory.get(itemTradeSlot).isEmpty()) { for (int i = itemStorageSlot1; i <= itemStorageSlot9; i++) { if (inventory.get(i).isEmpty()) { loadRemoteChunk(remoteX, remoteY, remoteZ); TileEntity te = world.getTileEntity(new BlockPos(remoteX, remoteY, remoteZ)); if (te != null && te instanceof TileEntityChest) { TileEntityChest chest = (TileEntityChest) te; for (int j = 0; j < chest.getSizeInventory(); j++) { if (inventory.get(i).isEmpty() && !chest.getStackInSlot(j).isEmpty() && chest.getStackInSlot(j).getItem() == inventory.get(itemTradeSlot).getItem()) { inventory.set(i, chest.getStackInSlot(j)); chest.setInventorySlotContents(j, ItemStack.EMPTY); checkSellingInventory(); } } } } } } }
public static IInventory getInventory(IInventory inv) { if (inv instanceof TileEntityChest) { TileEntityChest chest = (TileEntityChest) inv; TileEntityChest neighbour = null; boolean reverse = false; if (chest.adjacentChestXNeg != null) { neighbour = chest.adjacentChestXNeg; reverse = true; } else if (chest.adjacentChestXPos != null) { neighbour = chest.adjacentChestXPos; } else if (chest.adjacentChestZNeg != null) { neighbour = chest.adjacentChestZNeg; reverse = true; } else if (chest.adjacentChestZPos != null) { neighbour = chest.adjacentChestZPos; } if (neighbour != null) { if (reverse) { return new InventoryLargeChest("", neighbour, inv); } else { return new InventoryLargeChest("", inv, neighbour); } } } return inv; }
@Override public String execute(CommandSender sender, String[] params)throws CommandException { EntityPlayerMP player = getSenderAsEntity(sender.getMinecraftISender(), EntityPlayerMP.class); BlockPos coord1 = new BlockPos(player.getPosition().getX() + 1, player.getPosition().getY(), player.getPosition().getZ()); BlockPos coord2 = new BlockPos(player.getPosition().getX() + 1, player.getPosition().getY(), player.getPosition().getZ() + 1); WorldUtils.setBlock(player.world, coord1, Blocks.CHEST); WorldUtils.setBlock(player.world, coord2, Blocks.CHEST); InventoryLargeChest chestInv = new InventoryLargeChest("Large chest", (TileEntityChest) player.world.getTileEntity(coord1), (TileEntityChest) player.world.getTileEntity(coord2)); int count = 0; for (int i = 0; i < player.inventory.getSizeInventory() && count < chestInv.getSizeInventory(); i++) { chestInv.setInventorySlotContents(count++, player.inventory.getStackInSlot(i)); player.inventory.setInventorySlotContents(i, ItemStack.EMPTY); } sender.sendLangfileMessage("command.dropstore.stored"); return null; }
public static IInventory getChestInventory(TileEntityChest chest) { for (EnumFacing face : EnumFacing.Plane.HORIZONTAL) { BlockPos offsetPos = chest.getPos().offset(face); if (chest.getWorld().getBlockState(offsetPos).getBlock() == chest.getBlockType()) { TileEntity te = chest.getWorld().getTileEntity(offsetPos); if (te instanceof TileEntityChest) { TileEntityChest chest2 = (TileEntityChest) te; if (face != EnumFacing.WEST && face != EnumFacing.NORTH) { return new InventoryLargeChest("container.chestDouble", chest, chest2); } else { return new InventoryLargeChest("container.chestDouble", chest2, chest); } } } } return chest; }
public static IInventory getChest(IInventory inventory) { if (!(inventory instanceof TileEntityChest)) { return inventory; } TileEntityChest chest = (TileEntityChest) inventory; BlockPosition[] adjacent = new BlockPosition[] { new BlockPosition(chest.xCoord + 1, chest.yCoord, chest.zCoord), new BlockPosition(chest.xCoord - 1, chest.yCoord, chest.zCoord), new BlockPosition(chest.xCoord, chest.yCoord, chest.zCoord + 1), new BlockPosition(chest.xCoord, chest.yCoord, chest.zCoord - 1) }; for (BlockPosition pos : adjacent) { TileEntity otherChest = chest.getWorldObj().getTileEntity(pos.x, pos.y, pos.z); if (otherChest instanceof TileEntityChest) { return new InventoryLargeChest("", chest, (TileEntityChest) otherChest); } } return inventory; }
@Override public void onRender(EventOnRender event){ for(Object o : invoker.getTileEntityList()){ if(o instanceof TileEntityChest){ TileEntityChest chest = (TileEntityChest) o; RenderUtils.drawESP(true, invoker.getChestX(chest) - invoker.getRenderPosX(), invoker.getChestY(chest) - invoker.getRenderPosY(), invoker.getChestZ(chest) - invoker.getRenderPosZ(), invoker.getChestX(chest)+1 - invoker.getRenderPosX(), invoker.getChestY(chest)+1 - invoker.getRenderPosY(), invoker.getChestZ(chest)+1 - invoker.getRenderPosZ(), 0.3, 0.48, 1, 0.183, 0.3, 0.48, 1, 1); if(drawTracers.isChecked()){ RenderUtils.drawTracer(0, 0, 0, invoker.getChestX(chest)+0.5 - invoker.getRenderPosX(), invoker.getChestY(chest)+0.5 - invoker.getRenderPosY(), invoker.getChestZ(chest)+0.5 - invoker.getRenderPosZ(), 0.3, 0.48, 1, 1); } } } }
/** * Used to generate chests with items in it. ex: Temple Chests, Village Blacksmith Chests, Mineshaft Chests. */ protected boolean generateStructureChestContents(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, int par4, int par5, int par6, WeightedRandomChestContent[] par7ArrayOfWeightedRandomChestContent, int par8) { int var9 = this.getXWithOffset(par4, par6); int var10 = this.getYWithOffset(par5); int var11 = this.getZWithOffset(par4, par6); if (par2StructureBoundingBox.isVecInside(var9, var10, var11) && par1World.getBlock(var9, var10, var11) != Blocks.chest) { par1World.setBlock(var9, var10, var11, Blocks.chest, 0, 2); TileEntityChest var12 = (TileEntityChest)par1World.getTileEntity(var9, var10, var11); if (var12 != null) { WeightedRandomChestContent.generateChestContents(par3Random, par7ArrayOfWeightedRandomChestContent, var12, par8); } return true; } else { return false; } }
private TileEntityRendererDispatcher() { this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityRendererPiston()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable()); this.mapSpecialRenderers.put(TileEntityEndPortal.class, new RenderEndPortal()); this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); Iterator var1 = this.mapSpecialRenderers.values().iterator(); while (var1.hasNext()) { TileEntitySpecialRenderer var2 = (TileEntitySpecialRenderer)var1.next(); var2.func_147497_a(this); } }
@Override public boolean generate(World world, Random rand, int i, int j, int k) { while(LocationIsInvalid(world, i, j, k) && j > 0) j--; j++; if(!LocationIsInvalid(world, i, j, k) && !LocationIsInvalid(world, i, j + 2, k)) { world.setBlock(i, j, k, Blocks.quartz_block, 2, 3); world.setBlock(i+1, j, k, Blocks.quartz_block, 2, 3); world.setBlock(i-1, j, k, Blocks.quartz_block, 2, 3); world.setBlock(i, j, k+1, Blocks.quartz_block, 2, 3); world.setBlock(i, j, k-1, Blocks.quartz_block, 2, 3); world.setBlock(i, j+1, k, Blocks.chest, 2, 2); WeightedRandomChestContent[] content = new WeightedRandomChestContent[] {new WeightedRandomChestContent(AtlantisMod.atlantisEye, 1, 1, 1, 1)}; TileEntityChest tileentitychest = (TileEntityChest)world.getTileEntity(i, j, k); if (tileentitychest != null) WeightedRandomChestContent.generateChestContents(rand, content, tileentitychest, 1); return true; } return false; }
private boolean tryPlaceChest(int x, int y, int z, TileEntityChest tile) { boolean replace = false; int id = worldObj.getBlockId(x, y, z); Block bl = Block.blocksList[id]; if(worldObj.getBlockMaterial(x, y-1, z).isSolid()) { if(bl != null) { replace = bl.isBlockReplaceable(worldObj, x, y, z); } if(worldObj.isAirBlock(x, y, z) || replace) { worldObj.setBlock(x, y, z, Block.chest.blockID); worldObj.setBlockTileEntity(x, y, z, tile); return true; } } return false; }
protected boolean isItemValid(TileEntity tileEntity, ItemStack itemStack) { IInventory inventory = (IInventory)tileEntity; Class<?> cls = tileEntity.getClass(); if(cls == TEChest.class) return new SlotChest(inventory, 0, 0, 0).addItemException(ContainerChestTFC.getExceptions()).isItemValid(itemStack); if(cls == TileEntityChest.class) return new Slot(inventory, 0, 0, 0).isItemValid(itemStack); if(cls == TileEntityStorageRack.class) return new SlotStorageRack(inventory, 0, 0, 0).isItemValid(itemStack); return false; }