Posted March 13, 20169 yr Please can anyone help me, when I right click my generator tileentity, it crashes, I have a gui, container and tileentity so I'm not sure why. Crash log: ---- Minecraft Crash Report ---- // Why is it breaking Time: 13/03/16 11:29 Description: Ticking memory connection java.lang.NullPointerException: Ticking memory connection at net.minecraft.inventory.Slot.getStack(Slot.java:88) at net.minecraft.inventory.Container.getInventory(Container.java:67) at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at com.koopamillion.blocks.BlockEnergyGeneratorCoal.onBlockActivated(BlockEnergyGeneratorCoal.java:55) at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409) at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.inventory.Slot.getStack(Slot.java:88) at net.minecraft.inventory.Container.getInventory(Container.java:67) at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at com.koopamillion.blocks.BlockEnergyGeneratorCoal.onBlockActivated(BlockEnergyGeneratorCoal.java:55) at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409) at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@12b90575 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_73, Oracle Corporation Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 749875576 bytes (715 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar) UCHIJAAAA ekoop{0.1} [E Koop] (bin) GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player424'/155, l='New World', x=-444.50, y=70.00, z=-27.50]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' Gui Handler: package com.koopamillion.handler; import com.koopamillion.Main.MainRegistry; import com.koopamillion.gui.GUICoalGenerator; import com.koopamillion.gui.GUIPMachine; import com.koopamillion.inventory.ContainerEnergyGenerator; import com.koopamillion.inventory.ContainerPMachine; import com.koopamillion.lib.GuiIds; import com.koopamillion.tile_entity.TileEntityCoalGenerator; import com.koopamillion.tile_entity.TileEntityPoundingMachine; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; public class MGuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0){ TileEntityPoundingMachine tileEntityPMachine = (TileEntityPoundingMachine) world.getTileEntity(x, y, z); return new ContainerPMachine(player.inventory, tileEntityPMachine); } if(ID == 1){ TileEntityCoalGenerator tileEntiyCGEN = (TileEntityCoalGenerator) world.getTileEntity(x, y, z); return new ContainerEnergyGenerator(player, world, x, y, z); } return new ContainerEnergyGenerator(player, world, x, y, z); } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0){ TileEntityPoundingMachine tileEntityPMachine = (TileEntityPoundingMachine) world.getTileEntity(x, y, z); return new GUIPMachine(player.inventory, tileEntityPMachine); } if(ID == 1){ TileEntityCoalGenerator tileEntiyCGEN = (TileEntityCoalGenerator) world.getTileEntity(x, y, z); return new GUICoalGenerator(player, world, x, y, z); } return new ContainerEnergyGenerator(player, world, x, y, z); } public static void register(){ NetworkRegistry.INSTANCE.registerGuiHandler(MainRegistry.modInstance, new MGuiHandler()); } } Gui Coal Generator: package com.koopamillion.gui; import java.util.Arrays; import org.lwjgl.opengl.GL11; import com.koopamillion.energy.EnergyBar; import com.koopamillion.energy.IEnergy; import com.koopamillion.inventory.ContainerEnergyGenerator; import com.koopamillion.lib.Energy; import com.koopamillion.lib.RefStrings; import com.koopamillion.tile_entity.TileEntityCoalGenerator; import com.koopamillion.util.GuiUtil; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class GUICoalGenerator extends GuiContainer{ public final ResourceLocation GUI = new ResourceLocation(RefStrings.MODID + ":textures/gui/container/cGen.png"); public final EntityPlayer player; public final World world; public final int x; public final int y; public final int z; public TileEntityCoalGenerator tileentity; public GUICoalGenerator(EntityPlayer player, World world, int x, int y, int z){ super(new ContainerEnergyGenerator(player, world, x, y, z)); this.player = player; this.world = world; this.x = x; this.y = y; this.z = z; this.tileentity = (TileEntityCoalGenerator) world.getTileEntity(x, y, z); } @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y){ this.mc.getTextureManager().bindTexture(GUI); GuiUtil.drawRectangle(guiLeft, guiTop, xSize, ySize, 256, 256, 0, 0); int energyBarSize = 48; this.drawTexturedModalRect(guiLeft + 80, guiTop + 7 + energyBarSize - ((IEnergy) tileentity).getEnergyBar().getEnergyLevelScaled(energyBarSize), 176, 0, 16, ((IEnergy) tileentity).getEnergyBar().getEnergyLevelScaled(energyBarSize)); if(this.tileentity.isBurning()){ this.drawTexturedModalRect(guiLeft + 117, guiTop + 63, 176, 50, 14, 14); } } @Override public void drawGuiContainerForegroundLayer(int x, int y){ float scale = 0.8f; GL11.glScalef(scale, scale, scale); int seconds = tileentity.getBurnTime() / (20 * tileentity.burnTimeRemovedPerTick); int minutes = seconds / 60; fontRendererObj.drawString(minutes + " minutes and", 8, 8, 4210752); fontRendererObj.drawString(seconds + (this.tileentity.isBurning() ? 1 : 0) + " seconds of fuel remaining.", 8, 16, 4210752); GL11.glScalef(1 / scale, 1 / scale, 1 / scale); drawEnergyLevel(x, y); } private void drawEnergyLevel(int x, int y){ int minX = guiLeft + 80; int maxX = guiLeft + 95; int minY = guiTop + 7; int maxY = guiTop + 54; EnergyBar energyBar = ((IEnergy) tileentity).getEnergyBar(); if(x >= minX && x <= maxX && y >= minY && y <= maxX){ this.drawHoveringText(Arrays.asList(energyBar.getEnergyLevel() + " /" + energyBar.getMaxEnergyLevel() + " " + Energy.Koops.getName()), x - guiLeft - 6, y - guiTop, fontRendererObj); } } private void drawBurnTime(int x, int y){ int minX = guiLeft + 100; int maxX = guiLeft + 114; int minY = guiTop + 61; int maxY = guiTop + 74; if(x >= minX && x <= maxX && y >= minY && y <= maxX){ this.drawHoveringText(Arrays.asList(tileentity.getBurnTime() / 20 + " Burn Seconds Remaining"), x - guiLeft + 10, y - guiTop, fontRendererObj); } } } Container Energy Generator: package com.koopamillion.inventory; import com.koopamillion.tile_entity.TileEntityCoalGenerator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ContainerEnergyGenerator extends Container { public final EntityPlayer player; public final World world; public final int x; public final int y; public final int z; public TileEntityCoalGenerator tileentity; public ContainerEnergyGenerator(EntityPlayer player, World world, int x, int y, int z){ this.player = player; this.world = world; this.x = x; this.y = y; this.z = z; this.tileentity = (TileEntityCoalGenerator) world.getTileEntity(x, y, z); updateSlots(); } @Override public boolean canInteractWith(EntityPlayer player){ return true; } public ItemStack transferStackInSlot(EntityPlayer player, int slot){ return null; } public void updateSlots(){ this.inventorySlots.clear(); this.addSlotToContainer(new Slot(tileentity, 0, 80, 61)); for(int i = 0; i < 3; ++i){ for(int j = 0; j < 9; ++j){ this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 83 + i * 18)); } } for(int i = 0; i < 9; ++i){ this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 141)); //ep 33 to watch } } } Block Coal Generator: package com.koopamillion.blocks; import java.util.Random; import com.koopamillion.Main.MainRegistry; import com.koopamillion.creativetabs.MCreativeTabs; import com.koopamillion.lib.GuiIds; import com.koopamillion.lib.Names; import com.koopamillion.lib.RefStrings; import com.koopamillion.tile_entity.TileEntityCoalGenerator; import com.koopamillion.util.BlockUtil; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockEnergyGeneratorCoal extends Block{ private IIcon[] icons = new IIcon[3]; private static boolean keepInventory; private Random rand = new Random(); private int burnTime; public BlockEnergyGeneratorCoal() { super(Material.iron); this.setCreativeTab(MCreativeTabs.tabBlocks); this.setBlockName(Names.COALGEN); this.setHardness(3.5F); this.setResistance(20F); this.setLightLevel(0.0F); this.setStepSound(soundTypeMetal); this.setHarvestLevel("pickaxe", 1); } public TileEntity createNewTileEntity(World world, int meta){ return new TileEntityCoalGenerator(); } public boolean hasTileEntity(int meta){ return true; } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){ if(!world.isRemote){ player.openGui(MainRegistry.modInstance, 1, world, x, y, z); } return true; } public void registerBlockIcons(IIconRegister iconRegister){ //textures + sides icons[0] = iconRegister.registerIcon(RefStrings.MODID + ":ordinalMachineSide"); icons[1] = iconRegister.registerIcon(RefStrings.MODID + ":generatorFrontOff"); icons[2] = iconRegister.registerIcon(RefStrings.MODID + ":generatorFrontOn"); } public IIcon getIcon(int side, int meta){ if(meta == 0 && side == 3){ //what textures when machine status = off return icons[1]; } return icons[0]; } public void onBlockPlacedBy(World world, int x, int y, int z, EntityPlayer player, ItemStack itemstack){ int meta = world.getBlockMetadata(x, y, z); if(meta == 0){ TileEntityCoalGenerator tileentity = (TileEntityCoalGenerator) world.getTileEntity(x, y, z); tileentity.rotation = BlockUtil.determineMetadataBasedOnPlayerOrientation(player); } } public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ int meta = world.getBlockMetadata(x, y, z); if(meta == 0){ TileEntityCoalGenerator tileentity = (TileEntityCoalGenerator) world.getTileEntity(x, y, z); return icons[1]; }else{ return icons[0]; } } public void breakBlock(World world, int x, int y, int z, Block oldBlock, int oldMetadata) { if(!keepInventory) { TileEntityCoalGenerator tileEntity = (TileEntityCoalGenerator)world.getTileEntity(x, y, z); if(tileEntity != null) { for(int i = 0; i < tileEntity.getSizeInventory(); i++) { ItemStack itemStack = tileEntity.getStackInSlot(i); if(itemStack != null) { float f = this.rand.nextFloat() * 0.8F + 0.1F; float f1 = this.rand.nextFloat() * 0.8F + 0.1F; float f2 = this.rand.nextFloat() * 0.8F + 0.1F; while(itemStack.stackSize > 0) { int j = this.rand.nextInt(21) + 10; if(j > itemStack.stackSize) j = itemStack.stackSize; itemStack.stackSize -= j; EntityItem item = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemStack.getItem(), j, itemStack.getItemDamage())); if(itemStack.hasTagCompound()) item.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy()); world.spawnEntityInWorld(item); } } } world.func_147453_f(x, y, z, oldBlock); } } super.breakBlock(world, x, y, z, oldBlock, oldMetadata); } } TileEntity Coal Gen package com.koopamillion.tile_entity; import com.koopamillion.blocks.BlockType; import com.koopamillion.energy.EnergyBar; import com.koopamillion.energy.EnergyNet; import com.koopamillion.energy.IEnergy; import com.koopamillion.util.InventoryUtil; import com.koopamillion.util.NBTUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityCoalGenerator extends TileEntity implements IEnergy, IInventory, ISidedInventory{ private EnergyBar energyBar = new EnergyBar(12000); //how much it holds private ItemStack[] inventory = new ItemStack[7]; public int burnTime; public int currentItemBurnTime; public int rotation = 3; private float modifier = 17.5f; private float defaultModifier = 17.5f; public int burnTimeRemovedPerTick = 3; public void updateEntity(){ updateGenerating(); } private void updateGenerating(){ boolean modified = burnTime > 0; if(burnTime > 0){ if(burnTime > burnTimeRemovedPerTick){ burnTime -= burnTimeRemovedPerTick; energyBar.addEnergyWithRemaining(burnTimeRemovedPerTick); }else{ energyBar.addEnergyWithRemaining(burnTime); burnTime = 0; }}else{ if(burnTime > 0){ energyBar.addEnergyWithRemaining(burnTime); burnTime = 0; } } if(burnTime == 0 &&(TileEntityFurnace.isItemFuel(inventory[0]) || TileEntityFurnace.isItemFuel(inventory[5]) || TileEntityFurnace.isItemFuel(inventory[6]))){ currentItemBurnTime = burnTime += (int) (TileEntityFurnace.getItemBurnTime(inventory[0]) * modifier) + (int) (TileEntityFurnace.getItemBurnTime(inventory[6]) * modifier); if(inventory[0] != null){ inventory[0].stackSize--; if(inventory[0].stackSize <= 0){ inventory[0] = null; } } if(inventory[5] != null){ inventory[5].stackSize--; if(inventory[5].stackSize <= 0){ inventory[5] = null; } } if(inventory[6] != null){ inventory[6].stackSize--; if(inventory[6].stackSize <= 0){ inventory[6] = null; } } } EnergyNet.distributeEnergyToSurrounding(worldObj, xCoord, yCoord, zCoord, energyBar); if(modified != burnTime > 0){ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } @Override public boolean canAddEnergyOnSide(ForgeDirection direction){ //accept energy? return false; //no defaultly } @Override public boolean canConnect(ForgeDirection direction){ return true; } @Override public EnergyBar getEnergyBar(){ return energyBar; } @Override public void setLastRecievedDirection(ForgeDirection direction){ } @Override public int getEnergyTransferRate(){ return 10; } public Packet getDescriptionPacket(){ NBTTagCompound tag = new NBTTagCompound(); writeToNBT(tag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); } public void onDataPacket(NetworkManager manager, S35PacketUpdateTileEntity packet){ readFromNBT(packet.func_148857_g()); } @Override public int getSizeInventory(){ return InventoryUtil.getSizeInventory(inventory); } @Override public ItemStack getStackInSlot(int slot){ return InventoryUtil.getStackInSlot(inventory, slot); } @Override public ItemStack decrStackSize(int slot, int count){ return InventoryUtil.decrStackSize(inventory, slot, count); } @Override public ItemStack getStackInSlotOnClosing(int slot){ return InventoryUtil.getStackInSlotOnClosing(inventory, slot); } @Override public void setInventorySlotContents(int slot, ItemStack itemstack){ InventoryUtil.setInventorySlotContents(this, inventory, slot, itemstack); } @Override public String getInventoryName(){ return "container.powerGenerator"; } @Override public boolean hasCustomInventoryName(){ return false; } @Override public int getInventoryStackLimit(){ return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player){ return true; } @Override public void openInventory(){ } @Override public void closeInventory(){ } @Override public boolean isItemValidForSlot(int slot, ItemStack itemstack){ switch(slot){ case 0: return TileEntityFurnace.isItemFuel(itemstack); } return false; } public int getBurnTime(){ return burnTime; } public boolean isBurning(){ return burnTime > 0; } public int getBurnTimeScaled(int scale){ return burnTime * scale / currentItemBurnTime; } @Override public int[] getAccessibleSlotsFromSide(int slot){ return new int[] {0}; } @Override public boolean canInsertItem(int slot, ItemStack itemstack, int side){ return isItemValidForSlot(slot, itemstack); } @Override public boolean canExtractItem(int slot, ItemStack itemstack, int side){ return false; } @Override public BlockType getTypeOfBlock(){ return BlockType.MACHINE; } public void writeToNBT(NBTTagCompound tag){ super.writeToNBT(tag); energyBar.writeToNBT(tag); tag.setInteger("rotation", rotation); tag.setInteger("burnTime", burnTime); tag.setInteger("currentItemBurnTime", currentItemBurnTime); NBTUtil.writeItemStackArrayToNBT(inventory, tag); } public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); energyBar.readFromNBT(tag); rotation = tag.getInteger("rotation"); burnTime = tag.getInteger("burnTime"); currentItemBurnTime = tag.getInteger("currentItemBurnTime"); NBTUtil.readItemStackArrayFromNBT(inventory, tag); } } eKoop Creator: http://lumtech.byethost33.com/mods/eKoop/modinfo.html
March 13, 20169 yr Author Ok, but I don't understand about which methods, because the new TileEntity method errors when I @Override it. Thanks though. P.S The errors seem to say about the drawBackGroundGuiLayer bugging out, or is that because of I can't override the new TileEntity? eKoop Creator: http://lumtech.byethost33.com/mods/eKoop/modinfo.html
March 13, 20169 yr Author Let the BlockEnergyGeneratorCoal class extend BlockContainer and not Block. THANKS! It worked! eKoop Creator: http://lumtech.byethost33.com/mods/eKoop/modinfo.html
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.