• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu [1.12.2] IOException sur touche personnalisée en multi mais pas en solo

    1.12.x
    1.12.2
    3
    4
    210
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • S
      Sirvechs dernière édition par robin4002

      Bonjour,
      Je vous explique mon problème : je suis néophyte sur forge, je suis encore ne train d’apprendre, et j’ai suivi les différents tutos pour pouvoir bidouiller.

      J’ai créé des touches personnalisées en suivant ce tuto : https://www.minecraftforgefrance.fr/topic/521/ajouter-des-touches-personalisées

      J’ai ajouté 12 touches qui ont la même nomenclature pour l’instant :

      public class ClientProxy extends CommonProxy{
      
       private static KeyBinding rat;
      
      public ClientProxy()
      	{
       FMLCommonHandler.instance().bus().register(this);
       rat = new KeyBinding("Mudra.Rat", Keyboard.KEY_U, "key.categories.misc");
       ClientRegistry.registerKeyBinding(rat);
              }
      
       public void onEvent(KeyInputEvent event)
      	 {
      		
      		 if(rat.isPressed()) {
      			 timer();
      			 ratPressed();
      		 }
       }
      
       private void timer() {
      		 if(!timer.enCours || timer == null){ //NullPointerException ici en multijoueur mais pas en solo
      			 liste.clear();
      		 }
      		 if(liste.isEmpty()) {
      			 timer = new Chrono(100, true);
      		 }
       }
      }
      
      public class CommonProxy {
      	
      	protected static List<String> liste;
      	
      	protected Chrono timer;
      	
      	@SubscribeEvent @EventHandler
      	public void onQuit(PlayerLoggedOutEvent event) {
      		liste = null;
      		timer = null;
      	}
      	
      	@SubscribeEvent @EventHandler
      	public void onJoin(PlayerLoggedInEvent event) {
      		liste = new ArrayList<String>();
      		timer = new Chrono(0, false);
      	}
      	
          public void preInit(File configFile)
          {
              System.out.println("pre init côté commun");
          }
      
          public void init()
          { 
          }
      
      public class Chrono {
      
      	private int time; // en tick minecraft 20 ticks = 1 seconde
      	public boolean enCours = false;
      	
      	public Chrono(int temps, boolean lancer) {
      		
      		this.time = temps;
      		if(lancer)
      			this.lancer();
      	}
      	
      	public void lancer() {
      		FMLCommonHandler.instance().bus().register(this);
      		enCours = true;
      		
      	}
      	
      	@SubscribeEvent @EventHandler
      	public boolean onEvent(ServerTickEvent event) {
      		if(enCours) {
      			time--;
      			convert();
      		}
      		if(time == 0)
      			enCours = false;
      		
      		return enCours;
      	}
      	
      	private void convert() {
      		String seconde = String.valueOf(time / 20);
      		if(time % 20 == 0) {
      			seconde = String.valueOf(time / 20);
      			Minecraft.getMinecraft().player.sendChatMessage("/commandPerso " + seconde); //note ma commande perso fonctionne
      		}
      	}
      	
      }
      

      Et quand je suis en solo tout fonctionne bien, mais que je suis en multi, quand j’appuie sur la touche le client crash, j’imagine parce que l’input n’est pas géré par le serveur, j’ai donc essayé de suivre ce tuto qui à moins de 3 mois : https://www.minecraftforgefrance.fr/topic/5343/communiquer-entre-le-client-et-le-serveur-le-réseau-et-les-paquets

      Ce tuto ne marche pas, ou du moins je n’y arrive pas ^.^’ : SimpleChannel n’existe pas, ChannelBuilder non plus…

      Je ne vois pas trop comment faire…

      À noter que le crash est dû à un NullPointerException sur la ligne annotée dans le code.

      Côté serveur :

      [11:53:16] [Netty Server IO #2/ERROR] [FML]: NetworkDispatcher exception
      java.io.IOException: Une connexion existante a dû être fermée par l’hôte distant
      	at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:1.8.0_181]
      	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[?:1.8.0_181]
      	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[?:1.8.0_181]
      	at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[?:1.8.0_181]
      	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[?:1.8.0_181]
      	at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) ~[PooledUnsafeDirectByteBuf.class:4.1.9.Final]
      	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1100) ~[AbstractByteBuf.class:4.1.9.Final]
      	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:372) ~[NioSocketChannel.class:4.1.9.Final]
      	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123) [AbstractNioByteChannel$NioByteUnsafe.class:4.1.9.Final]
      	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:624) [NioEventLoop.class:4.1.9.Final]
      	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:559) [NioEventLoop.class:4.1.9.Final]
      	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:476) [NioEventLoop.class:4.1.9.Final]
      	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438) [NioEventLoop.class:4.1.9.Final]
      	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [SingleThreadEventExecutor$5.class:4.1.9.Final]
      	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
      [11:53:16] [Server thread/INFO] [minecraft/NetHandlerPlayServer]: Player284 lost connection: Internal Exception: java.io.IOException: Une connexion existante a dû être fermée par l’hôte distant
      

      Côté Client :

      [11:53:14] [main/ERROR] [FML]: Exception caught during firing event net.minecraftforge.fml.common.gameevent.InputEvent$KeyInputEvent@237c65fc:
      java.lang.NullPointerException: null
      	at sirvechs.mudra.client.ClientProxy.timer(ClientProxy.java:89) ~[ClientProxy.class:?]
      	at sirvechs.mudra.client.ClientProxy.onEvent(ClientProxy.java:103) ~[ClientProxy.class:?]
      	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_ClientProxy_onEvent_KeyInputEvent.invoke(.dynamic) ~[?:?]
      	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
      	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?]
      	at net.minecraftforge.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:565) [FMLCommonHandler.class:?]
      	at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2143) [Minecraft.class:?]
      	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1934) [Minecraft.class:?]
      	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1187) [Minecraft.class:?]
      	at net.minecraft.client.Minecraft.run(Minecraft.java:441) [Minecraft.class:?]
      	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_181]
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_181]
      	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_181]
      	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
      	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_181]
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_181]
      	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_181]
      	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
      	at GradleStart.main(GradleStart.java:25) [start/:?]
      

      Merci beaucoup d’avoir pris le temps de lire.

      1 réponse Dernière réponse Répondre Citer 0
      • Wind_Blade
        Wind_Blade dernière édition par Wind_Blade

        Tu utilise la variable Minecraft.getMinecraft().player qui est null pour un serveur, c’est pour ça que tu crash

        1 réponse Dernière réponse Répondre Citer 0
        • robin4002
          robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par

          Salut,
          Le tutoriel sur les paquets que tu as voulu suivre est pour la 1.13, suis plutôt ce tutoriel : https://www.minecraftforgefrance.fr/topic/1000/1-7-2-le-network

          1 réponse Dernière réponse Répondre Citer 0
          • S
            Sirvechs dernière édition par

            Merci beaucoup ! je vais regarder ça 😄

            1 réponse Dernière réponse Répondre Citer 0
            • 1 / 1
            • Premier message
              Dernier message
            Design by Woryk
            Contact / Mentions Légales

            MINECRAFT FORGE FRANCE © 2018

            Powered by NodeBB