public void func_146098_a(TileEntityBrewingStand p_146098_1_) { this.getNextWindowId(); this.playerNetServerHandler.sendPacket( new S2DPacketOpenWindow( this.currentWindowId, 5, p_146098_1_.getInventoryName(), p_146098_1_.getSizeInventory(), p_146098_1_.isCustomInventoryName())); this.openContainer = new ContainerBrewingStand(this.inventory, p_146098_1_); this.openContainer.windowId = this.currentWindowId; this.openContainer.onCraftGuiOpened(this); }
@Override public void updateEntity() { if (this.brewTime > 0) { --this.brewTime; if (this.brewTime == 0) { this.brewPotions(); this.spawnXP(); this.markDirty(); } else if (!this.canBrew()) { this.brewTime = 0; this.markDirty(); } } else if (this.canBrew()) { this.brewTime = this.getMaxBrewTime(); } int filledSlots = this.getFilledSlots(); if (filledSlots != this.filledSlots) { this.filledSlots = filledSlots; this.worldObj.setBlockMetadataWithNotify( this.xCoord, this.yCoord, this.zCoord, filledSlots, 2); } super.updateEntity(); }
/** Called by ItemBlocks after a block is set in the world, to allow post-place logic */ public void onBlockPlacedBy( World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { if (stack.hasDisplayName()) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityBrewingStand) { ((TileEntityBrewingStand) tileentity).setName(stack.getDisplayName()); } } }
@Override public boolean update(boolean force, boolean applyPhysics) { boolean result = super.update(force, applyPhysics); if (result) { brewingStand.markDirty(); } return result; }
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND); this.brewingItemStacks = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound tag = list.getCompoundTagAt(i); byte slotID = tag.getByte("Slot"); this.setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tag)); } this.brewTime = nbt.getShort("BrewTime"); }
@Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setShort("BrewTime", (short) this.brewTime); NBTTagList list = new NBTTagList(); for (int i = 0; i < this.brewingItemStacks.length; ++i) { if (this.brewingItemStacks[i] != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); this.brewingItemStacks[i].writeToNBT(tag); list.appendTag(tag); } } nbt.setTag("Items", list); }
public void setBrewingTime(int brewTime) { brewingStand.brewTime = brewTime; }