Jump to content

[SOLVED][1.7.10]Packet not being sent to client.


deadrecon98

Recommended Posts

You call sync() from the constructor of your IEEP in the NBT read method. That cannot work, you cannot send packets that early. Use the PlayerLoginEvent to send the initial packet.

 

Also: Why are you using an int[] in your packet? Use named fields.

Why is your fromBytes method empty? That packet cannot work.

 

Ok I will get to work on that tomorrow. As for using int[] I was trying to make a completely flexible packet but I'm not sure that's possible. Or at least worth trying.

Link to comment
Share on other sites

Ok I will get to work on that tomorrow. As for using int[] I was trying to make a completely flexible packet but I'm not sure that's possible. Or at least worth trying.

Usually, each packet should be as specific as possible so you only send the exact information you need.

 

If you just want to sync everything in your IEEP once when the player logs in, though, it's much simpler to send it as NBT data.

Link to comment
Share on other sites

Usually, each packet should be as specific as possible so you only send the exact information you need.

 

If you just want to sync everything in your IEEP once when the player logs in, though, it's much simpler to send it as NBT data.

 

I was using that a first but I am updating the data very often so it seems packets are necesary.

Link to comment
Share on other sites

You call sync() from the constructor of your IEEP in the NBT read method. That cannot work, you cannot send packets that early. Use the PlayerLoginEvent to send the initial packet.

 

Also: Why are you using an int[] in your packet? Use named fields.

Why is your fromBytes method empty? That packet cannot work.

 

I've done what you said but not a single thing has changed. Same error, slightly modified code.

Link to comment
Share on other sites

You're calling your sync method all over the place... you should only sync when the player actually joins the world, i.e. on PlayerLoggedInEvent + PlayerRespawnEvent, OR EntityJoinWorldEvent.

 

Not in any constructors, not when copying the data, not in PlayerEvent.Clone.

 

You CAN sync when data changes, such as your magic level, but then you should only be sending that specific information, not your entire extended properties.

 

It looks like your packet should be sent and received fine, aside from the above issue. Do you not get any of your log output in the console?

Link to comment
Share on other sites

You're calling your sync method all over the place... you should only sync when the player actually joins the world, i.e. on PlayerLoggedInEvent + PlayerRespawnEvent, OR EntityJoinWorldEvent.

 

Not in any constructors, not when copying the data, not in PlayerEvent.Clone.

 

You CAN sync when data changes, such as your magic level, but then you should only be sending that specific information, not your entire extended properties.

 

It looks like your packet should be sent and received fine, aside from the above issue. Do you not get any of your log output in the console?

 

I am getting output from my console but the issue that I had shown above is fixed. I was calling sync() inside of the wrong function. As for the rest it should work fine but for some reason it doesn't. Note: The crafting is flawless but for some reason the client is still not getting ANY data from the server. I have updated the GitHub again so that you can see all of the changes i've made.

Link to comment
Share on other sites

I think your problem  is in your main class:

FMLCommonHandler.instance().bus().register(instance); // why are you registering your main class to the FML bus?!?!?!
MinecraftForge.EVENT_BUS.register(new EventManager());

 

PlayerLoggedInEvent is on the FML bus, but you do not register your event manager on that bus (you can register to multiple buses, if need be).

Link to comment
Share on other sites

I think your problem  is in your main class:

FMLCommonHandler.instance().bus().register(instance); // why are you registering your main class to the FML bus?!?!?!
MinecraftForge.EVENT_BUS.register(new EventManager());

 

PlayerLoggedInEvent is on the FML bus, but you do not register your event manager on that bus (you can register to multiple buses, if need be).

 

As for me registering my instance that was completely unneccesary, I copied the code for the main files from another mod of mine. As for the PlayerLoggedInEvent, I removed that completely as it was not needed. So it's still the same thing as always. It just seems like whenever I send data to the client, the client just ignores it.

Link to comment
Share on other sites

I think your problem  is in your main class:

FMLCommonHandler.instance().bus().register(instance); // why are you registering your main class to the FML bus?!?!?!
MinecraftForge.EVENT_BUS.register(new EventManager());

 

PlayerLoggedInEvent is on the FML bus, but you do not register your event manager on that bus (you can register to multiple buses, if need be).

 

As for me registering my instance that was completely unneccesary, I copied the code for the main files from another mod of mine. As for the PlayerLoggedInEvent, I removed that completely as it was not needed. So it's still the same thing as always. It just seems like whenever I send data to the client, the client just ignores it.

 

EDIT: I am smacking myself very very hard right now.

 

    public static class Handler implements IMessageHandler<PacketUpdateClientIEEPData, IMessage> {      
        @Override
        public IMessage onMessage(PacketUpdateClientIEEPData message, MessageContext ctx){
        	EntityPlayerExtended player = EntityPlayerExtended.get(Minecraft.getMinecraft().thePlayer);
        	log.debug(String.format("Received packet."));
            return null;
        }
    }

Notice anything missing? Yeah, I completely forgot to tell it to update the players data.

Link to comment
Share on other sites

Yeah, I saw that. For some reason, I thought it was intentional on your part, like you were debugging that part because the packet wasn't being received at all.

 

In the future, it would be helpful to provide the console output, then it would have been immediately obvious what you were missing.

 

I was using it to debug it but I just got so tossed around with everything else I forgot. I will add in some more checks to make sure the data is sent properly and received properly

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.



×
×
  • Create New...

Important Information

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