
MyRedAlien43
Members-
Posts
37 -
Joined
-
Last visited
Everything posted by MyRedAlien43
-
Sorry for being dumb but where/what is it?
-
Tile Entity: package beta.mod.tileentity.press; import beta.mod.init.ItemInit; import beta.mod.tileentity.ModTET; import beta.mod.util.GuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.IInteractionObject; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; @SuppressWarnings("unused") public class TileEntityPress extends TileEntity implements ITickable, IInteractionObject { public ItemStackHandler handler = new ItemStackHandler(3); private int burnTime, currentBurnTime, cookTime, totalCookTime; private ITextComponent customName; private TileEntityPress(TileEntityType<?> type) { super(type); } public TileEntityPress() { this(ModTET.PRESS); } @Override public ITextComponent getName() { return this.hasCustomName() ? this.customName : new TextComponentTranslation("container.press"); } @Override public boolean hasCustomName() { return this.customName != null; } public void setCustomName(ITextComponent customName) { this.customName = customName; } @Override public void read(NBTTagCompound compound) { super.read(compound); this.handler.deserializeNBT(compound.getCompound("inventory")); this.burnTime = compound.getInt("BurnTime"); this.cookTime = compound.getInt("CookTime"); this.totalCookTime = compound.getInt("TotalCookTime"); this.currentBurnTime = compound.getInt("CurrentBurnTime"); if(compound.contains("CustomName", Constants.NBT.TAG_STRING)) { this.customName = ITextComponent.Serializer.fromJson(compound.getString("CustomName")); } } @Override public NBTTagCompound write(NBTTagCompound compound) { super.write(compound); compound.setTag("inventory", this.handler.serializeNBT()); compound.setInt("BurnTime", this.burnTime); compound.setInt("CookTime", this.cookTime); compound.setInt("TotalCookTime", this.totalCookTime); compound.setInt("CurrentBurnTime", this.currentBurnTime); if(this.hasCustomName()) { compound.setString("CustomName", ITextComponent.Serializer.toJson(customName)); } return compound; } public boolean isPressing() { return this.burnTime > 0; } @Override public void tick() { boolean flag = this.isPressing(), flag1 = false; if(this.isPressing()) { this.burnTime--; } if(!this.world.isRemote) { ItemStack stack = this.handler.getStackInSlot(1); if(this.isPressing() || !stack.isEmpty() && !this.handler.getStackInSlot(0).isEmpty()) { if(!this.isPressing() && this.canSmelt()) { this.burnTime = getBurnTime(stack); this.currentBurnTime = this.burnTime; if(this.isPressing()) { flag1 = true; if(!stack.isEmpty()) { Item item = stack.getItem(); stack.shrink(1); if(stack.isEmpty()) { ItemStack item1 = item.getContainerItem(stack); this.handler.setStackInSlot(1, item1); } } } } if(this.isPressing() && this.canSmelt()) { this.cookTime++; if(this.cookTime == this.totalCookTime) { this.cookTime = 0; this.totalCookTime = this.getCookTime(this.handler.getStackInSlot(0)); this.smeltItem(); flag1 = true; } } else { this.cookTime = 0; } } else if(!this.isPressing() && this.cookTime > 0) { this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.totalCookTime); } if(flag != this.isPressing()) { flag1 = true; BlockPress.setState(this.isPressing(), this.world, this.pos); } } } public void dropInventoryItems(World worldIn, BlockPos pos) { for(int i = 0; i < this.handler.getSlots(); i++) { ItemStack stack = this.handler.getStackInSlot(i); if(!stack.isEmpty()) { InventoryHelper.spawnItemStack(worldIn, (double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), stack); } } } public int getCookTime(ItemStack stack) { return 200; } private boolean canSmelt() { if(this.handler.getStackInSlot(0).isEmpty()) { return false; } else { ItemStack stack = PressRecipes.instance().getCookingResult(this.handler.getStackInSlot(0)); if(stack.isEmpty()) { return false; } else { ItemStack stack1 = this.handler.getStackInSlot(2); if(stack1.isEmpty()) { return true; } else if(!stack1.isItemEqual(stack)) { return false; } else if(stack1.getCount() + stack.getCount() <= 64 && stack1.getCount() + stack.getCount() <= stack1.getMaxStackSize()) { return true; } else { return stack1.getCount() + stack.getCount() <= stack.getMaxStackSize(); } } } } public void smeltItem() { if(this.canSmelt()) { ItemStack stack = this.handler.getStackInSlot(0), stack1 = PressRecipes.instance().getCookingResult(stack), stack2 = this.handler.getStackInSlot(2); if(stack2.isEmpty()) { this.handler.setStackInSlot(2, stack1.copy()); } else if(stack2.getItem() == stack1.getItem()) { stack2.grow(stack1.getCount()); } if(stack.getItem() == Blocks.WET_SPONGE.asItem() && !this.handler.getStackInSlot(1).isEmpty() && this.handler.getStackInSlot(1).getItem() == Items.BUCKET) { this.handler.setStackInSlot(1, new ItemStack(Items.WATER_BUCKET)); } stack.shrink(1); } } @SuppressWarnings("unlikely-arg-type") public static int getBurnTime(ItemStack stack) { if(stack.isEmpty()) { return 0; } else { int burnTime = net.minecraft.tileentity.TileEntityFurnace.getBurnTimes().get(stack); if(burnTime >= 0) return burnTime; Item item = stack.getItem(); if(item == ItemInit.GRAPE) { return 20; } } return 200; } public static boolean isItemFuel(ItemStack stack) { return getBurnTime(stack) > 0; } @Override public String getGuiID() { return GuiHandler.GUI.PRESS.getGuiID(); } @Override public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerPress(playerInventory, this); } public int getField(int id) { switch(id) { case 0: return this.burnTime; case 1: return this.currentBurnTime; case 2: return this.cookTime; case 3: return this.totalCookTime; default: return 0; } } public void setField(int id, int value) { switch(id) { case 0: this.burnTime = value; break; case 1: this.currentBurnTime = value; break; case 2: this.cookTime = value; break; case 3: this.totalCookTime = value; break; } } public int getFieldCount() { return 4; } public void clear() { for(int i = 0; i < this.handler.getSlots(); i++) { this.handler.setStackInSlot(i, ItemStack.EMPTY); } } public ItemStackHandler getInventory() { return this.handler; } @SuppressWarnings("unchecked") @Override public <T> LazyOptional<T> getCapability(Capability<T> cap) { if(!this.removed && cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return LazyOptional.of(() -> (T)handler); } else { return LazyOptional.empty(); } } @Override public ITextComponent getCustomName() { return this.hasCustomName() ? this.customName : new TextComponentTranslation("Press"); } } (I made setField and getField, not from IInventory) Container: package beta.mod.tileentity.press; import beta.mod.tileentity.press.slots.SlotPressFuel; import beta.mod.tileentity.press.slots.SlotPressOutput; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.items.SlotItemHandler; public class ContainerPress extends Container { private final TileEntityPress te; private int cookTime, totalCookTime, burnTime, currentBurnTime; public ContainerPress(InventoryPlayer plrInv, TileEntityPress te) { this.te = te; this.addSlot(new SlotItemHandler(te.getInventory(), 0, 56, 53)); this.addSlot(new SlotPressFuel(te.getInventory(), 1, 56, 17)); this.addSlot(new SlotPressOutput(plrInv.player, te.getInventory(), 2, 116, 35)); for(int i = 0; i < 3; i++) { for(int j = 0; j < 9; ++j) { this.addSlot(new Slot(plrInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for(int k = 0; k < 9; k++) { this.addSlot(new Slot(plrInv, k, 8 + k * 18, 142)); } } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); for(int i = 0; i < this.listeners.size(); i++) { IContainerListener icontainerlistener = this.listeners.get(i); if (this.cookTime != this.te.getField(2)) { icontainerlistener.sendWindowProperty(this, 2, this.te.getField(2)); } if (this.burnTime != this.te.getField(0)) { icontainerlistener.sendWindowProperty(this, 0, this.te.getField(0)); } if (this.currentBurnTime != this.te.getField(1)) { icontainerlistener.sendWindowProperty(this, 1, this.te.getField(1)); } if (this.totalCookTime != this.te.getField(3)) { icontainerlistener.sendWindowProperty(this, 3, this.te.getField(3)); } } this.cookTime = this.te.getField(2); this.burnTime = this.te.getField(0); this.currentBurnTime = this.te.getField(1); this.totalCookTime = this.te.getField(3); } @Override public void updateProgressBar(int id, int data) { this.te.setField(id, data); } @Override public boolean canInteractWith(EntityPlayer playerIn) { return playerIn.getDistanceSq((double)te.getPos().getX() + 0.5d, (double)te.getPos().getY() + 0.5d, (double)te.getPos().getZ() + 0.5d) <= 64.0d; } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index == 2) { if (!this.mergeItemStack(itemstack1, 3, 39, true)) { return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); } else if (index != 1 && index != 0) { if (!PressRecipes.instance().getCookingResult(itemstack1).isEmpty()) { if (!this.mergeItemStack(itemstack1, 0, 1, false)) { return ItemStack.EMPTY; } } else if (TileEntityPress.isItemFuel(itemstack1)) { if (!this.mergeItemStack(itemstack1, 1, 2, false)) { return ItemStack.EMPTY; } } else if (index >= 3 && index < 30) { if (!this.mergeItemStack(itemstack1, 30, 39, false)) { return ItemStack.EMPTY; } } else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) { return ItemStack.EMPTY; } if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(playerIn, itemstack1); } return itemstack; } }
-
I got another tile entity, with yet another problem.. When I right click it, it does nothing, but when I click the barrel(the other tile entity I had problems with) it opens. Gui Handler: public class GuiHandler { public static GuiScreen openGui(FMLPlayMessages.OpenContainer openContainer) { BlockPos pos = openContainer.getAdditionalData().readBlockPos(); EntityPlayerSP player = Minecraft.getInstance().player; //Barrel if(openContainer.getId().equals(new ResourceLocation(Main.modid, "barrel"))) { return new GuiBarrel(player.inventory, (TileEntityBarrel)Minecraft.getInstance().world.getTileEntity(pos), player); } if(openContainer.getId().equals(new ResourceLocation(Main.modid, "press"))) { return new GuiPress(player.inventory, (TileEntityPress)Minecraft.getInstance().world.getTileEntity(pos)); } return null; } public static enum GUI { BARREL("moresimplestuff:barrel", new ResourceLocation(Main.modid, "textures/gui/barrel.png")), PRESS("moresimplestuff:press", new ResourceLocation(Main.modid, "textures/gui/press.png")); private ResourceLocation texture; private String guiId; GUI(String guiId, ResourceLocation texture) { this.guiId = guiId; this.texture = texture; } public String getGuiID() { return guiId; } public ResourceLocation getTexture() { return texture; } } } How I registered it (in my main class): ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> GuiHandler::openGui); And how I open it (block class): @Override public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntityPress te = (TileEntityPress)worldIn.getTileEntity(pos); if(te != null) { if(player instanceof EntityPlayerMP && !(player instanceof FakePlayer)) { EntityPlayerMP playermp = (EntityPlayerMP)player; NetworkHooks.openGui(playermp, te, buf -> buf.writeBlockPos(pos)); } } return true; } } If you need to me to show other code, just tell me
-
Thank you very much! This is exactly what I needed.
-
Oh god this wasn't what I meant... I also don't want to turn this into a tutorial either. What I meant was, What does the Gui Factory have to extend/implement or method to have?
-
Ohh that makes sense. Mind showing me how to do so? Sorry, 1.13.2 is new to me.
-
@Override public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerBarrel(playerInventory, this, playerIn); } @Override public String getGuiID() { return "moresimplestuff:barrel"; } IGuiHandler?
-
Yea, I meant I now extend only TileEntity. @Override public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityBarrel && player instanceof EntityPlayerMP) { TileEntityBarrel barrel = (TileEntityBarrel)tileentity; NetworkHooks.openGui((EntityPlayerMP)player, barrel); } return true; } } I don't know if this is correct. Also, my block does NOT extend BlockContainer
-
I extended TileEntityLockable, so thanks. But now when I try to open the tile entity it does nothing.
-
So, I made a tile entity that stores items, it works and all of that but the only problem is that it doesn't save the contents. My read and write methods: @Override public void read(NBTTagCompound compound) { super.read(compound); this.handler = new ItemStackHandler(this.getSizeInventory()); this.handler.deserializeNBT(compound.getCompound("inventory")); if(compound.contains("CustomName", 8)) { this.customName = ITextComponent.Serializer.fromJson(compound.getString("CustomName")); } } @Override public NBTTagCompound write(NBTTagCompound compound) { super.write(compound); compound.setTag("inventory", this.handler.serializeNBT()); if(this.hasCustomName()) { compound.setString("CustomName", ITextComponent.Serializer.toJson(customName)); } return compound; } (What the handler is:) public ItemStackHandler handler = new ItemStackHandler(9); And I get no error. After I rejoin the items I put in just disappear like they were never saved (or loaded).
-
[1.13.2] BlockState giving NullPointerException
MyRedAlien43 replied to MyRedAlien43's topic in Modder Support
I got the gui and the container in the gui handler, but could u show an example of how i should set it up? Or, to be more exact, use ItemStackHandler as a capability? -
I was making a tile entity that stores stuff, and when I was done I got this weird NullPointerException I can't figure out how to solve! My code of the Tile Entity: package beta.mod.tileentity.barrel; import beta.mod.init.BlockInit; import beta.mod.tileentity.ModTET; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.inventory.Container; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.IChestLid; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityLockableLoot; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.NonNullList; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.IBlockReader; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; public class TileEntityBarrel extends TileEntityLockableLoot implements IChestLid, ITickable { private NonNullList<ItemStack> items = NonNullList.withSize(9, ItemStack.EMPTY); protected float lidAngle, prevLidAngle; protected int numPlayersUsing; private int ticksSinceSync; private net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler> handler; protected TileEntityBarrel(TileEntityType<?> type) { super(type); } public TileEntityBarrel() { this(ModTET.BARREL); } @Override public int getSizeInventory() { return 9; } @Override public boolean isEmpty() { for(ItemStack stack : this.items) { if(!stack.isEmpty()) { return false; } } return true; } @Override public ITextComponent getName() { ITextComponent component = this.getCustomName(); return (ITextComponent)(component != null ? component : new TextComponentTranslation("container.barrel")); } @Override public void read(NBTTagCompound compound) { super.read(compound); this.items = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY); if(!this.checkLootAndRead(compound)) { ItemStackHelper.loadAllItems(compound, items); } if(compound.contains("CustomName", 8)) { this.customName = ITextComponent.Serializer.fromJson(compound.getString("CustomName")); } } @Override public NBTTagCompound write(NBTTagCompound compound) { super.write(compound); if(!this.checkLootAndWrite(compound)) { ItemStackHelper.saveAllItems(compound, items); } ITextComponent component = this.getCustomName(); if(component != null) { compound.setString("CustomName", ITextComponent.Serializer.toJson(component)); } return compound; } @Override public int getInventoryStackLimit() { return 64; } @Override public void tick() { int i = this.pos.getX(); int j = this.pos.getY(); int k = this.pos.getZ(); this.ticksSinceSync++; if(!this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + i + j + k) % 200 == 0) { this.numPlayersUsing = 0; for(EntityPlayer entityplayer : this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB((double)((float)i - 5.0F), (double)((float)j - 5.0F), (double)((float)k - 5.0F), (double)((float)(i + 1) + 5.0F), (double)((float)(j + 1) + 5.0F), (double)((float)(k + 1) + 5.0F)))) { if(entityplayer.openContainer instanceof ContainerBarrel) { this.numPlayersUsing++; } } } this.prevLidAngle = this.lidAngle; if(this.numPlayersUsing > 0 && this.lidAngle == 0) { this.playSound(SoundEvents.BLOCK_IRON_TRAPDOOR_OPEN); } if(this.numPlayersUsing == 0 && this.lidAngle > 0.0f || this.numPlayersUsing > 0 && this.lidAngle < 1.0f) { float f2 = this.lidAngle; if (this.numPlayersUsing > 0) { this.lidAngle += 0.1F; } else { this.lidAngle -= 0.1F; } if (this.lidAngle > 1.0F) { this.lidAngle = 1.0F; } if(this.lidAngle < 0.5f && f2 >= 0.5f) { this.playSound(SoundEvents.BLOCK_IRON_TRAPDOOR_CLOSE); } if(this.lidAngle < 0.0f) { this.lidAngle = 0.0f; } } } private void playSound(SoundEvent soundIn) { double d0 = (double)this.pos.getX() + 0.5d; double d1 = (double)this.pos.getY() + 0.5d; double d2 = (double)this.pos.getZ() + 0.5d; this.world.playSound(null, d0, d1, d2, soundIn, SoundCategory.BLOCKS, 0.5f, this.world.rand.nextFloat() * 0.1f + 0.9f); } @Override public boolean receiveClientEvent(int id, int type) { if(id == 1) { this.numPlayersUsing = type; return true; } else { return super.receiveClientEvent(id, type); } } @Override public void openInventory(EntityPlayer player) { if(!player.isSpectator()) { if(this.numPlayersUsing < 0) { this.numPlayersUsing = 0; } this.numPlayersUsing++; this.onOpenOrClose(); } } @Override public void closeInventory(EntityPlayer player) { if(!player.isSpectator()) { this.numPlayersUsing--; this.onOpenOrClose(); } } protected void onOpenOrClose() { Block block = this.getBlockState().getBlock(); if(block instanceof BlockBarrel) { this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing); this.world.notifyNeighborsOfStateChange(this.pos, block); } } @Override public String getGuiID() { return "moresimplestuff:barrel"; } @Override public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { this.fillWithLoot(playerIn); return new ContainerBarrel(playerInventory, this, playerIn); } @Override protected NonNullList<ItemStack> getItems() { return this.items; } @Override protected void setItems(NonNullList<ItemStack> itemsIn) { this.items = itemsIn; } @Override public float getLidAngle(float partialTicks) { return this.prevLidAngle + (this.lidAngle - this.prevLidAngle) * partialTicks; } public static int getPlayersUsing(IBlockReader reader, BlockPos posIn) { IBlockState state = reader.getBlockState(posIn); if(state.hasTileEntity()) { TileEntity te = reader.getTileEntity(posIn); if(te instanceof TileEntityBarrel) { return ((TileEntityBarrel)te).numPlayersUsing; } } return 0; } public static void swapContents(TileEntityBarrel barrel, TileEntityBarrel otherBarrel) { NonNullList<ItemStack> list = barrel.getItems(); barrel.setItems(otherBarrel.getItems()); otherBarrel.setItems(list); } @Override public void updateContainingBlockInfo() { super.updateContainingBlockInfo(); if(this.handler != null) { this.handler.invalidate(); this.handler = null; } } @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, EnumFacing side) { if(!this.removed && cap == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if(this.handler == null) { this.handler = LazyOptional.of(this::createUnSidedHandler); } return this.handler.cast(); } return super.getCapability(cap, side); } @Override public void remove() { super.remove(); if(handler != null) { handler.invalidate(); } } } Error log: [23:53:40.268] [Server thread/FATAL] [minecraft/MinecraftServer]: Error executing task java.util.concurrent.ExecutionException: java.lang.NullPointerException at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_202] at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_202] at net.minecraft.util.Util.runTask(Util.java:127) [?:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:770) [?:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:724) [?:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:122) [?:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:611) [?:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_202] Caused by: java.lang.NullPointerException at net.minecraft.tileentity.TileEntity.getBlockState(TileEntity.java:145) ~[?:?] at beta.mod.tileentity.barrel.TileEntityBarrel.onOpenOrClose(TileEntityBarrel.java:183) ~[?:?] at beta.mod.tileentity.barrel.TileEntityBarrel.openInventory(TileEntityBarrel.java:170) ~[?:?] at beta.mod.tileentity.barrel.ContainerBarrel.<init>(ContainerBarrel.java:16) ~[?:?] at beta.mod.tileentity.barrel.TileEntityBarrel.createContainer(TileEntityBarrel.java:198) ~[?:?] at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:171) ~[?:?] at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:114) ~[?:?] at beta.mod.tileentity.barrel.BlockBarrel.onBlockActivated(BlockBarrel.java:55) ~[?:?] at net.minecraft.block.state.IBlockState.onBlockActivated(IBlockState.java:315) ~[?:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:389) ~[?:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItemOnBlock(NetHandlerPlayServer.java:873) ~[?:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:62) ~[?:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:13) ~[?:?] at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:15) ~[?:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_202] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_202] at net.minecraft.util.Util.runTask(Util.java:126) ~[?:?] ... 5 more (Most of the code is from the chest class)