Secondly, I'm trying to only have one container and multiple gui classes. I would paste the code however, I can't right now (maybe later?). I can't seem to figure out what the problem is. Only one block works. However, when I try to use that same method (with modifications of course), it crashes with a class cast exception. Please help me.
---- Minecraft Crash Report ----
// Everything's going to plan. No, really, that was supposed to happen.
Time: 10/21/13 10:09 PM
Description: Ticking memory connection
java.lang.ClassCastException: Gui.ElectricEngineGuiMV cannot be cast to net.minecraft.inventory.Container
at cpw.mods.fml.common.network.NetworkRegistry.openRemoteGui(NetworkRegistry.java:308)
at cpw.mods.fml.common.network.FMLNetworkHandler.openGui(FMLNetworkHandler.java:352)
at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2480)
at Engines.TileEntitys.TileEntityElectricEngineMV.onBlockActivated(TileEntityElectricEngineMV.java:208)
at Engines.Blocks.BlockElectricEngine.onBlockActivated(BlockElectricEngine.java:177)
at net.minecraft.item.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:416)
at net.minecraft.network.NetServerHandler.handlePlace(NetServerHandler.java:554)
at net.minecraft.network.packet.Packet15Place.processPacket(Packet15Place.java:79)
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)
at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:689)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:585)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Stacktrace:
at cpw.mods.fml.common.network.NetworkRegistry.openRemoteGui(NetworkRegistry.java:308)
at cpw.mods.fml.common.network.FMLNetworkHandler.openGui(FMLNetworkHandler.java:352)
at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2480)
at Engines.TileEntitys.TileEntityElectricEngineMV.onBlockActivated(TileEntityElectricEngineMV.java:208)
at Engines.Blocks.BlockElectricEngine.onBlockActivated(BlockElectricEngine.java:177)
at net.minecraft.item.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:416)
at net.minecraft.network.NetServerHandler.handlePlace(NetServerHandler.java:554)
at net.minecraft.network.packet.Packet15Place.processPacket(Packet15Place.java:79)
at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)
at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)
-- Ticking connection --
Details:
Connection: net.minecraft.network.NetServerHandler@18be981e
Stacktrace:
at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)
at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:689)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:585)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
-- System Details --
Details:
Minecraft Version: 1.6.2
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_40, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 861532848 bytes (821 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 781 (43736 bytes; 0 MB) allocated, 260 (14560 bytes; 0 MB) used
Suspicious classes: FML and Forge are installed
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v8.04 FML v6.2.62.871 Minecraft Forge 9.10.1.871 11 mods loaded, 11 mods active
mcp{8.04} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{6.2.62.871} [Forge Mod Loader] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{9.10.1.871} [Minecraft Forge] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
BuildCraft|Core{@VERSION@} [BuildCraft] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
BuildCraft|Builders{@VERSION@} [BuildCraft Builders] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
BuildCraft|Energy{@VERSION@} [BuildCraft Energy] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
BuildCraft|Factory{@VERSION@} [BuildCraft Factory] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
BuildCraft|Transport{@VERSION@} [Buildcraft Transport] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
BuildCraft|Silicon{@VERSION@} [BuildCraft Silicon] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
TransformerConvertors{V1.6.2_0.0.2} [TransformerConvertors] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
IC2{2.0.223-experimental} [IndustrialCraft 2] (industrialcraft-2-dev-deobf_2.0.223-experimental.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Profiler Position: N/A (disabled)
Vec3 Pool Size: 62 (3472 bytes; 0 MB) allocated, 32 (1792 bytes; 0 MB) used
Player Count: 1 / 8; [EntityPlayerMP['Player564'/5, l='New World10', x=-1328.39, y=4.00, z=-730.86]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
As long as each inventory accessing the container is exactly the same size and each inventory is a subclass of the same type (or each one implements IInventory), then you should be able to use a single container provided your container's constructor uses the generic superclass / interface:
private IInventory inventory;
public ContainerGeneric(EntityPlayer player, InventoryPlayer invPlayer, IInventory inventory) {
this.inventory = inventory;
// add slots; all inventories must be able to use the same slots
}
This also presumes that you won't be accessing any unique methods particular to any of the inventories; generic methods only (i.e. methods inherited from IInventory) unless you check what type of IInventory you've got at the moment:
if (this.inventory instanceof MySpecialInventory) {
// cast as your special inventory to access the special methods
((MySpecialInventory) this.inventory).specialMethod();
}
Again, let me impress upon you the importance that ALL of the inventories using this generic container MUST be the exact same size. If you're awesome with Java/coding, you could probably work around that limitation, but it would start getting very messy at that point.
However, I think the issue is as I stated above. Post your Gui code. It should extend GuiContainer if you're using it with a companion container class, and if you didn't extend GuiContainer, that would explain the class cast exception in your error log.
However, I think the issue is as I stated above. Post your Gui code. It should extend GuiContainer if you're using it with a companion container class, and if you didn't extend GuiContainer, that would explain the class cast exception in your error log.
Secondly, I'm trying to only have one container and multiple gui classes. I would paste the code however, I can't right now (maybe later?). I can't seem to figure out what the problem is. Only one block works. However, when I try to use that same method (with modifications of course), it crashes with a class cast exception. Please help me.
This also presumes that you won't be accessing any unique methods particular to any of the inventories; generic methods only (i.e. methods inherited from IInventory) unless you check what type of IInventory you've got at the moment:
Again, let me impress upon you the importance that ALL of the inventories using this generic container MUST be the exact same size. If you're awesome with Java/coding, you could probably work around that limitation, but it would start getting very messy at that point.
EDIT: Ninja'd Guess I was wrong, but close!
Yeah, thanks for trying though!