Jump to content

Recommended Posts

Posted

Code:

Network Registration: Lines 136 & 151

Packet sent from server to client.

Packet sent form client to server

 

I load a single player world, wait a second, back to title screen and load the world again. Log file.

 

Now in the log file, why does line 105 happen after 104 the first time I log in, but next time it is not the same as line 141. The packet seems to go missing?

 

Or maybe there is something I am missing?

Posted

Where do you send PacketPingClient message?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

In 1.8 Minecraft has beed split into 4 threads, not 2 like it was before. New threads are: Client, Server, Client Netty and Server Netty. Those 2 last are threads responsinble for handling packets. What happens in your code:

Client logs in, server creates instance of player entity and sends packet to client via LoggedIn event. The problem here is that the client HASN'T created EntityPlayer yet, since spawnin entity to world (spawn packet) occurs after LoggedIn event. This results in packet being delivered but not processed since you don't have entity to process it on (player).

 

EVERYTIME (strongly suggeted) you send packt from server to client you have to ensure thread-safety by creating new Runnable and putting it into main client thread.

@Override
	public IMessage handleClientMessage(PacketSendData message, MessageContext ctx)
	{
		Minecraft.getMinecraft().addScheduledTask(new ScheludedClientTaskData(message));
		return null;
	}

ScheludedClientTaskData implements Runnable and in run() you put all code to be processed.

 

Note: This way you don't have to ever worry about packet being lost to non-existant client entities (that includes mobs if you e.g send packet from EntityJoinWorld, which also happens on server first).

1.7.10 is no longer supported by forge, you are on your own.

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.

Announcements



×
×
  • Create New...

Important Information

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