Jump to content

Getting an ID for a slot?


TLHPoE

Recommended Posts

How would I find an available ID for my slot? In my container, I have the player's inventory and my 6 slots. How would I decide what numbers to use?

 

ContainerAccessories:

 

 

public ContainerAccessories(InventoryPlayer playerInv, World world, int x, int y, int z)
{

	this.worldObj = world;

	this.addSlotToContainer(new Slot(playerInv, 0, 134, 12));
	this.addSlotToContainer(new Slot(playerInv, 0, 134, 30));
	this.addSlotToContainer(new Slot(playerInv, 0, 134, 48));

	this.addSlotToContainer(new Slot(playerInv, 0, 152, 12));
	this.addSlotToContainer(new Slot(playerInv, 0, 152, 30));
	this.addSlotToContainer(new Slot(playerInv, 0, 152, 48));

	int l;
	int i1;

	for (l = 0; l < 3; ++l)
	{
		for (i1 = 0; i1 < 9; ++i1)
		{
			this.addSlotToContainer(new Slot(playerInv, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18));
		}
	}

	for (l = 0; l < 9; ++l)
	{
		this.addSlotToContainer(new Slot(playerInv, l, 8 + l * 18, 142));
	}

}

 

 

Kain

Link to comment
Share on other sites

Well, if I did my math right, the next ID available would be 37. I tried 37, and went all the way up to 42. Crashed  :(

 

Crash

 

 

2013-10-26 18:34:18 [iNFO] [sTDERR] net.minecraft.util.ReportedException: Ticking player

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:63)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

2013-10-26 18:34:18 [iNFO] [sTDERR] Caused by: java.lang.ArrayIndexOutOfBoundsException: 4

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.entity.player.InventoryPlayer.getStackInSlot(InventoryPlayer.java:658)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.inventory.Slot.getStack(Slot.java:91)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.inventory.Container.getInventory(Container.java:69)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:55)

2013-10-26 18:34:18 [iNFO] [sTDERR] at cpw.mods.fml.common.network.NetworkRegistry.openRemoteGui(NetworkRegistry.java:321)

2013-10-26 18:34:18 [iNFO] [sTDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.openGui(FMLNetworkHandler.java:352)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2480)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.gloriarpg.handler.PlayerTickHandler.playerTick(PlayerTickHandler.java:58)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.gloriarpg.handler.PlayerTickHandler.tickStart(PlayerTickHandler.java:26)

2013-10-26 18:34:18 [iNFO] [sTDERR] at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:28)

2013-10-26 18:34:18 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:122)

2013-10-26 18:34:18 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:383)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:282)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:325)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.network.NetServerHandler.handleFlying(NetServerHandler.java:304)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.network.packet.Packet10Flying.processPacket(Packet10Flying.java:51)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)

2013-10-26 18:34:18 [iNFO] [sTDERR] at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)

2013-10-26 18:34:18 [iNFO] [sTDERR] ... 6 more

2013-10-26 18:34:18 [sEVERE] [Minecraft-Server] Encountered an unexpected exception ReportedException

net.minecraft.util.ReportedException: Ticking player

at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:63)

at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)

at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

Caused by: java.lang.ArrayIndexOutOfBoundsException: 4

at net.minecraft.entity.player.InventoryPlayer.getStackInSlot(InventoryPlayer.java:658)

at net.minecraft.inventory.Slot.getStack(Slot.java:91)

at net.minecraft.inventory.Container.getInventory(Container.java:69)

at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:55)

at cpw.mods.fml.common.network.NetworkRegistry.openRemoteGui(NetworkRegistry.java:321)

at cpw.mods.fml.common.network.FMLNetworkHandler.openGui(FMLNetworkHandler.java:352)

at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2480)

at net.gloriarpg.handler.PlayerTickHandler.playerTick(PlayerTickHandler.java:58)

at net.gloriarpg.handler.PlayerTickHandler.tickStart(PlayerTickHandler.java:26)

at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:28)

at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:122)

at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:383)

at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:282)

at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:325)

at net.minecraft.network.NetServerHandler.handleFlying(NetServerHandler.java:304)

at net.minecraft.network.packet.Packet10Flying.processPacket(Packet10Flying.java:51)

at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)

at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)

at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)

... 6 more

2013-10-26 18:34:18 [sEVERE] [Minecraft-Server] This crash report has been saved to: C:\Users\Kavin\Dropbox\Mods\GloriaRPG\mcp\jars\.\crash-reports\crash-2013-10-26_18.34.18-server.txt

2013-10-26 18:34:18 [iNFO] [Minecraft-Server] Stopping server

2013-10-26 18:34:18 [iNFO] [Minecraft-Server] Saving players

2013-10-26 18:34:18 [iNFO] [sTDOUT] ---- Minecraft Crash Report ----

2013-10-26 18:34:18 [iNFO] [sTDOUT] // I let you down. Sorry :(

2013-10-26 18:34:18 [iNFO] [sTDOUT]

2013-10-26 18:34:18 [iNFO] [sTDOUT] Time: 10/26/13 6:34 PM

2013-10-26 18:34:18 [iNFO] [sTDOUT] Description: Ticking player

2013-10-26 18:34:18 [iNFO] [sTDOUT]

2013-10-26 18:34:18 [iNFO] [sTDOUT] java.lang.ArrayIndexOutOfBoundsException: 4

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.entity.player.InventoryPlayer.getStackInSlot(InventoryPlayer.java:658)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.inventory.Slot.getStack(Slot.java:91)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.inventory.Container.getInventory(Container.java:69)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:55)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at cpw.mods.fml.common.network.NetworkRegistry.openRemoteGui(NetworkRegistry.java:321)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at cpw.mods.fml.common.network.FMLNetworkHandler.openGui(FMLNetworkHandler.java:352)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2480)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.gloriarpg.handler.PlayerTickHandler.playerTick(PlayerTickHandler.java:58)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.gloriarpg.handler.PlayerTickHandler.tickStart(PlayerTickHandler.java:26)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:28)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:122)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:383)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:282)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:325)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.network.NetServerHandler.handleFlying(NetServerHandler.java:304)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.network.packet.Packet10Flying.processPacket(Packet10Flying.java:51)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

2013-10-26 18:34:18 [iNFO] [sTDOUT]

2013-10-26 18:34:18 [iNFO] [sTDOUT]

2013-10-26 18:34:18 [iNFO] [sTDOUT] A detailed walkthrough of the error, its code path and all known details is as follows:

2013-10-26 18:34:18 [iNFO] [sTDOUT] ---------------------------------------------------------------------------------------

2013-10-26 18:34:18 [iNFO] [sTDOUT]

2013-10-26 18:34:18 [iNFO] [sTDOUT] -- Head --

2013-10-26 18:34:18 [iNFO] [sTDOUT] Stacktrace:

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.entity.player.InventoryPlayer.getStackInSlot(InventoryPlayer.java:658)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.inventory.Slot.getStack(Slot.java:91)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.inventory.Container.getInventory(Container.java:69)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:55)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at cpw.mods.fml.common.network.NetworkRegistry.openRemoteGui(NetworkRegistry.java:321)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at cpw.mods.fml.common.network.FMLNetworkHandler.openGui(FMLNetworkHandler.java:352)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2480)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.gloriarpg.handler.PlayerTickHandler.playerTick(PlayerTickHandler.java:58)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.gloriarpg.handler.PlayerTickHandler.tickStart(PlayerTickHandler.java:26)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:28)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:122)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:383)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:282)

2013-10-26 18:34:18 [iNFO] [sTDOUT]

2013-10-26 18:34:18 [iNFO] [sTDOUT] -- Player being ticked --

2013-10-26 18:34:18 [iNFO] [sTDOUT] Details:

2013-10-26 18:34:18 [iNFO] [sTDOUT] Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)

2013-10-26 18:34:18 [iNFO] [sTDOUT] Entity ID: 449

2013-10-26 18:34:18 [iNFO] [sTDOUT] Entity Name: Player981

2013-10-26 18:34:18 [iNFO] [sTDOUT] Entity's Exact location: -244.50, 64.00, 256.50

2013-10-26 18:34:18 [iNFO] [sTDOUT] Entity's Block location: World: (-245,64,256), Chunk: (at 11,4,0 in -16,16; contains blocks -256,0,256 to -241,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

2013-10-26 18:34:18 [iNFO] [sTDOUT] Entity's Momentum: 0.00, -0.08, 0.00

2013-10-26 18:34:18 [iNFO] [sTDOUT] Stacktrace:

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:325)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.network.NetServerHandler.handleFlying(NetServerHandler.java:304)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.network.packet.Packet10Flying.processPacket(Packet10Flying.java:51)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)

2013-10-26 18:34:18 [iNFO] [sTDOUT]

2013-10-26 18:34:18 [iNFO] [sTDOUT] -- Ticking connection --

2013-10-26 18:34:18 [iNFO] [sTDOUT] Details:

2013-10-26 18:34:18 [iNFO] [sTDOUT] Connection: net.minecraft.network.NetServerHandler@2f56c2b0

2013-10-26 18:34:18 [iNFO] [sTDOUT] Stacktrace:

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)

2013-10-26 18:34:18 [iNFO] [sTDOUT] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

 

 

ContainerAccessories:

 

 

package net.gloriarpg.container;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.world.World;

public class ContainerAccessories extends Container
{

private World worldObj;

public ContainerAccessories(InventoryPlayer playerInv, World world, int x, int y, int z)
{

	this.worldObj = world;

	this.addSlotToContainer(new Slot(playerInv, 37, 134, 12));
	this.addSlotToContainer(new Slot(playerInv, 38, 134, 30));
	this.addSlotToContainer(new Slot(playerInv, 39, 134, 48));

	this.addSlotToContainer(new Slot(playerInv, 40, 152, 12));
	this.addSlotToContainer(new Slot(playerInv, 41, 152, 30));
	this.addSlotToContainer(new Slot(playerInv, 42, 152, 48));

	int l;
	int i1;

	for (l = 0; l < 3; ++l)
	{
		for (i1 = 0; i1 < 9; ++i1)
		{
			this.addSlotToContainer(new Slot(playerInv, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18));
		}
	}

	for (l = 0; l < 9; ++l)
	{
		this.addSlotToContainer(new Slot(playerInv, l, 8 + l * 18, 142));
	}

}

@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{

	return true;

}

}

 

 

Kain

Link to comment
Share on other sites

The id's start at 0, so you'll use 0-35 (equals 36 slots) for the entire player inventory.

 

But that number is not the slot number, these will automatically assigned (in the order you call addSlotToContainer()).

You just need to pass it the index of the inventory itself, so probably 0-5.

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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