Code 1.8 qui fait crash en 1.10
-
Salut,
Je ne vois aucune référence à ton container dans le crash.En revanche dans le stack trace il y a le gui handler :
at com.CSC.net.GUI.GuiHandler.getClientGuiElement(GuiHandler.java:76) ~[GuiHandler.class:?]Tu peux nous passer cette classe ?
-
@‘robin4002’:
Salut,
Je ne vois aucune référence à ton container dans le crash.En revanche dans le stack trace il y a le gui handler :
at com.CSC.net.GUI.GuiHandler.getClientGuiElement(GuiHandler.java:76) ~[GuiHandler.class:?]Tu peux nous passer cette classe ?
Tien:
package com.CSC.net.GUI; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; import com.CSC.net.block.TileEntityCuve; import com.CSC.net.block.TileEntityMachineLaver; import com.CSC.net.block.TileEntitySecheLinge; public class GuiHandler implements IGuiHandler { public static EntityPlayer currentTarget; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { return new ContainerLinge(player.inventory, new InventoryLinge(player.getHeldItemOffhand(), 54)); } if(ID == 1) { return new ContainerPlayerCustom(currentTarget.inventory, world.isRemote, currentTarget); } if(ID == 2) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntitySecheLinge) { return new ContainerSecheLinge((TileEntitySecheLinge)tile, player.inventory); } } if(ID == 3) { return new ContainerColi(player.inventory, new InventoryColi(player.getHeldItemOffhand(), 54)); } if(ID == 4) { TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); if(te instanceof TileEntityCuve) { return new ContainerCuve(player.inventory, (TileEntityCuve)te); } return null; } if(ID == 5) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntityMachineLaver) { return new ContainerMachineLaver((TileEntityMachineLaver)tile, player.inventory); } } if(ID == 6) { return null; } if(ID == 7) { return null; } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { return new GuiLinge(player.inventory, new InventoryLinge(player.getHeldItemOffhand(), 54)); } if(ID == 1) { return new GuiInv(currentTarget); } if(ID == 2) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntitySecheLinge) { return new GuiSecheLinge((TileEntitySecheLinge)tile, player.inventory); } } if(ID == 3) { return new GuiColi(player.inventory, new InventoryColi(player.getHeldItemOffhand(), 54)); } if(ID == 4) { TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); if(te instanceof TileEntityCuve) { return new GuiCuve(player.inventory, (TileEntityCuve)te); } return null; } if(ID == 5) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntityMachineLaver) { return new GuiMachineLaver((TileEntityMachineLaver)tile, player.inventory); } } if(ID == 6) { return new Prison(); } if(ID == 7) { return new QuestionGui1(); } return null; } }Du coup les problèmes viennent de cette classe ?
-
player.getHeldItemOffhand est surement null.
Mets la valeur de x sur 0 si le joueur à l’item dans la main droite, sur 1 si c’est la main gauche dans l’item.
Et ensuite faire une condition en fonction de la valeur de x dans le gui handler. -
@‘robin4002’:
player.getHeldItemOffhand est surement null.
Mets la valeur de x sur 0 si le joueur à l’item dans la main droite, sur 1 si c’est la main gauche dans l’item.
Et ensuite faire une condition en fonction de la valeur de x dans le gui handler.J’ai fais ça:
J’ai pas compris pour la condition en fonction de la valeur de x.
package com.CSC.net.GUI; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHandSide; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; import com.CSC.net.block.TileEntityCuve; import com.CSC.net.block.TileEntityMachineLaver; import com.CSC.net.block.TileEntitySecheLinge; public class GuiHandler implements IGuiHandler { public static EntityPlayer currentTarget; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { return new ContainerLinge(player.inventory, new InventoryLinge(player.getHeldItemOffhand(), 54)); } if(ID == 1) { return new ContainerPlayerCustom(currentTarget.inventory, world.isRemote, currentTarget); } if(ID == 2) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntitySecheLinge) { return new ContainerSecheLinge((TileEntitySecheLinge)tile, player.inventory); } } if(ID == 3) { return new ContainerColi(player.inventory, new InventoryColi(player.getHeldItemOffhand(), 54)); } if(ID == 4) { TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); if(te instanceof TileEntityCuve) { return new ContainerCuve(player.inventory, (TileEntityCuve)te); } return null; } if(ID == 5) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntityMachineLaver) { return new ContainerMachineLaver((TileEntityMachineLaver)tile, player.inventory); } } if(ID == 6) { return null; } if(ID == 7) { return null; } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { EnumHandSide side = player.getPrimaryHand(); EnumHand hand = getHandForSide(side, player); if(hand == EnumHand.MAIN_HAND) { x = 0; System.out.println(x); } else { x = 1; System.out.println(x); } if(ID == 0) { return new GuiLinge(player.inventory, new InventoryLinge(player.getHeldItemOffhand(), 54)); } if(ID == 1) { return new GuiInv(currentTarget); } if(ID == 2) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntitySecheLinge) { return new GuiSecheLinge((TileEntitySecheLinge)tile, player.inventory); } } if(ID == 3) { return new GuiColi(player.inventory, new InventoryColi(player.getHeldItemOffhand(), 54)); } if(ID == 4) { TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); if(te instanceof TileEntityCuve) { return new GuiCuve(player.inventory, (TileEntityCuve)te); } return null; } if(ID == 5) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); if(tile instanceof TileEntityMachineLaver) { return new GuiMachineLaver((TileEntityMachineLaver)tile, player.inventory); } } if(ID == 6) { return new Prison(); } if(ID == 7) { return new QuestionGui1(); } return null; } public static EnumHand getHandForSide(EnumHandSide side, EntityLivingBase entity) { return side == entity.getPrimaryHand() ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND; } } -
Reviens en arrière, tu as en effet pas du tout compris.
Dans ton item tu as surement une fonction comme celle-ci :
public ActionResult <itemstack>onItemRightClick(World world, EntityPlayer player, EnumHand hand) { player.openGui(ClassePrincipale.instance, 0, world, 0, 0, 0); // instance, id, world, x, y, z return new ActionResult(EnumActionResult.PASS, player.getHeldItem(hand)); }Remplaces par :
public ActionResult <itemstack>onItemRightClick(World world, EntityPlayer player, EnumHand hand) { if(hand == EnumHand.MAIN_HAND) // main principale { player.openGui(ClassePrincipale.instance, 0, world, 0, 0, 0); // instance, id, world, x, y, z } else // seconde main { player.openGui(ClassePrincipale.instance, 0, world, 1, 0, 0); // instance, id, world, x, y, z } return new ActionResult(EnumActionResult.PASS, player.getHeldItem(hand)); }ou en plus compact :
public ActionResult <itemstack>onItemRightClick(World world, EntityPlayer player, EnumHand hand) { player.openGui(ClassePrincipale.instance, 0, world, hand == EnumHand.MAIN_HAND ? 0 : 1, 0, 0); // instance, id, world, x, y, z return new ActionResult(EnumActionResult.PASS, player.getHeldItem(hand)); }Et ensuite dans ton gui handler :
@Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0) { if(x == 0) { return new GuiLinge(player.inventory, new InventoryLinge(player.getHeldItemMainhand(), 54)); // 0 donc main principale } else { return new GuiLinge(player.inventory, new InventoryLinge(player.getHeldItemOffhand(), 54)); // 1 donc seconde main } } …. ```</itemstack></itemstack></itemstack> -
Ah ouais j’avais pas du tout compris ça ^^ je savais pas du tout pour getHeldItemMainHand et OffHand j’avais pas fais gaffe.
Pour se qui est du TileEntity tu sais d’ou ça vient ou non?
J’ai oublier de te passer le crash report…
Je te le passe tien:
java.lang.ClassCastException: net.minecraft.entity.player.EntityPlayerMP cannot be cast to net.minecraft.inventory.InventoryCrafting at com.CSC.net.GUI.ContainerSecheLinge.detectAndSendChanges(ContainerSecheLinge.java:132) at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:292) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2099) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872) at net.minecraft.world.World.updateEntity(World.java:2066) at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:673) at net.minecraft.world.World.updateEntities(World.java:1862) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) at java.lang.Thread.run(Thread.java:745) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at com.CSC.net.GUI.ContainerSecheLinge.detectAndSendChanges(ContainerSecheLinge.java:132) at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:292) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2099) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872) at net.minecraft.world.World.updateEntity(World.java:2066) -- Player being ticked -- Details: Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) Entity ID: 353 Entity Name: Darkmayke Entity's Exact location: -44,47, 72,00, 280,77 Entity's Block location: World: (-45,72,280), Chunk: (at 3,4,8 in -3,17; contains blocks -48,0,272 to -33,255,287), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Entity's Momentum: 0,00, -0,08, 0,00 Entity's Passengers: [] Entity's Vehicle: ~~ERROR~~ NullPointerException: null Stacktrace: at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:673) at net.minecraft.world.World.updateEntities(World.java:1862) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644) -- Affected level -- Details: Level name: New World All players: 1 total; [EntityPlayerMP['Darkmayke'/353, l='New World', x=-44,47, y=72,00, z=280,77]] Chunk stats: ServerChunkCache: 350 Drop: 0 Level seed: -8076992039048543240 Level generator: ID 00 - default, ver 1\. Features enabled: true Level generator options: Level spawn location: World: (-40,64,256), Chunk: (at 8,4,0 in -3,16; contains blocks -48,0,256 to -33,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 145365 game time, 39921 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 15845 (now: true), thunder time: 71400 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) at java.lang.Thread.run(Thread.java:745) – System Details -- Details: Minecraft Version: 1.10 Operating System: Windows 7 (x86) version 6.1 Java Version: 1.8.0_45, Oracle Corporation Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation Memory: 504680536 bytes (481 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP 9.32 Powered by Forge 12.18.0.2000 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.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10-12.18.0.2000-1.10.0.jar) UCHIJAAAA Forge{12.18.0.2000} [Minecraft Forge] (forgeSrc-1.10-12.18.0.2000-1.10.0.jar) UCHIJAAAA csc{1.0} [Cite Sous Controle] (bin) Loaded coremods (and transformers): GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Player Count: 1 / 8; [EntityPlayerMP['Darkmayke'/353, l='New World', x=-44,47, y=72,00, z=280,77]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' [22:29:25] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2016-12-10_22.29.25-server.txt [22:29:25] [Client thread/INFO] [FML]: Waiting for the server to terminate/save. [22:29:25] [Server thread/INFO]: Saving chunks for level 'New World'/Nether [22:29:25] [Server thread/INFO]: Saving chunks for level 'New World'/The End [22:29:26] [Server thread/INFO] [FML]: Unloading dimension 0 [22:29:26] [Server thread/INFO] [FML]: Unloading dimension -1 [22:29:26] [Server thread/INFO] [FML]: Unloading dimension 1 [22:29:26] [Server thread/INFO] [FML]: Applying holder lookups [22:29:26] [Server thread/INFO] [FML]: Holder lookups applied [22:29:26] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded. [22:29:26] [Client thread/INFO] [FML]: Server terminated. [22:29:26] [Client Shutdown Thread/INFO]: Stopping server [22:29:26] [Client Shutdown Thread/INFO]: Saving players AL lib: (EE) alc_cleanup: 1 device not closed Java HotSpot(TM) Client VM warning: Using incremental CMS is deprecated and will likely be removed in a future release -
this.listeners.get(i) est un entity player, or toi tu essaie de le cast à InventoryCrafting.
Donc le type de this.listeners.get(i) à surement changé. Regardes le code de la table de craft.
-
@‘robin4002’:
this.listeners.get(i) est un entity player, or toi tu essaie de le cast à InventoryCrafting.
Donc le type de this.listeners.get(i) à surement changé. Regardes le code de la table de craft.
J’ai trouvé super merci, par contre c’était dans la classe de la furnace en soit j’avais compris x) merci !
Un dernier truc:
J’ai trois block container donc mon mod et deux sont buggé, je sais d’ou ça vient car pour les trois c’est le même type de json et en 1.8 ça marchais nickel.
Je te passe un screen pour que tu comprennes le problème, (les blocks sont invisible).

-
Rajoute ceci dans la classe de ton bloc :
@Override public int getRenderType() { return 3; } -
@‘BrokenSwing’:
Rajoute ceci dans la classe de ton bloc :
@Override public int getRenderType() { return 3; }En 1.10 ça exite plus getRenderType.
J’ai trouvé ça du coup:
@Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; }ça marche nickel merci

-
Ah oui désolé je suis pas aller regarder, mais c’est bien t’as trouvé tout seul
