Posted May 28, 201411 yr Hello everybody ! I begin in modding with forge and i want to do some custome gui. And i made it works ! My custom gui is opened with the J key and all slots are well placed (There are 40 slots in the container plus all the slots of the player inventory. But when i click on a slot with a number greater than 44, my game crashes. I use a custom container and a custom tileEntity and in my custom container, there is a clickSlot method overriden(ftm it returns null). But when it crashes, it says there is an error on this method... Here is the error report : ---- Minecraft Crash Report ---- // Hi. I'm Minecraft, and I'm a crashaholic. Time: 27/05/14 23:30 Description: Ticking memory connection java.lang.IndexOutOfBoundsException: Index: 63, Size: 45 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at net.minecraft.inventory.Container.slotClick(Container.java:302) at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:948) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:41) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:113) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:716) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:604) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:742) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at net.minecraft.inventory.Container.slotClick(Container.java:302) at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:948) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:41) at net.minecraft.network.play.client.C0EPacketClickWindow.processPacket(C0EPacketClickWindow.java:113) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@559eae50 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:716) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:604) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:742) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_05, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 678128456 bytes (646 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 4994 (279664 bytes; 0 MB) allocated, 4868 (272608 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP v9.01-pre FML v7.2.156.1060 Minecraft Forge 10.12.1.1060 4 mods loaded, 4 mods active mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.2.156.1060} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.12.1.1060} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available yugfm{0.0.1} [YuGiOh FM] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 1808 (101248 bytes; 0 MB) allocated, 1637 (91672 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player878'/366, l='New World', x=180,50, y=72,00, z=203,50]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'
May 28, 201411 yr Did you override slotClick method? It seems that you had mistaken with the function "clickSlot" ... You should add @Override annotation when you overrides a function. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
May 28, 201411 yr Author Yep i said the wrong methode in my first message but i overrided the good one ^^ here is my container code : package shuyin.test.fy; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class DeckContainer extends Container{ protected DeckTile tile_entity; public DeckContainer(InventoryPlayer player_inventory, DeckTile tile){ this.tile_entity = tile; int k = 0; for(int j = 0 ; j < 5 ; j++){ for(int i = 0 ; i < 8 ; i++){ addSlotToContainer(new CardSlot(tile_entity, k, 17 + i * 18, 11 + j*18)); k++; } } bindPlayerInventory(player_inventory); System.out.println(this.inventorySlots.size()); } protected void bindPlayerInventory(InventoryPlayer player_inventory){ for(int i = 0; i < 3; i++){ for(int j = 0; j < 9; j++){ addSlotToContainer(new Slot(player_inventory, j + i * 9 + 9, 8 + j * 18, 140 + i * 18)); } } for(int i = 0; i < 9; i++){ addSlotToContainer(new Slot(player_inventory, i, 8 + i * 18, 198)); } } @Override public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) { System.out.println( par1+" " + par2 + " " + par3); System.out.println(this.inventorySlots.size()); return null; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ ItemStack stack = null; Slot slot_object = (Slot) inventorySlots.get(slot); if(slot_object != null && slot_object.getHasStack()){ ItemStack stack_in_slot = slot_object.getStack(); stack = stack_in_slot.copy(); if(slot == 0){ if(!mergeItemStack(stack_in_slot, 1, inventorySlots.size(), true)){ return null; } } else if(!mergeItemStack(stack_in_slot, 0, 1, false)){ return null; } if(stack_in_slot.stackSize == 0){ slot_object.putStack(null); } else{ slot_object.onSlotChanged(); } } return stack; } @Override public boolean canInteractWith(EntityPlayer player) { return tile_entity.isUseableByPlayer(player); } } It's very strange because i wrote some debug messages that appears in my console when i play there is nothing weird...
May 28, 201411 yr I think it is related with your GuiHandler. can you post the code? I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
May 28, 201411 yr Author Here is my GuiHandler code : import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; import cpw.mods.fml.common.network.IGuiHandler; public class CommonProxy implements IGuiHandler{ @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if ( ID == DeckGui.GUI_ID){ return new DeckContainer(player.inventory, Main.liste.get(player.getUniqueID())); } // TODO Auto-generated method stub return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if ( ID == DeckGui.GUI_ID){ return new DeckGui(player.inventory, Main.liste.get(player.getUniqueID())); } // TODO Auto-generated method stub return null; } } The Main.list is a HashMap with UUID keys and DeckTile .
May 28, 201411 yr TileEntity is related to a Block in the World. You can't have it in this HashMap from your Main class.
May 28, 201411 yr I think your container is not overriden during the crash.. Can you debug with it.? I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
May 28, 201411 yr Before that: Can you post the code related with Main.list? I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
May 28, 201411 yr Author here is my keyInputHandler (i use it for open my GUI) : import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; public class KeyInputHandler extends CommonProxy{ @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent eventK) { EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; if(KeyBindings.deck.isPressed()) if(player != null && Main.instance != null && player.worldObj != null){ if(!Main.liste.containsKey(player.getUniqueID())) Main.liste.put(player.getUniqueID(), new DeckTile()); player.openGui(Main.instance, 30, player.worldObj, (int)Math.floor(player.posX), (int)Math.floor(player.posY), (int)Math.floor(player.posZ)); } } @SubscribeEvent public void onMouseInput(InputEvent.MouseInputEvent eventM){ EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; //not used ftm } } and my main class : import java.util.HashMap; import java.util.UUID; import shuyin.yugioh.fm.items.Carte; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid=Main.MODID, name = Main.MODNAME, version=Main.VERSION) public class Main { public static HashMap<UUID, DeckTile> liste; @SidedProxy(clientSide= "shuyin.yugioh.fm.KeyInputHandler", serverSide= "shuyin.yugioh.fm.CommonProxy") public static KeyInputHandler proxy = new KeyInputHandler(); public static CommonProxy gui = new CommonProxy(); public static final String MODID = "yugfm"; public static final String MODNAME = "testModGui"; public static final String VERSION = "0.0.1"; public static Item carte; @Instance ( MODID ) public static Main instance; public static CreativeTabs tabCard = new CreativeTabs("tabName") { public Item getTabIconItem() { return Items.arrow; } }; @EventHandler public void preInit(FMLPreInitializationEvent e) { } @EventHandler public void init(FMLInitializationEvent e) { instance = this; liste = new HashMap<UUID, DeckTile>(); KeyBindings.init(); carte = new Carte(); GameRegistry.registerItem(carte, MODID + ":" + "test"); GameRegistry.registerTileEntity(DeckTile.class, MODID); NetworkRegistry.INSTANCE.registerGuiHandler(this, gui); FMLCommonHandler.instance().bus().register(proxy); } @EventHandler public void postInit(FMLPostInitializationEvent e) { } }
May 29, 201411 yr TileEntity is related to a Block in the World. You can't have it in this HashMap from your Main class. World#getTileEntity(int, int, int) And opening your container from client side (key handler) is not going to work. You need to send a packet to the server and open the container on server side.
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.