Jump to content

[1.7.10] Forge Error ? IDE Crash when using Forge's Network


Player131

Recommended Posts

So, i got an error from my IDE when trying to use SimpleNetworkWrapper...

 

My Packet Registry class :

package net.yuri6037.AncientAddinMod.packet;

import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;

public class PacketManager {

    public static final SimpleNetworkWrapper networkSystem;

    static {
        networkSystem = NetworkRegistry.INSTANCE.newSimpleChannel("AncientAddinMod");
        networkSystem.registerMessage(MessageHeavyArmorJet.class, MessageHeavyArmorJet.class, 0, Side.CLIENT);
    }
}

 

My packet code

package net.yuri6037.AncientAddinMod.packet;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;

public class MessageHeavyArmorJet implements IMessage, IMessageHandler {

    public MessageHeavyArmorJet(){}

    public void fromBytes(ByteBuf buf) {
    }

    public void toBytes(ByteBuf buf) {
    }

    public IMessage onMessage(IMessage message, MessageContext ctx) {
        ctx.getServerHandler().playerEntity.motionY += 0.1D;
        ctx.getServerHandler().playerEntity.addPotionEffect(new PotionEffect(Potion.moveSpeed.getId(), 20, 5));
        return null;
    }
}

 

This packet is normaly used to activate speed effect when you're actioning your jets on my "Future" armor...

 

The crash from my IDE :

H:\Dev_MC1.7.10\IntelliJdevWorkspace\build\sources\java\net\yuri6037\AncientAddinMod\packet\PacketManager.java:13: cannot find symbol
symbol  : method registerMessage(java.lang.Class<net.yuri6037.AncientAddinMod.packet.MessageHeavyArmorJet>,java.lang.Class<net.yuri6037.AncientAddinMod.packet.MessageHeavyArmorJet>,int,cpw.mods.fml.relauncher.Side)
location: class cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
        networkSystem.registerMessage(MessageHeavyArmorJet.class, MessageHeavyArmorJet.class, 0, Side.CLIENT);
                     ^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

 

Thanks by advance

Link to comment
Share on other sites

This is compiling now, just made a Refactor->Rename on the Message class and now it's working. However i got a new problem happening everytime i send a packet to the server !

 

I got this crash from Minecraft Server Thread (Integrated server)

[15:52:12] [server thread/ERROR] [FML]: There was a critical exception handling a packet on channel AncientAddinMod
io.netty.handler.codec.DecoderException: java.lang.NullPointerException: Undefined message for discriminator 0 in channel AncientAddinMod
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[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:?]
Caused by: java.lang.NullPointerException: Undefined message for discriminator 0 in channel AncientAddinMod
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:73) ~[FMLIndexedMessageToMessageCodec.class:?]
at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?]
at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?]
... 13 more

Link to comment
Share on other sites

So i remade the way i was handling that. I made 2 MinecraftForge messages (one for client packets and one for server packets), but again impossible to run the Client or the Server. I got exactly the same problem saying that the method registerMessage isn't existing in the SimpleNetworkWrapper. I don't know why it's happening. The most problematic thing is that it's not the IDE that is causing the bug but the Java Compiler that i throwing this exception !!

 

I made some tests to find why it's happening, but it seams to be a problem with MinecraftForge running incrrectly on Java Compiler 1.6.0

Link to comment
Share on other sites

So for the code now it's much more longer, i hope you'll understand that, because i'm not realy liking comments... Sorry...

 

So the Client Message :

package net.yuri6037.AncientAddinMod.packet.mcNet;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;

public class HandlerMinecraftMessageClient implements IMessageHandler {

    public IMessage onMessage(IMessage message, MessageContext ctx) {
        if (message instanceof MessageMinecraftMessageServer){
            MessageMinecraftMessageServer ms = (MessageMinecraftMessageServer) message;
            if (ms.thePacket != null){
                ms.thePacket.handleData(ctx);
            }
        }
        return message;
    }

}

package net.yuri6037.AncientAddinMod.packet.mcNet;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.relauncher.Side;
import io.netty.buffer.ByteBuf;
import net.yuri6037.AncientAddinMod.packet.data.Packet;
import net.yuri6037.AncientAddinMod.packet.data.PacketList;
import org.apache.logging.log4j.LogManager;

public class MessageMinecraftMessageClient implements IMessage {

    protected Packet thePacket;

    public MessageMinecraftMessageClient(){}
    public MessageMinecraftMessageClient(Packet packet){
        thePacket = packet;
    }

    public void fromBytes(ByteBuf buf) {
        int id = buf.readInt();
        try {
            Packet packet = PacketList.getPacketFromID(id, Side.SERVER);
            packet.readData(buf);
            thePacket = packet;
        } catch (IllegalAccessException e) {
            LogManager.getLogger().warn("Unable to read Ancient packet : IllegalAccessException !");
        } catch (InstantiationException e) {
            LogManager.getLogger().warn("Unable to read Ancient packet : InstantiationException !");
        }
    }

    public void toBytes(ByteBuf buf) {
        thePacket.writeData(buf);
    }
}

 

The Server Message now :

package net.yuri6037.AncientAddinMod.packet.mcNet;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;

public class HandlerMinecraftMessageServer implements IMessageHandler {

    public IMessage onMessage(IMessage message, MessageContext ctx) {
        if (message instanceof MessageMinecraftMessageServer){
            MessageMinecraftMessageServer ms = (MessageMinecraftMessageServer) message;
            if (ms.thePacket != null){
                ms.thePacket.handleData(ctx);
            }
        }
        return message;
    }

}

package net.yuri6037.AncientAddinMod.packet.mcNet;

import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.relauncher.Side;
import io.netty.buffer.ByteBuf;
import net.yuri6037.AncientAddinMod.packet.data.Packet;
import net.yuri6037.AncientAddinMod.packet.data.PacketList;
import org.apache.logging.log4j.LogManager;

public class MessageMinecraftMessageServer implements IMessage {

    protected Packet thePacket;

    public MessageMinecraftMessageServer(){}
    public MessageMinecraftMessageServer(Packet packet){
        thePacket = packet;
    }

    public void fromBytes(ByteBuf buf) {
        int id = buf.readInt();
        try {
            Packet packet = PacketList.getPacketFromID(id, Side.CLIENT);
            packet.readData(buf);
            thePacket = packet;
        } catch (IllegalAccessException e) {
            LogManager.getLogger().warn("Unable to read Ancient packet : IllegalAccessException !");
        } catch (InstantiationException e) {
            LogManager.getLogger().warn("Unable to read Ancient packet : InstantiationException !");
        }
    }

    public void toBytes(ByteBuf buf) {
        thePacket.writeData(buf);
    }
}

 

My registry for SimpleNetworkWrapper (Packet interface is an interface that i made to be able to handle packets directly in the packet class) :

package net.yuri6037.AncientAddinMod.packet;

import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.yuri6037.AncientAddinMod.packet.data.Packet;
import net.yuri6037.AncientAddinMod.packet.mcNet.HandlerMinecraftMessageClient;
import net.yuri6037.AncientAddinMod.packet.mcNet.HandlerMinecraftMessageServer;
import net.yuri6037.AncientAddinMod.packet.mcNet.MessageMinecraftMessageClient;
import net.yuri6037.AncientAddinMod.packet.mcNet.MessageMinecraftMessageServer;

public class PacketManager {
    private static SimpleNetworkWrapper networkSystem;

    @SideOnly(Side.CLIENT)
    public static void sendPacketToServer(Packet packet){
        networkSystem.sendToServer(new MessageMinecraftMessageClient(packet));
    }

    public static void sendPacketToClient(Packet packet, EntityPlayer to){
        networkSystem.sendTo(new MessageMinecraftMessageServer(packet), (net.minecraft.entity.player.EntityPlayerMP) to);
    }

    static {
        networkSystem = NetworkRegistry.INSTANCE.newSimpleChannel("AncientAddinMod");
        networkSystem.registerMessage(HandlerMinecraftMessageClient.class, MessageMinecraftMessageClient.class, 0, Side.SERVER); //Here, i got the cannot find symbol registerMessage
        networkSystem.registerMessage(HandlerMinecraftMessageServer.class, MessageMinecraftMessageServer.class, 1, Side.CLIENT); //Here, i got the cannot find symbol registerMessage
    }
}

 

The new principe is realy simple now, i got 2 messages (One for handling client sent, and the other for server sent). You'll send a Packet that will be wrote using the client message or the server message, and after, when i recieve the client or server message, i read the ID of the Packet, create an instance of it, and after read data, and call a handling method in it.

 

The PacketManager class is instanciated by my main mod class in the init function.

 

 

Link to comment
Share on other sites

That's the way i'm making it, it's my way...

 

The problem is not happening on the way i'm doing that, it's happening when i try to call the registerMessage ! I can register anything even register the old packet i made before but it's crashing always and only if the registerMessage is called. If i comment these registrations, the client launches server too, but the rest isn't working, because the client and server don't know what are MessageMinecraftMessageClient or MessageMinecraftMessageServer. So i need help to find out why the register is causing a Java Compiler crash...

 

EDIT : I got another idea, but i'm not sure it's the right way.

I can use SLDT's GameEngine networking protocol. Indead, i made a network protocol using Java TCP sockets. The only problem is that it can cause conflicts with Netty. I'm not sure, because i never used, in any of my programms, librarys. The only library i'm using are LWGJL OpenGL and LWJGL OpenAL, or STD Lib when i code C++.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I am in such a mess. I have lost over 4.7m due to a scammer... It started as bank wires and then bitcoin. it is hard to imagine but it is true and can send any proof, then I tried to use a couple of recovery companies and was as well. Graphic design has been more than just a hobby for me since high school—it has become a thriving career. Starting in my parents' garage, I eventually expanded to my office, running a successful graphic design business. However, like many, I faced the need to diversify my investments due to inflation. This led me to invest 60.16 in Bitcoin, a decision that paid off handsomely as my investment grew to 4.7m over time. This financial windfall allowed me to upgrade my equipment and take on more ambitious projects, furthering the growth of my business. Unfortunately, my excitement was abruptly cut short when I fell victim to a hacking incident. Malware infected my computer, giving hackers access to my Bitcoin wallet. The devastation of potentially losing all my hard-earned savings and plans weighed heavily on me. At this dire moment, a fellow designer suggested Linux Cyber Security Company as a potential solution. Desperate for a lifeline, I reached out to them, hoping for a miracle. The response from Linux Cyber Security Company was prompt, incredibly professional, and effective. Their team quickly traced the hacker’s activities and recovered most of my funds, alleviating a significant amount of stress and uncertainty. Beyond the recovery, they took the time to educate me on essential practices to secure my Bitcoin holdings better. They emphasized using antivirus software to prevent malware infections, avoiding suspicious downloads, and the added security provided by hardware wallets. This experience served as a critical wake-up call for me. It highlighted the vulnerabilities inherent in digital assets and underscored the importance of robust security measures. Thanks to the guidance and expertise of Linux Cyber Security Company, I now feel more equipped to protect my digital assets proactively. Their insights have empowered me to implement stronger security protocols in my business operations and personal finances alike. With my Bitcoin funds securely recovered and a newfound understanding of digital security best practices, I am more confident in navigating future challenges. This journey has reinforced my commitment to safeguarding my hard-earned assets and leveraging technology responsibly. I am optimistic about the growth opportunities ahead, creatively in graphic design and prudently in investment strategies. In conclusion, while the hacking incident was a setback, it ultimately became a catalyst for enhancing my digital security awareness and resilience. I am grateful to Linux Cyber Security Company for their expertise and support during a challenging time, enabling me to continue pursuing my passion for graphic design with renewed confidence and financial stability. Contact a professional company I am sure they can help you with your case too, Website [www.linuxcybersecurity.com Email the team; info@)(linuxcybersecurity.com
    • https://pastebin.com/B2HnBZTa
    • it was easy villager mate, thanks ill see how to do it without that mod! thanks
    • mybe but thats the central mod i want, is that the one causing the problem?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.