Jump to content

Recommended Posts

Posted

Is there a cap on how many slots a container can hold? The code should be adding about 62 slots, but the slots list has a size of 45 when it's done adding the slots.

 

The weird part is that all of the slots are rendered, but if I try to click on one of the slots that are added after the first 45 are added, I crash with an NPE stating that the index is out of bounds.

 

Container Class:

package ttm.inventory;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import ttm.util.LogUtil;

public class ContainerInventory extends Container {
public IInventory inventory;

public ContainerInventory() {
	super();
	inventory = new InventoryT();
	int currentSlot = 0;
	for(int i = 0; i < 9; i++) {
		this.addSlotToContainer(new Slot(inventory, currentSlot, 10 + (18 * i), 14));
		currentSlot++;
	}
	for(int i = 0; i < 9; i++) {
		for(int l = 0; l < 6; l++) {
			this.addSlotToContainer(new Slot(inventory, currentSlot, 10 + (18 * i), 52 + (18 * l)));
			currentSlot++;
		}
	}
}

@Override
public boolean canInteractWith(EntityPlayer var1) {
	return true;
}
}

Kain

Posted

Yeah, the index is out of bounds so the list returns a null. :P

 

(I think)

 

 

Here's the crash log if you need it:

---- Minecraft Crash Report ----
// Sorry 

Time: 6/15/14 11:51 PM
Description: Ticking memory connection

java.lang.IndexOutOfBoundsException: Index: 49, Size: 45
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at net.minecraft.inventory.Container.slotClick(Container.java:474)
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:721)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608)
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:747)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at net.minecraft.inventory.Container.slotClick(Container.java:474)
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@6838d45
Stacktrace:
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:721)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608)
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:747)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 783455912 bytes (747 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 7103 (397768 bytes; 0 MB) allocated, 3693 (206808 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.03 FML v7.2.211.1124 Minecraft Forge 10.12.2.1124 4 mods loaded, 4 mods active
mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.2.211.1124} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.2.1124.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.2.1124} [Minecraft Forge] (forgeSrc-1.7.2-10.12.2.1124.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
ttm{Indev} [Terraria to Minecraft] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Profiler Position: N/A (disabled)
Vec3 Pool Size: 5800 (324800 bytes; 0 MB) allocated, 5681 (318136 bytes; 0 MB) used
Player Count: 1 / 8; [EntityPlayerMP['Player543'/170, l='New World', x=32.50, y=75.00, z=259.50]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'

Kain

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



×
×
  • Create New...

Important Information

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