protected boolean generateDispenserContents(World worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, int meta, 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.dispenser) { worldIn.setBlockState(blockpos, Blocks.dispenser.getStateFromMeta(this.getMetadataWithOffset(Blocks.dispenser, meta)), 2); TileEntity tileentity = worldIn.getTileEntity(blockpos); if (tileentity instanceof TileEntityDispenser) { WeightedRandomChestContent.generateDispenserContents(rand, listIn, (TileEntityDispenser)tileentity, max); } return true; } else { return false; } }
protected void dispense(World worldIn, BlockPos pos) { BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); if (tileentitydispenser != null) { int i = tileentitydispenser.getDispenseSlot(); if (i < 0) { worldIn.playAuxSFX(1001, pos, 0); } else { ItemStack itemstack = tileentitydispenser.getStackInSlot(i); IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack); if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider) { ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack); tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1); } } } }
public static void generateDispenserContents(Random random, List<WeightedRandomChestContent> listIn, TileEntityDispenser dispenser, int max) { for (int i = 0; i < max; ++i) { WeightedRandomChestContent 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); } } } }
@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 createDispenser(World p_189419_1_, StructureBoundingBox p_189419_2_, Random p_189419_3_, int p_189419_4_, int p_189419_5_, int p_189419_6_, EnumFacing p_189419_7_, ResourceLocation p_189419_8_) { BlockPos blockpos = new BlockPos(this.getXWithOffset(p_189419_4_, p_189419_6_), this.getYWithOffset(p_189419_5_), this.getZWithOffset(p_189419_4_, p_189419_6_)); if (p_189419_2_.isVecInside(blockpos) && p_189419_1_.getBlockState(blockpos).getBlock() != Blocks.DISPENSER) { this.setBlockState(p_189419_1_, Blocks.DISPENSER.getDefaultState().withProperty(BlockDispenser.FACING, p_189419_7_), p_189419_4_, p_189419_5_, p_189419_6_, p_189419_2_); TileEntity tileentity = p_189419_1_.getTileEntity(blockpos); if (tileentity instanceof TileEntityDispenser) { ((TileEntityDispenser)tileentity).setLootTable(p_189419_8_, p_189419_3_.nextLong()); } return true; } else { return false; } }
protected void dispense(World worldIn, BlockPos pos) { BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); if (tileentitydispenser != null) { int i = tileentitydispenser.getDispenseSlot(); if (i < 0) { worldIn.playEvent(1001, pos, 0); } else { ItemStack itemstack = tileentitydispenser.getStackInSlot(i); IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack); if (ibehaviordispenseitem != IBehaviorDispenseItem.DEFAULT_BEHAVIOR) { tileentitydispenser.setInventorySlotContents(i, ibehaviordispenseitem.dispense(blocksourceimpl, itemstack)); } } } }
/** * Picks up fluid in front of a Dispenser and fills a container with it. */ private ItemStack fillContainer(IBlockSource source, ItemStack stack) { World world = source.getWorld(); EnumFacing dispenserFacing = source.getBlockState().getValue(BlockDispenser.FACING); BlockPos blockpos = source.getBlockPos().offset(dispenserFacing); ItemStack result = FluidUtil.tryPickUpFluid(stack, null, world, blockpos, dispenserFacing.getOpposite()); if (result == null) { return super.dispenseStack(source, stack); } if (--stack.stackSize == 0) { stack.deserializeNBT(result.serializeNBT()); } else if (((TileEntityDispenser)source.getBlockTileEntity()).addItemStack(result) < 0) { this.dispenseBehavior.dispense(source, result); } return stack; }
protected void dispense(World worldIn, BlockPos pos) { BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); if (tileentitydispenser != null) { int i = tileentitydispenser.getDispenseSlot(); if (i < 0) { worldIn.playEvent(1001, pos, 0); } else { ItemStack itemstack = tileentitydispenser.getStackInSlot(i); IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack); if (ibehaviordispenseitem != IBehaviorDispenseItem.DEFAULT_BEHAVIOR) { ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack); tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1); } } } }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityDispenser) { playerIn.displayGUIChest((TileEntityDispenser)tileentity); } return true; } }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); tileentitydispenser.setCustomName("Block Placer"); if (tileentity instanceof TileEntityDispenser) { playerIn.displayGUIChest((TileEntityDispenser)tileentity); } return true; } }
/** * Used to generate dispenser contents for structures. ex: Jungle Temples. */ protected boolean generateStructureDispenserContents(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, int par4, int par5, int par6, int par7, WeightedRandomChestContent[] par8ArrayOfWeightedRandomChestContent, int par9) { int var10 = this.getXWithOffset(par4, par6); int var11 = this.getYWithOffset(par5); int var12 = this.getZWithOffset(par4, par6); if (par2StructureBoundingBox.isVecInside(var10, var11, var12) && par1World.getBlock(var10, var11, var12) != Blocks.dispenser) { par1World.setBlock(var10, var11, var12, Blocks.dispenser, this.func_151555_a(Blocks.dispenser, par7), 2); TileEntityDispenser var13 = (TileEntityDispenser)par1World.getTileEntity(var10, var11, var12); if (var13 != null) { WeightedRandomChestContent.func_150706_a(par3Random, par8ArrayOfWeightedRandomChestContent, var13, par9); } return true; } else { return false; } }
/** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (p_149727_1_.isClient) { return true; } else { TileEntityDispenser var10 = (TileEntityDispenser)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); if (var10 != null) { p_149727_5_.func_146102_a(var10); } return true; } }
protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_) { BlockSourceImpl var5 = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_); TileEntityDispenser var6 = (TileEntityDispenser)var5.getBlockTileEntity(); if (var6 != null) { int var7 = var6.func_146017_i(); if (var7 < 0) { p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0); } else { ItemStack var8 = var6.getStackInSlot(var7); IBehaviorDispenseItem var9 = this.func_149940_a(var8); if (var9 != IBehaviorDispenseItem.itemDispenseBehaviorProvider) { ItemStack var10 = var9.dispense(var5, var8); var6.setInventorySlotContents(var7, var10.stackSize == 0 ? null : var10); } } } }
public static void func_150706_a(Random p_150706_0_, WeightedRandomChestContent[] p_150706_1_, TileEntityDispenser p_150706_2_, int p_150706_3_) { for (int var4 = 0; var4 < p_150706_3_; ++var4) { WeightedRandomChestContent var5 = (WeightedRandomChestContent)WeightedRandom.getRandomItem(p_150706_0_, p_150706_1_); int var6 = var5.theMinimumChanceToGenerateItem + p_150706_0_.nextInt(var5.theMaximumChanceToGenerateItem - var5.theMinimumChanceToGenerateItem + 1); if (var5.theItemId.getMaxStackSize() >= var6) { ItemStack var7 = var5.theItemId.copy(); var7.stackSize = var6; p_150706_2_.setInventorySlotContents(p_150706_0_.nextInt(p_150706_2_.getSizeInventory()), var7); } else { for (int var9 = 0; var9 < var6; ++var9) { ItemStack var8 = var5.theItemId.copy(); var8.stackSize = 1; p_150706_2_.setInventorySlotContents(p_150706_0_.nextInt(p_150706_2_.getSizeInventory()), var8); } } } }
protected boolean generateStructureDispenserContents(World p_74869_1_, StructureBoundingBox p_74869_2_, Random p_74869_3_, int p_74869_4_, int p_74869_5_, int p_74869_6_, int p_74869_7_, WeightedRandomChestContent[] p_74869_8_, int p_74869_9_) { int j1 = this.getXWithOffset(p_74869_4_, p_74869_6_); int k1 = this.getYWithOffset(p_74869_5_); int l1 = this.getZWithOffset(p_74869_4_, p_74869_6_); if (p_74869_2_.isVecInside(j1, k1, l1) && p_74869_1_.getBlock(j1, k1, l1) != Blocks.dispenser) { p_74869_1_.setBlock(j1, k1, l1, Blocks.dispenser, this.getMetadataWithOffset(Blocks.dispenser, p_74869_7_), 2); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)p_74869_1_.getTileEntity(j1, k1, l1); if (tileentitydispenser != null) { WeightedRandomChestContent.generateDispenserContents(p_74869_3_, p_74869_8_, tileentitydispenser, p_74869_9_); } return true; } else { return false; } }
public void func_146102_a(TileEntityDispenser p_146102_1_) { // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerDispenser(this.inventory, p_146102_1_)); if (container == null) { p_146102_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients return; } // CraftBukkit end this.getNextWindowId(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, p_146102_1_ instanceof TileEntityDropper ? 10 : 3, p_146102_1_.getInventoryName(), p_146102_1_.getSizeInventory(), p_146102_1_.hasCustomInventoryName())); this.openContainer = container; // CraftBukkit - Use container we passed to event this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); }
public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (p_149727_1_.isRemote) { return true; } else { TileEntityDispenser tileentitydispenser = (TileEntityDispenser)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); if (tileentitydispenser != null) { p_149727_5_.func_146102_a(tileentitydispenser); } return true; } }
protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_) { BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); if (tileentitydispenser != null) { int l = tileentitydispenser.func_146017_i(); if (l < 0) { p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0); } else { ItemStack itemstack = tileentitydispenser.getStackInSlot(l); IBehaviorDispenseItem ibehaviordispenseitem = this.func_149940_a(itemstack); if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider) { ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack); tileentitydispenser.setInventorySlotContents(l, itemstack1.stackSize == 0 ? null : itemstack1); } } } }
protected boolean func_74869_a(World p_74869_1_, StructureBoundingBox p_74869_2_, Random p_74869_3_, int p_74869_4_, int p_74869_5_, int p_74869_6_, int p_74869_7_, WeightedRandomChestContent[] p_74869_8_, int p_74869_9_) { int var10 = this.func_74865_a(p_74869_4_, p_74869_6_); int var11 = this.func_74862_a(p_74869_5_); int var12 = this.func_74873_b(p_74869_4_, p_74869_6_); if(p_74869_2_.func_78890_b(var10, var11, var12) && p_74869_1_.func_72798_a(var10, var11, var12) != Block.field_71958_P.field_71990_ca) { p_74869_1_.func_72832_d(var10, var11, var12, Block.field_71958_P.field_71990_ca, this.func_74863_c(Block.field_71958_P.field_71990_ca, p_74869_7_), 2); TileEntityDispenser var13 = (TileEntityDispenser)p_74869_1_.func_72796_p(var10, var11, var12); if(var13 != null) { WeightedRandomChestContent.func_76294_a(p_74869_3_, p_74869_8_, var13, p_74869_9_); } return true; } else { return false; } }
protected void func_82526_n(World p_82526_1_, int p_82526_2_, int p_82526_3_, int p_82526_4_) { BlockSourceImpl var5 = new BlockSourceImpl(p_82526_1_, p_82526_2_, p_82526_3_, p_82526_4_); TileEntityDispenser var6 = (TileEntityDispenser)var5.func_82619_j(); if(var6 != null) { int var7 = var6.func_70361_i(); if(var7 < 0) { p_82526_1_.func_72926_e(1001, p_82526_2_, p_82526_3_, p_82526_4_, 0); } else { ItemStack var8 = var6.func_70301_a(var7); IBehaviorDispenseItem var9 = this.func_96472_a(var8); if(var9 != IBehaviorDispenseItem.field_82483_a) { ItemStack var10 = var9.func_82482_a(var5, var8); var6.func_70299_a(var7, var10.field_77994_a == 0?null:var10); } } } }
public ContainerDispenser(IInventory p_i1825_1_, TileEntityDispenser p_i1825_2_) { this.field_75182_e = p_i1825_2_; int var3; int var4; for(var3 = 0; var3 < 3; ++var3) { for(var4 = 0; var4 < 3; ++var4) { this.func_75146_a(new Slot(p_i1825_2_, var4 + var3 * 3, 62 + var4 * 18, 17 + var3 * 18)); } } for(var3 = 0; var3 < 3; ++var3) { for(var4 = 0; var4 < 9; ++var4) { this.func_75146_a(new Slot(p_i1825_1_, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); } } for(var3 = 0; var3 < 9; ++var3) { this.func_75146_a(new Slot(p_i1825_1_, var3, 8 + var3 * 18, 142)); } }
public static void func_76294_a(Random p_76294_0_, WeightedRandomChestContent[] p_76294_1_, TileEntityDispenser p_76294_2_, int p_76294_3_) { for(int var4 = 0; var4 < p_76294_3_; ++var4) { WeightedRandomChestContent var5 = (WeightedRandomChestContent)WeightedRandom.func_76274_a(p_76294_0_, p_76294_1_); int var6 = var5.field_76295_d + p_76294_0_.nextInt(var5.field_76296_e - var5.field_76295_d + 1); if(var5.field_76297_b.func_77976_d() >= var6) { ItemStack var7 = var5.field_76297_b.func_77946_l(); var7.field_77994_a = var6; p_76294_2_.func_70299_a(p_76294_0_.nextInt(p_76294_2_.func_70302_i_()), var7); } else { for(int var9 = 0; var9 < var6; ++var9) { ItemStack var8 = var5.field_76297_b.func_77946_l(); var8.field_77994_a = 1; p_76294_2_.func_70299_a(p_76294_0_.nextInt(p_76294_2_.func_70302_i_()), var8); } } } }
/** * Used to generate dispenser contents for structures. ex: Jungle Temples. */ protected boolean generateStructureDispenserContents(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, int par4, int par5, int par6, int par7, WeightedRandomChestContent[] par8ArrayOfWeightedRandomChestContent, int par9) { int j1 = this.getXWithOffset(par4, par6); int k1 = this.getYWithOffset(par5); int l1 = this.getZWithOffset(par4, par6); if (par2StructureBoundingBox.isVecInside(j1, k1, l1) && par1World.getBlockId(j1, k1, l1) != Block.dispenser.blockID) { par1World.setBlock(j1, k1, l1, Block.dispenser.blockID, this.getMetadataWithOffset(Block.dispenser.blockID, par7), 2); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)par1World.getBlockTileEntity(j1, k1, l1); if (tileentitydispenser != null) { WeightedRandomChestContent.generateDispenserContents(par3Random, par8ArrayOfWeightedRandomChestContent, tileentitydispenser, par9); } return true; } else { return false; } }
/** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if (par1World.isRemote) { return true; } else { TileEntityDispenser tileentitydispenser = (TileEntityDispenser)par1World.getBlockTileEntity(par2, par3, par4); if (tileentitydispenser != null) { par5EntityPlayer.displayGUIDispenser(tileentitydispenser); } return true; } }
protected void dispense(World par1World, int par2, int par3, int par4) { BlockSourceImpl blocksourceimpl = new BlockSourceImpl(par1World, par2, par3, par4); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); if (tileentitydispenser != null) { int l = tileentitydispenser.getRandomStackFromInventory(); if (l < 0) { par1World.playAuxSFX(1001, par2, par3, par4, 0); } else { ItemStack itemstack = tileentitydispenser.getStackInSlot(l); IBehaviorDispenseItem ibehaviordispenseitem = this.getBehaviorForItemStack(itemstack); if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider) { ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack); tileentitydispenser.setInventorySlotContents(l, itemstack1.stackSize == 0 ? null : itemstack1); } } } }