Récupérer un EntityPlayerMP dans le PlayerLoggingInEvent



  • Bonjour à tous !

    Je suis actuellement en train d'implémenter des paquets, et je doit en envoyer un à la connexion d'un joueur... au joueur justement.
    Le seul problème, c'est que dans le PlayerLoggingInEvent, on peut obtenir un EntityPlayer mais pas un EntityPlayerMP.

    ILevel level = e.player.getCapability(DCLevelProvider.LEVEL_CAP, null);
    
    if (!e.player.world.isRemote)
    {
    	Dofuscraftcore.network.sendTo(new PacketSyncLevel(level),(EntityPlayerMP) e.player);
    }
    

    J'ai bien essayé de caster, mais cela ne fonctionne pas et j'ai une magnifique erreur :

    java.lang.ClassCastException: net.minecraft.client.network.NetHandlerPlayClient cannot be cast to net.minecraft.network.NetHandlerPlayServer
    

    On ne peut donc pas vraiment caster un EntityPlayer en EntityPlayerMP... Mais alors comment faire ?
    J'ai pas mal chercher mais je n'ai pas trouver de solution fonctionnelle en 1.12.2.

    Merci d'avance pour votre aide !

    Jerem'



  • check si le side est un side server avec le player#world#isRemote
    et apres si le isRemote == false tu pourra cast


  • Moddeurs confirmés Rédacteurs Administrateurs

    Il vérifies déjà que le monde est remote.
    C'est étrange que cela ne fonctionne pas, car cela devrait être le cas.
    Vérifies sinon avec e.player instanceof EntityPlayerMP ?



  • ha mince autant pour moi javais pas vu



  • J'ai toujours le même problème avec e.player instanceof EntityPlayerMP

    ILevel level = e.player.getCapability(DCLevelProvider.LEVEL_CAP, null);
    
    if (!e.player.world.isRemote && e.player instanceof EntityPlayerMP)
    {
    	Dofuscraftcore.network.sendTo(new PacketSyncLevel(level),(EntityPlayerMP) e.player);
    }
    

    C'est en effet bizarre car mes recherches me ramenais sur un code du genre, mais ça ne fonctionne pas. Peut-être une spécificité de la 1.12.2 ?

    Jerem'



  • Je reviens après quelques jours de tests pour faire un point.

    Etant donné que cela est censé fonctionner, j'ai fait un nettoyage de gradle, mis à jour IntellJ Idea (en le désinstallant complètement (cache compris)) ainsi que Java (idem que pour Idea).

    Et devinez quoi : rien ne change ! Toujours cette erreur !
    Du coup je suis complètement bloqué, je sais pas si un event similaire ayant un EntityPlayerMP existe, mais de ce que j'ai obtenu de mes recherches bah.... il n'y a pas grand chose...

    Une autre idée d'où ça pourrais venir ou d'une solution alternative ?

    Jerem'


  • Moddeurs confirmés Rédacteurs Administrateurs

    Tu enregistre où et comment ta classe ou se trouve ton event PlayerLoggingInEvent ?



  • Je l'enregistre dans la classe principale, dans le init :

    @Mod.EventHandler
    public void init(FMLInitializationEvent event)
    {
    	proxy.init();
    	if( event.getSide().isClient() )
    	{
    		MinecraftForge.EVENT_BUS.register(new CancelOpenMainGuiEvent());
    		MinecraftForge.EVENT_BUS.register(new CapabilityEvents());
    	}
    }
    

    J'ai aussi essayé dans le init du commonProxy, mais ça change rien.


  • Moddeurs confirmés Rédacteurs Administrateurs

    Sachant que tu l'enregistre dans une condition qui vérifies que le side est de type client, ce n'est pas étonnant bien que l'évent n'est jamais appelé avec une EntityPlayerMP ...

    Sort l'enregistrement de la classe d'évent de ce if.



  • Même en faisant cela, toujours la même erreur !

    @Mod.EventHandler
    public void init(FMLInitializationEvent event)
    {
    	proxy.init();
    
    	MinecraftForge.EVENT_BUS.register(new CapabilityEvents());
    
    	if( event.getSide().isClient() )
    	{
    		MinecraftForge.EVENT_BUS.register(new CancelOpenMainGuiEvent());
    	}
    }
    
    java.lang.ClassCastException: net.minecraft.client.network.NetHandlerPlayClient cannot be cast to net.minecraft.network.NetHandlerPlayServer
    


  • Où est-ce que tu utilise NetHandlerPlayServer dans ton code ? Parceque dans tout ce que tu as montré, il y a EntityPlayerMP mais pas NetHandlerPlayServer. (Et le crash porte sur ça) (D'ailleurs, le rapport complet peut être utile)



  • Justement je n'ai jamais entendu parler de ce NetHandlerPlayServer.
    Le rapport complet :

    [22:04:42] [Netty Local Client IO #0/ERROR]: SimpleChannelHandlerWrapper exception
    java.lang.ClassCastException: net.minecraft.client.network.NetHandlerPlayClient cannot be cast to net.minecraft.network.NetHandlerPlayServer
    	at net.minecraftforge.fml.common.network.simpleimpl.MessageContext.getServerHandler(MessageContext.java:55) ~[MessageContext.class:?]
    	at fr.dofuscraft.dofuscraftcore.network.PacketSyncLevel$Handler.onMessage(PacketSyncLevel.java:53) ~[PacketSyncLevel$Handler.class:?]
    	at fr.dofuscraft.dofuscraftcore.network.PacketSyncLevel$Handler.onMessage(PacketSyncLevel.java:48) ~[PacketSyncLevel$Handler.class:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:56) ~[SimpleChannelHandlerWrapper.class:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:36) ~[SimpleChannelHandlerWrapper.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) ~[SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [MessageToMessageDecoder.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) [MessageToMessageCodec.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:4.1.9.Final]
    	at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:274) [EmbeddedChannel.class:4.1.9.Final]
    	at net.minecraftforge.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:108) [FMLProxyPacket.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:155) [NetworkManager.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:49) [NetworkManager.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.handleClientSideCustomPacket(NetworkDispatcher.java:386) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:272) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:72) [NetworkDispatcher.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel.finishPeerRead0(LocalChannel.java:443) [LocalChannel.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel.access$500(LocalChannel.java:49) [LocalChannel.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel$5.run(LocalChannel.java:397) [LocalChannel$5.class:4.1.9.Final]
    	at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) [DefaultEventLoop.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_191]
    [22:04:42] [Netty Local Client IO #0/ERROR]: There was a critical exception handling a packet on channel dofuscraftcore
    java.lang.ClassCastException: net.minecraft.client.network.NetHandlerPlayClient cannot be cast to net.minecraft.network.NetHandlerPlayServer
    	at net.minecraftforge.fml.common.network.simpleimpl.MessageContext.getServerHandler(MessageContext.java:55) ~[MessageContext.class:?]
    	at fr.dofuscraft.dofuscraftcore.network.PacketSyncLevel$Handler.onMessage(PacketSyncLevel.java:53) ~[PacketSyncLevel$Handler.class:?]
    	at fr.dofuscraft.dofuscraftcore.network.PacketSyncLevel$Handler.onMessage(PacketSyncLevel.java:48) ~[PacketSyncLevel$Handler.class:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:56) ~[SimpleChannelHandlerWrapper.class:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:36) ~[SimpleChannelHandlerWrapper.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) ~[SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) ~[MessageToMessageDecoder.class:4.1.9.Final]
    	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) ~[DefaultChannelPipeline$HeadContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) ~[DefaultChannelPipeline.class:4.1.9.Final]
    	at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:274) ~[EmbeddedChannel.class:4.1.9.Final]
    	at net.minecraftforge.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:108) [FMLProxyPacket.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:155) [NetworkManager.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:49) [NetworkManager.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.handleClientSideCustomPacket(NetworkDispatcher.java:386) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:272) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:72) [NetworkDispatcher.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:4.1.9.Final]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel.finishPeerRead0(LocalChannel.java:443) [LocalChannel.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel.access$500(LocalChannel.java:49) [LocalChannel.class:4.1.9.Final]
    	at io.netty.channel.local.LocalChannel$5.run(LocalChannel.java:397) [LocalChannel$5.class:4.1.9.Final]
    	at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) [DefaultEventLoop.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_191]
    [22:04:42] [Netty Local Client IO #0/ERROR]: Network Disconnect: A fatal error has occurred, this connection is terminated
    

  • Moddeurs confirmés Rédacteurs Administrateurs

    Le problème est dans la fonction onMessage de ton paquet.



  • Bon et bien j'ai pas trouver l'erreur donc voilà le code :

    public static class Handler implements IMessageHandler<PacketSyncLevel, IMessage>
    {
    	@Override
    	public IMessage onMessage(PacketSyncLevel message, MessageContext ctx)
    	{
    		EntityPlayerMP player = ctx.getServerHandler().player;
    		IThreadListener thread = (WorldServer) ctx.getServerHandler().player.world;
    		thread.addScheduledTask(() -> {
    			if(player != null)
    			{
    				ILevel levelCap = player.getCapability(DCLevelProvider.LEVEL_CAP, null);
    				if(levelCap != null)
    				{
    					levelCap.setAlchemistLevel(message.alchemist_level);
    					levelCap.setLumberjackLevel(message.lumberjack_level);
    					levelCap.setMinerLevel(message.miner_level);
    					levelCap.setPeasantLevel(message.peasant_level);
    				}
    			}
    		});
    		return null;
    	}
    }
    

  • Moddeurs confirmés Rédacteurs Administrateurs

    Le problème c'est que tu envoies un paquet du serveur vers le client puis que dans le handler de ce dernier tu fais comme si tu étais côté serveur (alors que comme c'est le client qui reçoit le paquet, c'est le client qui va utiliser l'handler).

    Donc au lieu de EntityPlayerMP player = ctx.getServerHandler().player; il faut utiliser `Minecraft.getMinecraft().player) et au lieu de

    		IThreadListener thread = (WorldServer) ctx.getServerHandler().player.world;
    		thread.addScheduledTask(() -> {
    

    Il faut utiliser

    Minecraft.getMinecraf().addScheduledTask(() -> {
    


  • Effectivement ça a corrigé le problème !
    Grand merci de ton aide !



  • Je reviens car par contre j'ai ce crash quand je lance un serveur désormais :

    Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/entity/EntityPlayerSP
    	at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:1.8.0_191]
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[?:1.8.0_191]
    	at java.lang.Class.getConstructor0(Class.java:3075) ~[?:1.8.0_191]
    	at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_191]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:166) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:159) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at fr.dofuscraft.dofuscraftcore.Dofuscraftcore.preInit(Dofuscraftcore.java:50) ~[DofuscraftCore/:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:629) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?]
    	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?]
    	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?]
    	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?]
    	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135) ~[LoadController.class:?]
    	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:627) ~[Loader.class:?]
    	at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:98) ~[FMLServerHandler.class:?]
    	at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:332) ~[FMLCommonHandler.class:?]
    	at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:128) ~[DedicatedServer.class:?]
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:552) [MinecraftServer.class:?]
    	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
    Caused by: java.lang.ClassNotFoundException: net.minecraft.client.entity.EntityPlayerSP
    	at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?]
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_191]
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_191]
    	at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:1.8.0_191]
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[?:1.8.0_191]
    	at java.lang.Class.getConstructor0(Class.java:3075) ~[?:1.8.0_191]
    	at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_191]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:166) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:159) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at fr.dofuscraft.dofuscraftcore.Dofuscraftcore.preInit(Dofuscraftcore.java:50) ~[DofuscraftCore/:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:629) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?]
    	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?]
    	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?]
    	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?]
    	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135) ~[LoadController.class:?]
    	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:627) ~[Loader.class:?]
    	at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:98) ~[FMLServerHandler.class:?]
    	at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:332) ~[FMLCommonHandler.class:?]
    	at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:128) ~[DedicatedServer.class:?]
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:552) ~[MinecraftServer.class:?]
    	at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_191]
    Caused by: net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerException: Exception in class transformer net.minecraftforge.fml.common.asm.transformers.SideTransformer@4e3d36c2 from coremod FMLCorePlugin
    	at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:262) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?]
    	at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?]
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_191]
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_191]
    	at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:1.8.0_191]
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[?:1.8.0_191]
    	at java.lang.Class.getConstructor0(Class.java:3075) ~[?:1.8.0_191]
    	at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_191]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:166) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:159) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at fr.dofuscraft.dofuscraftcore.Dofuscraftcore.preInit(Dofuscraftcore.java:50) ~[DofuscraftCore/:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:629) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?]
    	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?]
    	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?]
    	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?]
    	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135) ~[LoadController.class:?]
    	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:627) ~[Loader.class:?]
    	at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:98) ~[FMLServerHandler.class:?]
    	at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:332) ~[FMLCommonHandler.class:?]
    	at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:128) ~[DedicatedServer.class:?]
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:552) ~[MinecraftServer.class:?]
    	at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_191]
    Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/entity/EntityPlayerSP for invalid side SERVER
    	at net.minecraftforge.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:62) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:258) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?]
    	at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?]
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_191]
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_191]
    	at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:1.8.0_191]
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[?:1.8.0_191]
    	at java.lang.Class.getConstructor0(Class.java:3075) ~[?:1.8.0_191]
    	at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_191]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:166) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:159) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at fr.dofuscraft.dofuscraftcore.Dofuscraftcore.preInit(Dofuscraftcore.java:50) ~[DofuscraftCore/:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:629) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?]
    	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?]
    	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196) ~[forgeSrc-1.12.2-14.23.4.2705.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
    	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?]
    	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?]
    	at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?]
    	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135) ~[LoadController.class:?]
    	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:627) ~[Loader.class:?]
    	at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:98) ~[FMLServerHandler.class:?]
    	at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:332) ~[FMLCommonHandler.class:?]
    	at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:128) ~[DedicatedServer.class:?]
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:552) ~[MinecraftServer.class:?]
    	at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_191]
    

    L'enregistrement des paquets (ce que vise le crash à la ligne 50 de Dofuscraftcore) :

    @Mod.EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
    	proxy.preInit();
    
    	// Enregistrement des paquets
    	network = NetworkRegistry.INSTANCE.newSimpleChannel(References.MODID);
    	network.registerMessage(PacketSyncLevel.Handler.class, PacketSyncLevel.class, 0, Side.CLIENT);
    	network.registerMessage(PacketSyncSubLevel.Handler.class, PacketSyncSubLevel.class, 1, Side.CLIENT);
    }
    

    Le paquets :

    public class PacketSyncLevel implements IMessage
    {
    private int alchemist_level;
    private int lumberjack_level;
    private int miner_level;
    private int peasant_level;
    
    public PacketSyncLevel() {}
    
    public PacketSyncLevel(ILevel level)
    {
    	this.alchemist_level = level.getAlchemistLevel();
    	this.lumberjack_level = level.getLumberjackLevel();
    	this.miner_level = level.getMinerLevel();
    	this.peasant_level = level.getPeasantLevel();
    }
    
    @Override
    public void fromBytes(ByteBuf buf)
    {
    	this.alchemist_level = buf.readInt();
    	this.lumberjack_level = buf.readInt();
    	this.miner_level = buf.readInt();
    	this.peasant_level = buf.readInt();
    }
    
    @Override
    public void toBytes(ByteBuf buf)
    {
    	buf.writeInt(this.alchemist_level);
    	buf.writeInt(this.lumberjack_level);
    	buf.writeInt(this.miner_level);
    	buf.writeInt(this.peasant_level);
    }
    
    public static class Handler implements IMessageHandler<PacketSyncLevel, IMessage>
    {
    	@Override
    	public IMessage onMessage(PacketSyncLevel message, MessageContext ctx)
    	{
    		EntityPlayer player = Minecraft.getMinecraft().player;
    		Minecraft.getMinecraft().addScheduledTask(() -> {
    			if(player != null)
    			{
    				ILevel levelCap = player.getCapability(DCLevelProvider.LEVEL_CAP, null);
    				if(levelCap != null)
    				{
    					levelCap.setAlchemistLevel(message.alchemist_level);
    					levelCap.setLumberjackLevel(message.lumberjack_level);
    					levelCap.setMinerLevel(message.miner_level);
    					levelCap.setPeasantLevel(message.peasant_level);
    				}
    			}
    		});
    		return null;
    	}
    }
    }
    
    

    J'ai cherché une solution mais je n'en ai pas trouvé qui corrige le crash sans causer des problème côté solo...
    Il reste plus que ça car en solo il n'y aucuns soucis tout fonctionne parfaitement !


  • Moddeurs confirmés Rédacteurs Administrateurs

    Mets un @SideOnly(Side.CLIENT) au dessus de onMessage



  • Effectivement ça fixe le problème !
    Merci beaucoup !


Log in to reply