GUI qui ne s'ouvre pas en multijoueur



  • Bonjour, j'ai créé un simple GUI. Il s'affiche parfaitement en solo, mais pas en multijoueur. Je pense pourtant avoir fait correctement la démarche adéquate.

    La classe de mon item qui ouvre le GUI :

    public class Livre1 extends Item
    {
    @Override
    public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) 
    {
    if(world.isRemote)
    {
    ModPhenix.proxy.openMyGui();
    }
       return super.onItemRightClick(stack, world, player);
    }
    
    }
    

    Mon GUI :

    public class GuiLivre1 extends GuiScreen
    {
    int guiWidth= 256;
    int guiHeight= 256;
    
    @Override                                                               
    public void drawScreen(int x, int y, float ticks )
    {
    int guix =(width - guiWidth) /2 ;
    int guiy =(height - guiHeight) /2;
    
    mc.renderEngine.bindTexture(new ResourceLocation(ModPhenix.MODID,"textures/gui/guiLivre.png"));
    
    drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight);
    
    fontRendererObj.drawString("\u00a70" + "\u00a7o" + "Lever le voile du futur", guix + 17, guiy + 55, 0x404040 );
    
    super.drawScreen(x, y, ticks);
    }
    
    @Override
    public boolean doesGuiPauseGame()
    {
    return false;
    }
    }
    

    ClientProxy :

    public class ClientProxy extends CommonProxy 
    {
    public static int tesrRenderId;
    
    @Override
    public void registerRender()
    {
    MinecraftForge.EVENT_BUS.register(new TickClientHandler());
    }
    
    @Override
    public void openMyGui()
    {
        Minecraft.getMinecraft().displayGuiScreen(new GuiLivre1());
    }
    }
    

    CommonProxy :

    public class CommonProxy 
    {
    public void registerRender()
    {
    
    }
    
    public void openMyGui()
    {
    
    }
    }
    

    Je fais appel à vous car je vous avouerai que je sèche un peu là.. En multijoueur il n'y a ni crash, ni message, ni erreur, ni quoi que ce soit. Rien ne se passe.

    Merci pour votre aide 😉



  • Ton code est étrange, normalement si tu as un Gui sur un Item, dans 99% des cas tu auras besoin d'un lien avec le serveur, or ici tu ne l'ouvres que du côté client



  • "If(world. isRemote)" tu ouvres ton qui côté client, mets un ! devant la condition

    Edit : autant pour moi, j'ai mis mon message sans voir que c'était pas un container.

    Envoyé de mon RAINBOW LITE 4G en utilisant Tapatalk



  • Nan justement, c'est bon car c'est un Gui, c'est juste très étrange d'utiliser cette manière



  • Retire la condition if(world.isRemote) dans ton onitemRightClick et dis moi ce qui se passe ?



  • @'Plaigon':

    Retire la condition if(world.isRemote) dans ton onitemRightClick et dis moi ce qui se passe ?

    Pareil, il ne se passe rien



  • ça c'est pas normal, tu devrais avoir un crash car tu appelles des fonctions du client côté serveur


  • Administrateurs

    Non, il passe par le proxy. Côté serveur il ne se passe rien et c'est normal.
    Par contre côté client le gui devrait s'ouvrir.
    Ajoutes un print dans ta fonction openMyGui du client proxy.



  • @'robin4002':

    Non, il passe par le proxy. Côté serveur il ne se passe rien et c'est normal.
    Par contre côté client le gui devrait s'ouvrir.
    Ajoutes un print dans ta fonction openMyGui du client proxy.

    En effet la fonction n'est pas appelée


  • Administrateurs

    Envoies la ligne en rapport avec les proxy dans ta classe principale.



  • @'robin4002':

    Envoies la ligne en rapport avec les proxy dans ta classe principale.

    Voilà :

    @SidedProxy(clientSide = "laserflip33.ordreduphenix.proxy.ClientProxy", serverSide = "laserflip33.ordreduphenix.proxy.CommonProxy")
    
    public static CommonProxy proxy;
    

  • Administrateurs

    étrange que ça ne fonctionne pas.
    Sinon mets :
    if(FMLCommonHandler.instance().getSide().isClient())
    {
    Minecraft.getMinecraft().displayGuiScreen(new GuiLivre1());
    }

    directement dans onItemRightClick



  • Si je fais ça, ça crash :

    –-- Minecraft Crash Report ----
    // I feel sad now :(
    
    Time: 25/04/16 12:09
    Description: Exception in server tick loop
    
    cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen
    at cpw.mods.fml.common.LoadController.transition(LoadController.java:162)
    at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:514)
    at cpw.mods.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:88)
    at cpw.mods.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:319)
    at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:167)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:599)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen
    at laserflip33.ordreduphenix.common.ModPhenix.preInit(ModPhenix.java:851)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
    at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
    at com.google.common.eventbus.EventBus.post(EventBus.java:267)
    at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
    at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
    at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
    at com.google.common.eventbus.EventBus.post(EventBus.java:267)
    at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
    at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:512)
    ... 5 more
    Caused by: java.lang.ClassNotFoundException: net.minecraft.client.gui.GuiScreen
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 32 more
    Caused by: java.lang.RuntimeException: Attempted to load class bcd for invalid side SERVER
    at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:51)
    at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:276)
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:174)
    ... 34 more
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- System Details --
    Details:
    Minecraft Version: 1.7.2
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.7.0_79, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 173032048 bytes (165 MB) / 501088256 bytes (477 MB) up to 1037959168 bytes (989 MB)
    JVM Flags: 6 total; -Xms512M -Xmx1024M -XX:PermSize=256m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseStringCache
    AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP v9.03 FML v7.2.217.1147 Minecraft Forge 10.12.2.1147 13 mods loaded, 13 mods active
    mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
    FML{7.2.217.1147} [Forge Mod Loader] (minecraft_server.jar) Unloaded->Constructed->Pre-initialized
    Forge{10.12.2.1147} [Minecraft Forge] (minecraft_server.jar) Unloaded->Constructed->Pre-initialized
    CustomSpawner{3.2.0.dev.R3} [DrZhark's CustomSpawner] (CustomMobSpawner 3.2.0-DEV-R3.zip) Unloaded->Constructed->Pre-initialized
    customnpcs{1.7.2-2} [CustomNpcs] (CustomNPCs_1.7.2.jar) Unloaded->Constructed->Pre-initialized
    MoCreatures{6.2.0.dev.R3} [DrZhark's Mo'Creatures Mod] (DrZharks MoCreatures Mod v6.2.0-DEV-R3.zip) Unloaded->Constructed->Pre-initialized
    ftfloocraft{1.7.10-0.3.1} [Floocraft] (Floocraft-1.7.10-0.3.1.jar) Unloaded->Constructed->Pre-initialized
    MineChess{1.3.7} [MineChess] (MineChess-Mod-1.7.2.zip) Unloaded->Constructed->Pre-initialized
    halloween{1.0.0} [Halloween] (ModHalloween.jar) Unloaded->Constructed->Pre-initialized
    ordreduphenix{1.0.0} [Ordre du Phenix] (ordreduphenix-1.0.jar) Unloaded->Constructed->Errored
    pottermod{0.2} [PotterMod] (Pottermod-0.2.jar) Unloaded->Constructed->Pre-initialized
    quidcraft{0.1} [Quidcraft] (Quidcraft-0.1(1.7.2).jar) Unloaded->Constructed->Pre-initialized
    witchery{0.20.4} [Witchery] (witchery-1.7.2-0.20.4.jar) Unloaded->Constructed->Pre-initialized
    Profiler Position: N/A (disabled)
    Is Modded: Definitely; Server brand changed to 'cauldron,craftbukkit,mcpc,fml,forge'
    Type: Dedicated Server (map_server.txt)
    


  • Tu as mis ça dans ta classe principale ?
    Il faut mettre ça où tu ouvres ton gui (dans on block activated), et si ça marche toujours pas, remplace getSide() par getEffectiveSide()

    Envoyé de mon RAINBOW LITE 4G en utilisant Tapatalk



  • @'AymericRed':

    Tu as mis ça dans ta classe principale ?
    Il faut mettre ça où tu ouvres ton gui (dans on block activated), et si ça marche toujours pas, remplace getSide() par getEffectiveSide()

    Envoyé de mon RAINBOW LITE 4G en utilisant Tapatalk

    Non j'ai pas mis ça dans la classe principale j'ai mis ça dans la fonction onItemRightClick. J'ai remplacé getSide() par getEffectiveSide(), ça ne change rien.

    –-- Minecraft Crash Report ----
    // Ouch. That hurt :(
    
    Time: 25/04/16 12:38
    Description: Exception in server tick loop
    
    cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen
    at cpw.mods.fml.common.LoadController.transition(LoadController.java:162)
    at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:514)
    at cpw.mods.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:88)
    at cpw.mods.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:319)
    at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:167)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:599)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen
    at laserflip33.ordreduphenix.common.ModPhenix.preInit(ModPhenix.java:851)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
    at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
    at com.google.common.eventbus.EventBus.post(EventBus.java:267)
    at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
    at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
    at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
    at com.google.common.eventbus.EventBus.post(EventBus.java:267)
    at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
    at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:512)
    ... 5 more
    Caused by: java.lang.ClassNotFoundException: net.minecraft.client.gui.GuiScreen
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 32 more
    Caused by: java.lang.RuntimeException: Attempted to load class bcd for invalid side SERVER
    at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:51)
    at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:276)
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:174)
    ... 34 more
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- System Details --
    Details:
    Minecraft Version: 1.7.2
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.7.0_79, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 175926568 bytes (167 MB) / 501088256 bytes (477 MB) up to 1037959168 bytes (989 MB)
    JVM Flags: 6 total; -Xms512M -Xmx1024M -XX:PermSize=256m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseStringCache
    AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP v9.03 FML v7.2.217.1147 Minecraft Forge 10.12.2.1147 13 mods loaded, 13 mods active
    mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
    FML{7.2.217.1147} [Forge Mod Loader] (minecraft_server.jar) Unloaded->Constructed->Pre-initialized
    Forge{10.12.2.1147} [Minecraft Forge] (minecraft_server.jar) Unloaded->Constructed->Pre-initialized
    CustomSpawner{3.2.0.dev.R3} [DrZhark's CustomSpawner] (CustomMobSpawner 3.2.0-DEV-R3.zip) Unloaded->Constructed->Pre-initialized
    customnpcs{1.7.2-2} [CustomNpcs] (CustomNPCs_1.7.2.jar) Unloaded->Constructed->Pre-initialized
    MoCreatures{6.2.0.dev.R3} [DrZhark's Mo'Creatures Mod] (DrZharks MoCreatures Mod v6.2.0-DEV-R3.zip) Unloaded->Constructed->Pre-initialized
    ftfloocraft{1.7.10-0.3.1} [Floocraft] (Floocraft-1.7.10-0.3.1.jar) Unloaded->Constructed->Pre-initialized
    MineChess{1.3.7} [MineChess] (MineChess-Mod-1.7.2.zip) Unloaded->Constructed->Pre-initialized
    halloween{1.0.0} [Halloween] (ModHalloween.jar) Unloaded->Constructed->Pre-initialized
    ordreduphenix{1.0.0} [Ordre du Phenix] (ordreduphenix-1.0.jar) Unloaded->Constructed->Errored
    pottermod{0.2} [PotterMod] (Pottermod-0.2.jar) Unloaded->Constructed->Pre-initialized
    quidcraft{0.1} [Quidcraft] (Quidcraft-0.1(1.7.2).jar) Unloaded->Constructed->Pre-initialized
    witchery{0.20.4} [Witchery] (witchery-1.7.2-0.20.4.jar) Unloaded->Constructed->Pre-initialized
    Profiler Position: N/A (disabled)
    Is Modded: Definitely; Server brand changed to 'cauldron,craftbukkit,mcpc,fml,forge'
    Type: Dedicated Server (map_server.txt)
    


  • Et si tu mets un SideOnly(Side.CLIENT) au dessus de ta classe du gui ?



  • Pareil ça crash


  • Administrateurs

    Fais comme ça :

    @Override
    public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
    {
    if(FMLCommonHandler.instance().getSide().isClient())
    {
    this.openGui();
    }
    return super.onItemRightClick(stack, world, player);
    }
    
    @SideOnly(Side.CLIENT)
    public void openGui()
    {
    Minecraft.getMinecraft().displayGuiScreen(new GuiLivre1());
    }
    


  • Là ça ne crash plus mais le GUI ne s'ouvre pas non plus


  • Administrateurs

    Ajoutes un System.out.println("quelque chose"); pour voir si la fonction est appelé.