Jump to content

Recommended Posts

Posted

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'

Posted

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.

Posted

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...

Posted

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.

Posted

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 .

Posted

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.

Posted

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.

Posted

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)
{

}
}

 

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Yep I did upgrade just because it showed me a new version available.  I'll redownload the mod list and make sure anything works.  Thanks!
    • The latest log was taken down by pastebin for some reason. Did you try removing the mods you added? The mods you updated, was there a specific reason you updated, or just because? It's possible the updates introduced incompatibilitie, or even need a newer build of forge. If you didn't need the updates for a specific reason, you could also try downgrading those mods.
    • Please read the FAQ, and post logs as described there. https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/
    • I am using forge 1.20.1 (version 47.3.0). My pc has an RTX 4080 super and an i9 14900 KF, I am on the latest Nvidia graphics driver, latest windows 10 software, I have java 23, forge 1.12.2 works and so does all vanilla versions but for some reason no version of forge 1.20.1 works and instead the game just crashes with the error code "-1." I have no mods in my mods fodler, I have deleted my options.txt and forge.cfg files in case my settings were causing a crash and have tried removing my forge version from the installations folder and reinstalling but no matter what I still crash with the same code and my log doesn't tell me anything: 18:34:53.924 game 2025-02-06 18:34:53,914 main WARN Advanced terminal features are not available in this environment 18:34:54.023 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, mrmirchi, --version, 1.20.1-forge-47.3.0, --gameDir, C:\Users\aryam\AppData\Roaming\.minecraft, --assetsDir, C:\Users\aryam\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, 2db00ea8d678420a8956109a85d90e9d, --accessToken, ????????, --clientId, ZWI3NThkNzMtNmNlZS00MGI5LTgyZTgtYmZkNzcwMTM5MGMx, --xuid, 2535436222989555, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\aryam\AppData\Roaming\.minecraft\quickPlay\java\1738838092785.json, --launchTarget, forgeclient, --fml.forgeVersion, 47.3.0, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] 18:34:54.027 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 10 arch amd64 version 10.0 18:34:54.132 game [18:34:54] [main/INFO] [ne.mi.fm.lo.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow 18:34:54.191 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 18:34:54.303 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 18:34:54.367 monitor Process Monitor Process crashed with exit code -1     screenshot of log: https://drive.google.com/file/d/1WdkH88H865XErvmIqAKjlg7yrmj8EYy7/view?usp=sharing
    • I am currently working on a big mod, but I'm having trouble with my tabs, I want to find a way to add tabs inside tabs, like how in mrcrayfishes furniture mod, his furniture tab has multiple other sub tabs to them, so i know it is possible but i just don't know how it is possible, any help would be appreciated, thanks
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.