Posted June 24, 20187 yr Hey, i'm in need of some help concerning a container. Container: Spoiler package com.andreas.ame.containers; import com.andreas.ame.tileentities.EntityTable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; public class ContainerTable extends Container{ public ContainerTable(InventoryPlayer playerInv, final EntityTable table) { IItemHandler inventory = table.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); addSlotToContainer(new SlotItemHandler(inventory, 0, 80, 35) { @Override public void onSlotChanged() { table.markDirty(); } }); for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(playerInv, k, 8 + k * 18, 142)); } } @Override public boolean canInteractWith(EntityPlayer playerIn) { // TODO Auto-generated method stub return true; } } Building the Player Inventory works, but the SlotItemHandler gives me this Crash Report: Spoiler ---- Minecraft Crash Report ---- // Ooh. Shiny. Time: 6/24/18 4:59 PM Description: Ticking player java.lang.NullPointerException: Ticking player at net.minecraftforge.items.SlotItemHandler.getStack(SlotItemHandler.java:79) at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:97) at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:365) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2168) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:871) at net.minecraft.world.World.updateEntity(World.java:2127) at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:672) at net.minecraft.world.World.updateEntities(World.java:1903) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Thread.java:748) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace: at net.minecraftforge.items.SlotItemHandler.getStack(SlotItemHandler.java:79) at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:97) at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:365) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2168) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:871) at net.minecraft.world.World.updateEntity(World.java:2127) -- Player being ticked -- Details: Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) Entity ID: 231 Entity Name: Player711 Entity's Exact location: -254.36, 65.00, 243.01 Entity's Block location: World: (-255,65,243), Chunk: (at 1,4,3 in -16,15; contains blocks -256,0,240 to -241,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Entity's Momentum: 0.00, -0.08, 0.00 Entity's Passengers: [] Entity's Vehicle: ~~ERROR~~ NullPointerException: null Stacktrace: at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:672) at net.minecraft.world.World.updateEntities(World.java:1903) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:643) -- Affected level -- Details: Level name: TEST All players: 1 total; [EntityPlayerMP['Player711'/231, l='TEST', x=-254.36, y=65.00, z=243.01]] Chunk stats: ServerChunkCache: 625 Drop: 0 Level seed: 6028521562681449438 Level generator: ID 00 - default, ver 1. Features enabled: true Level generator options: Level spawn location: World: (-228,64,236), Chunk: (at 12,4,12 in -15,14; contains blocks -240,0,224 to -225,255,239), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 46199 game time, 46199 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 4716 (now: true), thunder time: 16996 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:842) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Thread.java:748) -- System Details -- Details: Minecraft Version: 1.12.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_171, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 649280984 bytes (619 MB) / 1023934464 bytes (976 MB) up to 1894252544 bytes (1806 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP 9.42 Powered by Forge 14.23.4.2705 11 mods loaded, 11 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored | State | ID | Version | Source | Signature | |:--------- |:----------------- |:------------ |:----------------------------------------------- |:---------------------------------------- | | UCHIJAAAA | minecraft | 1.12.2 | minecraft.jar | None | | UCHIJAAAA | mcp | 9.42 | minecraft.jar | None | | UCHIJAAAA | FML | 8.0.99.99 | forgeSrc-1.12.2-14.23.4.2705.jar | None | | UCHIJAAAA | forge | 14.23.4.2705 | forgeSrc-1.12.2-14.23.4.2705.jar | None | | UCHIJAAAA | ame | 1.0 | ame-0.1.jar | None | | UCHIJAAAA | codechickenlib | 3.2.0.345 | CodeChickenLib-1.12.2-3.2.0.345-universal.jar | f1850c39b2516232a2108a7bd84d1cb5df93b261 | | UCHIJAAAA | redstoneflux | 2.0.2 | RedstoneFlux-1.12-2.0.2.3-universal.jar | 8a6abf2cb9e141b866580d369ba6548732eff25f | | UCHIJAAAA | cofhcore | 4.5.2 | CoFHCore-1.12.2-4.5.2.19-universal.jar | None | | UCHIJAAAA | cofhworld | 1.2.0 | CoFHWorld-1.12.2-1.2.0.5-universal.jar | 8a6abf2cb9e141b866580d369ba6548732eff25f | | UCHIJAAAA | thermalfoundation | 2.5.0 | ThermalFoundation-1.12.2-2.5.0.19-universal.jar | 8a6abf2cb9e141b866580d369ba6548732eff25f | | UCHIJAAAA | thermalexpansion | 5.5.0 | ThermalExpansion-1.12.2-5.5.0.29-universal.jar | 8a6abf2cb9e141b866580d369ba6548732eff25f | Loaded coremods (and transformers): GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 1 / 8; [EntityPlayerMP['Player711'/231, l='TEST', x=-254.36, y=65.00, z=243.01]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' Help would be appreciated! On an unrelated Note: How can I easily figure out where my Container will be on Screen ?(x and y position) Edited June 24, 20187 yr by GloriousAlpaca
June 24, 20187 yr Author 8 minutes ago, diesieben07 said: You passed a null IItemHandler to SlotItemHandler. How could I fix this? 8 minutes ago, diesieben07 said: You passed a null IItemHandler to SlotItemHandler. Don't you specify that yourself? Yes, but i don't know what position the coordinates correspond to in-game. Edited June 24, 20187 yr by GloriousAlpaca
June 24, 20187 yr Author 5 minutes ago, diesieben07 said: Don't pass null. Sadly I don't really know why i'm passing the null. :T 5 minutes ago, diesieben07 said: Can you please provide your use case / actual problem? This sounds like an x/y problem. I have made a gui image and want to put the container slots on the corresponding positions. My problem is that I don't know the coordinates of the image slots. Edited June 24, 20187 yr by GloriousAlpaca
June 24, 20187 yr Show your EntityTable class. 4 minutes ago, GloriousAlpaca said: My problem is that I don't know the coordinates of the image slots. Try pixels, measured from the top left. Edited June 24, 20187 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 24, 20187 yr Author The Entity Class is basically empty: Spoiler package com.andreas.ame.tileentities; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.energy.IEnergyStorage; public class EntityTable extends TileEntity implements IEnergyStorage{ public int energy = 0; @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setInteger("energy", energy); return super.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound) { energy = compound.getInteger("energy"); super.readFromNBT(compound); } @Override public int receiveEnergy(int maxReceive, boolean simulate) { // TODO Auto-generated method stub return 0; } @Override public int extractEnergy(int maxExtract, boolean simulate) { // TODO Auto-generated method stub return 0; } @Override public int getEnergyStored() { // TODO Auto-generated method stub return energy; } @Override public int getMaxEnergyStored() { // TODO Auto-generated method stub return 0; } @Override public boolean canExtract() { // TODO Auto-generated method stub return false; } @Override public boolean canReceive() { // TODO Auto-generated method stub return true; } } Edited June 24, 20187 yr by GloriousAlpaca
June 24, 20187 yr Author 1 minute ago, diesieben07 said: You have made the GUI texture, hence you are the one who knows where you put the slots. Okay so if i understand this correctly i'm giving the coordinates in pixels on my image?
June 24, 20187 yr 10 minutes ago, GloriousAlpaca said: IEnergyStorage Why are you doing this and not implementing an Energy Capability? Capabilities are the solution to the stacks of mod-supplied interfaces. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 24, 20187 yr Author Just now, diesieben07 said: Yes. Okay that's great! 1 minute ago, diesieben07 said: ... yet you expect it to have the IItemHandler capability: I have tried implementing it there but failed miserably thus just leaving it out. How would I give it the capability ?
June 24, 20187 yr Author Just now, Draco18s said: Why are you doing this and not implementing an Energy Capability? Capabilities are the solution to the stacks of mod-supplied interfaces. I'll remember that thanks!
June 24, 20187 yr Author 4 minutes ago, diesieben07 said: https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/ Okay i'll give it a go! Thank you for helping.
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.