Ajouter un gui et un container à un bloc
-
Il manque l’essentiel : le rapport de crash.
-
Voilà !!
[19:07:59] [Server thread/INFO]: themoney158 a rejoint la partie [19:08:15] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking memory connection at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:198) ~[NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.ArrayIndexOutOfBoundsException: 18 at mod.plantsandfoodpack.common.TileEntityKitchenCupboard.getStackInSlot(TileEntityKitchenCupboard.java:104) ~[TileEntityKitchenCupboard.class:?] at net.minecraft.inventory.Slot.getStack(Slot.java:88) ~[Slot.class:?] at net.minecraft.inventory.Container.getInventory(Container.java:67) ~[Container.class:?] at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53) ~[Container.class:?] at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) ~[EntityPlayer.class:?] at mod.plantsandfoodpack.common.BlockKitchenCupboard.onBlockActivated(BlockKitchenCupboard.java:92) ~[BlockKitchenCupboard.class:?] at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409) ~[ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) ~[C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) ~[C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) ~[NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) ~[NetworkSystem.class:?] … 5 more [19:08:16] [Server thread/ERROR]: This crash report has been saved to: C:\Users\nathan\Desktop\Mod Minecraft 1.7.2\eclipse\.\crash-reports\crash-2017-05-09_19.08.16-server.txt [19:08:16] [Server thread/INFO]: Stopping server [19:08:16] [Server thread/INFO]: Saving players [19:08:16] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ---- // I feel sad now :( Time: 09/05/17 19:08 Description: Ticking memory connection java.lang.ArrayIndexOutOfBoundsException: 18 at mod.plantsandfoodpack.common.TileEntityKitchenCupboard.getStackInSlot(TileEntityKitchenCupboard.java:104) at net.minecraft.inventory.Slot.getStack(Slot.java:88) at net.minecraft.inventory.Container.getInventory(Container.java:67) at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at mod.plantsandfoodpack.common.BlockKitchenCupboard.onBlockActivated(BlockKitchenCupboard.java:92) at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409) at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at mod.plantsandfoodpack.common.TileEntityKitchenCupboard.getStackInSlot(TileEntityKitchenCupboard.java:104) at net.minecraft.inventory.Slot.getStack(Slot.java:88) at net.minecraft.inventory.Container.getInventory(Container.java:67) at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at mod.plantsandfoodpack.common.BlockKitchenCupboard.onBlockActivated(BlockKitchenCupboard.java:92) at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409) at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@493d80f4 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_121, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 835496320 bytes (796 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 15, tcache: 0, allocated: 13, tallocated: 95 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA plantsandfoodpack{1.0.0} [Plants & Food Pack Mod] (bin) GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['themoney158'/337, l='TEST 1', x=5,83, y=68,00, z=309,36]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' [19:08:16] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2017-05-09_19.08.16-server.txt [19:08:16] [Client thread/INFO] [FML]: Waiting for the server to terminate/save. [19:08:16] [Server thread/INFO]: Saving worlds [19:08:16] [Server thread/INFO]: Saving chunks for level 'TEST 1'/Overworld [19:08:16] [Server thread/INFO]: Saving chunks for level 'TEST 1'/Nether [19:08:16] [Server thread/INFO]: Saving chunks for level 'TEST 1'/The End [19:08:16] [Server thread/INFO] [FML]: Unloading dimension 0 [19:08:16] [Server thread/INFO] [FML]: Unloading dimension -1 [19:08:16] [Server thread/INFO] [FML]: Unloading dimension 1 [19:08:16] [Server thread/INFO] [FML]: Applying holder lookups [19:08:16] [Server thread/INFO] [FML]: Holder lookups applied [19:08:16] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded. [19:08:16] [Client thread/INFO] [FML]: Server terminated. AL lib: (EE) alc_cleanup: 1 device not closed Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
Merci D’avance !
-
Ton inventaire à 18 slots :
private ItemStack[] contents = new ItemStack[18];
Or dans ton container tu mets 9x3 slots (27)for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(tile, j + i * 9, 8 + j * 18, 18 + i * 18)); } }
Donc forcement ça fait un ArrayIndexOutOfBoundsException
-
MERCI BEAUCOUP
ça marche enfin merci!
-
Mon block ne s’ouvre pas
Mon onBlockActivated :
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitx, float hity, float hitz) { if (world.isRemote) { return true; } else { player.openGui(CompleatCraft.instance, 0, world, x, y, z); return true; }
-
Salut,
Il faudrait le code de CompleatCraft et du gui handler. -
Oui désoler je n’avais plus de co
CompleatCraft :
package Package1.common; import Package1.common.FourTotal.BlockFour; import Package1.common.FourTotal.GuiBlockFour; import Package1.common.FourTotal.TileEntityFour; import Package1.common.Proxy.CommonProxy; 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.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @Mod(modid = "compleatcraft", name = "Compleat Craft", version = "1.0.0" ) public class CompleatCraft { @Instance("compleatcraft") public static CompleatCraft instance; @SidedProxy(clientSide = "Package1.common.Proxy.ClientProxy", serverSide = "Package1.common.Proxy.CommonProxy") public static CommonProxy proxy; public static final String MODID = "compleatcraft"; public static Block BlockFourConstuct; @EventHandler public void preInit(FMLPreInitializationEvent event) { ItemsMod.init(); ItemsMod.register(); BlocksMod.init(); BlocksMod.register(); proxy.registerTileEntities(); BlockFourConstuct = new BlocksMod(Material.rock).setBlockName("BlockFour"); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); GameRegistry.registerTileEntity(TileEntityFour.class, "compleatcraft:TileEntityFour"); GameRegistry.registerBlock(BlockFourConstuct, "Block_Four"); GameRegistry.registerTileEntity(TileEntityFour.class, MODID + ":FourTileEntity"); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
Le guihandler :
package Package1.common; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import Package1.common.FourTotal.ContainerBlockFour; import Package1.common.FourTotal.GuiBlockFour; import Package1.common.FourTotal.TileEntityFour; import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityFour) { return new ContainerBlockFour((TileEntityFour)tile, player.inventory); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityFour) { return new GuiBlockFour((TileEntityFour)tile, player.inventory); } return null; } }
-
Je ne vois pas d’erreur ici.
Dans la classe de ton bloc tu as bien tout le code qu’il faut pour le tile entity ? -
Mon bloc :
package Package1.common.FourTotal; import Package1.common.CompleatCraft; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BlockFour extends BlockContainer { public BlockFour(Material material) { super(Material.rock); this.setResistance(8.0F); this.setHarvestLevel("pickaxe", 2); this.setBlockTextureName(CompleatCraft.MODID + ":BlockFour"); } @Override public TileEntity createNewTileEntity(World world, int metadata) { return new TileEntityFour(); } @Override public boolean hasTileEntity(int metadata) { return true; } public void breakBlock(World world, int x, int y, int z, Block block, int metadata) { TileEntity tileentity = world.getTileEntity(x, y, z); if (tileentity instanceof IInventory) { IInventory inv = (IInventory)tileentity; for (int i1 = 0; i1 < inv.getSizeInventory(); ++i1) { ItemStack itemstack = inv.getStackInSlot(i1); if (itemstack != null) { float f = world.rand.nextFloat() * 0.8F + 0.1F; float f1 = world.rand.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) { int j1 = world.rand.nextInt(21) + 10; if (j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3); entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3); if (itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); } } } } world.func_147453_f(x, y, z, block); } super.breakBlock(world, x, y, z, block, metadata); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitx, float hity, float hitz) { if (world.isRemote) { return true; } else { player.openGui(CompleatCraft.instance, 0, world, x, y, z); return true; } } }
-
Ajoutes System.out.println(“test”); au dessus de player.openGui(CompleatCraft.instance, 0, world, x, y, z); dans le bloc, puis System.out.println(“test 2”); au dessus de return new GuiBlockFour((TileEntityFour)tile, player.inventory); dans le GuiHandler.
Vas en jeu, fais un clic sur ton bloc et regardes ce que tu as dans la console. -
Il ne se passe rien dans la console.
-
Ajoutes @Override au dessus de la fonction onBlockActivated ?
-
Toujours rien ^^
-
Pas d’erreur lorsque tu ajoutes le override ?
-
Non
-
Je ne vois pas comment c’est possible o_O
-
Bizarrre, montres la classe de ton block avec le system.out et le @Override, voir si ils sont bien placés.
-
-
Et le “test” apparaît vraiment aucune fois dans la console quand tu cliques droit sur ton bloc ?
-
Non, il n’y a rien