Deconnection anormale



  • Bonjour, j'ai fais un GUI, et quand je clique sur un bouton, en solo, ca me deconnecte de ma partie et le menu multijoueur apparaît. Les logs:

    [17:35:33] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception
    java.lang.NullPointerException
    at com.harrypotter.sosoh.proxy.Handler.onMessage(Handler.java:27) ~[Handler.class:?]
    at com.harrypotter.sosoh.proxy.Handler.onMessage(Handler.java:1) ~[Handler.class:?]
    at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:37) ~[SimpleChannelHandlerWrapper.class:?]
    at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:17) ~[SimpleChannelHandlerWrapper.class:?]
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) ~[SimpleChannelInboundHandler.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [MessageToMessageDecoder.class:?]
    at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) [MessageToMessageCodec.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?]
    at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?]
    at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [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:?]
    [17:35:33] [Server thread/ERROR] [FML]: There was a critical exception handling a packet on channel HarryPotterMod
    java.lang.NullPointerException
    at com.harrypotter.sosoh.proxy.Handler.onMessage(Handler.java:27) ~[Handler.class:?]
    at com.harrypotter.sosoh.proxy.Handler.onMessage(Handler.java:1) ~[Handler.class:?]
    at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:37) ~[SimpleChannelHandlerWrapper.class:?]
    at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:17) ~[SimpleChannelHandlerWrapper.class:?]
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) ~[SimpleChannelInboundHandler.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[MessageToMessageDecoder.class:?]
    at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) ~[DefaultChannelPipeline.class:?]
    at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) ~[EmbeddedChannel.class:?]
    at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [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:?]
    [17:35:33] [Server thread/INFO]: Stopping server
    [17:35:33] [Server thread/INFO]: Saving players
    [17:35:33] [Server thread/INFO]: Saving worlds
    [17:35:33] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/Overworld
    [17:35:33] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/Nether
    [17:35:33] [Server thread/INFO]: Saving chunks for level 'Nouveau monde'/The End
    [17:35:34] [Server thread/INFO] [FML]: Unloading dimension 0
    [17:35:34] [Server thread/INFO] [FML]: Unloading dimension -1
    [17:35:34] [Server thread/INFO] [FML]: Unloading dimension 1
    [17:35:34] [Server thread/INFO] [FML]: Applying holder lookups
    [17:35:34] [Server thread/INFO] [FML]: Holder lookups applied
    [17:44:35] [Client thread/INFO]: Stopping!
    [17:44:35] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]:
    [17:44:35] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: SoundSystem shutting down…
    [17:44:35] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:importantMessage:90]:     Author: Paul Lamb, www.paulscode.com
    [17:44:35] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]:
    
    

    Mon code:

    ​public class Handler implements IMessageHandler <paquethandler, imessage="">{
    
        @Override
        public IMessage onMessage(PaquetHandler message, MessageContext ctx) {
    
        if(message.text.equals("p")){
    
        Container c = ctx.getServerHandler().playerEntity.openContainer;
        if(c instanceof ContainerChaudron){
          TileEntityChaudron tile = ((ContainerChaudron)c).getTile();
    
          if (tile.getStackInSlot(8).getItem() == ModHarryPotter.itemRPotionAmnesie){
          if(tile.getStackInSlot(10) == null && tile.getStackInSlot(1) != null && tile.getStackInSlot(1).getItem() == ModHarryPotter.itemEauLethe && tile.getStackInSlot(2) != null && tile.getStackInSlot(2).getItem() == ModHarryPotter.itemBaieGui && tile.getStackInSlot(3) != null && tile.getStackInSlot(3).getItem() == ModHarryPotter.itemBrinsValeriane && tile.getStackInSlot(9) != null && tile.getStackInSlot(9).getItem() == ModHarryPotter.itemFiole){
    
          tile.setInventorySlotContents(1, null);
          tile.setInventorySlotContents(2, null);
          tile.setInventorySlotContents(3, null);
          tile.setInventorySlotContents(4, null);
          tile.setInventorySlotContents(5, null);
          tile.setInventorySlotContents(6, null);
          tile.setInventorySlotContents(7, null);
          tile.setInventorySlotContents(9, null);
          tile.setInventorySlotContents(10, new ItemStack(ModHarryPotter.itemPotionAmnesie));
    
          }
          else{
          ctx.getServerHandler().playerEntity.addChatMessage(new ChatComponentText("Recette de Potion Amnesie: Ingredients Manquants"));
          }
          }
           else if(tile.getStackInSlot(10) != null){
    
            ctx.getServerHandler().playerEntity.addChatMessage(new ChatComponentText("Merci de laisser vide le derniere case."));
            }
           else if(tile.getStackInSlot(8) == null){
    
            ctx.getServerHandler().playerEntity.addChatMessage(new ChatComponentText("Merci de mettre une recette dans la case adaptée."));
            }
        }
        }
            return null;
        }
    }
    ```</paquethandler,>

  • Administrateurs

    java.lang.NullPointerException
        at com.harrypotter.sosoh.proxy.Handler.onMessage(Handler.java:27) ~[Handler.class:?]
    

    Tu as un NPE à la ligne 27.



  • A la ligne 27 c'est "if(tile.getStackInSlot(8).getItem() == ModHarryPotter.itemRPotionAmnesie){"


  • Administrateurs

    remplace par :
    if(tile.getStackInSlot(8) != null && tile.getStackInSlot(8).getItem() == ModHarryPotter.itemRPotionAmnesie){



  • Ah oui merci