• Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Solved Connexion serveur depuis second Thread

    Support pour les utilisateurs
    1.12.2
    2
    4
    38
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Orthil
      Orthil last edited by

      Bonjour,
      Je suis actuellement en train de développer un mod en 1.12.2, je rencontre un probleme au moment du code ou le jeu doit connecter le joueur à un serveur, cette action est effectuer depuis un Thread à par ce qui me donne une erreur. J’aimerais savoir s’il est quand meme possible de connecter le joueur depuis un second Thread ou si je suis obliger d’utiliser le Client Thread.
      Voici l’erreur et le morceau de code que j’utilise pour connecter le joueur :

      Exception in thread "Thread-8" [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: No OpenGL context found in the current thread.
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at org.lwjgl.opengl.GL11.glClear(GL11.java:585)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.client.renderer.GlStateManager.clear(GlStateManager.java:579)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.client.LoadingScreenRenderer.displayString(LoadingScreenRenderer.java:71)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.client.LoadingScreenRenderer.resetProgressAndMessage(LoadingScreenRenderer.java:46)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.client.Minecraft.loadWorld(Minecraft.java:2610)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.client.Minecraft.loadWorld(Minecraft.java:2563)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.client.multiplayer.GuiConnecting.<init>(GuiConnecting.java:38)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.modtest.client.gui.CMGuiLogin.initGui(CMGuiLogin.java:121)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.client.gui.GuiScreen.setWorldAndResolution(GuiScreen.java:543)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.client.Minecraft.displayGuiScreen(Minecraft.java:1098)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.modtest.client.gui.CMGuiQueue.initGui(CMGuiQueue.java:127)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.client.gui.GuiScreen.setWorldAndResolution(GuiScreen.java:543)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.client.Minecraft.displayGuiScreen(Minecraft.java:1098)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.modtest.client.waitingline.WaitingLine.run(WaitingLine.java:51)
      [19:56:55] [Thread-8/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at java.lang.Thread.run(Thread.java:748)
      

      Partie du code dans un Thread à par pour connecter le joueur :

      FMLClientHandler.instance().connectToServer(new CMGuiMainMenu(), CMGuiMainMenu.SERVER);
      

      Merci d’avance 🙂

      1 Reply Last reply Reply Quote 0
      • robin4002
        robin4002 Moddeurs confirmés Rédacteurs Administrateurs last edited by robin4002

        Bonsoir,
        il faut absolument être sur le main thread.
        Tu peux utiliser Minecraft.getInstance().addScheduledTask pour ajouter la tâche, minecraft l’exécutera ensuite depuis le main thread.

        1 Reply Last reply Reply Quote 0
        • robin4002
          robin4002 Moddeurs confirmés Rédacteurs Administrateurs last edited by robin4002

          Bonsoir,
          il faut absolument être sur le main thread.
          Tu peux utiliser Minecraft.getInstance().addScheduledTask pour ajouter la tâche, minecraft l’exécutera ensuite depuis le main thread.

          1 Reply Last reply Reply Quote 0
          • Orthil
            Orthil last edited by

            Merci beaucoup pour la reponse rapide ^^, cepandant je fait 2-3 test mais je me retrouve toujour avec la même erreur j’ai essayer ceci :

            Minecraft.getMinecraft().addScheduledTask((Runnable) new GuiConnecting(this, mc, CMGuiMainMenu.SERVER));
            
            1 Reply Last reply Reply Quote 0
            • Orthil
              Orthil last edited by

              Problème régler ! Merci beaucoup d’avoir repondu aussi vite 🙂

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Design by Woryk
              Contact / Mentions Légales

              MINECRAFT FORGE FRANCE © 2018

              Powered by NodeBB