Jump to content

[Auto-solved] IEEP, Clonning and Synchronization.


Ernio

Recommended Posts

We all know that after death PlayerEntity is being dissolved and new one is created. By subscribing to events:

EntityConstructing ("CONSTRUCTING")

EntityJoinWorldEvent ("JOINED")

PlayerEvent.Clone ("COPYING")

I've analised process and have no idea (in proper way) how to archieve my goal, here's process:

[20:01:03] [server thread/INFO]: 2 fell from a high place
[20:01:03] [Client thread/INFO]: [CHAT] 2 fell from a high place
[20:01:05] [Client thread/INFO] [sTDOUT]: [com.midstcraft.ernio.RoA.common.events.ForgeEvents:join:54]: JOINED
[20:01:06] [Client thread/INFO] [sTDOUT]: [com.midstcraft.ernio.RoA.common.events.ForgeEvents:join:54]: JOINED
[20:01:08] [Client thread/INFO] [sTDOUT]: [com.midstcraft.ernio.RoA.common.events.ForgeEvents:join:54]: JOINED
[20:01:09] [Client thread/INFO] [sTDOUT]: [com.midstcraft.ernio.RoA.common.events.ForgeEvents:join:54]: JOINED
[20:01:11] [Client thread/INFO] [sTDOUT]: [com.midstcraft.ernio.RoA.common.events.ForgeEvents:join:54]: JOINED
[20:01:11] [server thread/INFO] [sTDOUT]: [com.midstcraft.ernio.RoA.common.events.ForgeEvents:onEntityConstructing:33]: CONSTRUCTING
[20:01:11] [server thread/INFO] [sTDOUT]: [com.midstcraft.ernio.RoA.common.events.ForgeEvents:onPlayerClonning:42]: COPYING
[20:01:11] [server thread/INFO] [sTDOUT]: [com.midstcraft.ernio.RoA.common.events.ForgeEvents:join:54]: JOINED
[20:01:11] [Client thread/INFO] [sTDOUT]: [com.midstcraft.ernio.RoA.common.events.ForgeEvents:onEntityConstructing:33]: CONSTRUCTING
[20:01:11] [Client thread/INFO] [sTDOUT]: [com.midstcraft.ernio.RoA.common.events.ForgeEvents:join:54]: JOINED

 

So basically:

1. You die.

2. Client launches JOINED every 1-2sec attempting to join (idk why)

3. When you press respawn server makes new EntityPlayer, copies old entity data to new one and joins the world.

4. Client Makes new player and joins the world.

 

My goal 1: Make Client data presist, as seen on event - impossible since Clonning is only server-side.

So when my "goal 1" turned out to be impossible here's goal 2:

Make Server send synchro packet right after Player is reconstructed.

 

Now the problem is that as you can see - I can't send ANY packet just after neither of "CONSTRUCTING", "COPYING" or even "JOINED" since at that moment Client doesn't even have NEW Player constructed.

 

Normally I was doing it in PlayerLoggedInEvent, but that is only called just after you log in, never when you respawn.

 

So basically - what do I do? Best options, tools? (I know I could send request packet from client after "JOINED" but that's next ton of making sure all player will get what the should).

 

------

Edit: Regarding the idea of "sending request packet" after client finishes creating new PlayerEntity:

That's again - how? I'd need some event that gets called only once just after new entity joins world, and as you can see in log above the EntityJoinWorldEvent is spamming clint-side every those 1-2sec when you are viewing Death-screen (before you push "respawn" button).

So basically I would need to somehow check if the "request packet" should be sent, but to do that I would again need some boolean inside IEEP which at that time might aswell not exist.

 

I just DON'T belive that stuff like this can be SO damn difficult, I must be missing something...

-------

 

Thx for help :)

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

Link to comment
Share on other sites

So I was kinda hoping I'll be like "EUREKA!" by now... but I am not.

For convinience:

 

@SubscribeEvent
public void onEntityConstructing(EntityConstructing event)
{
	if (event.entity instanceof EntityPlayer)
	{
		System.out.println("CONSTRUCTING");
		if (ExtendedPlayer.get((EntityPlayer) event.entity) == null)
			ExtendedPlayer.register((EntityPlayer) event.entity);
	}
}

@SubscribeEvent
public void onPlayerClonning(PlayerEvent.Clone event)
{
	System.out.println("COPYING");
	ExtendedPlayer epNew = ExtendedPlayer.get(event.entityPlayer);
	ExtendedPlayer epOld = ExtendedPlayer.get(event.original);
	epNew.setStats(epOld.getStats());
	epNew.setInventory(epOld.getInventory());
}

@SubscribeEvent
public void join(EntityJoinWorldEvent event)
{
	if (event.entity instanceof EntityPlayer)
	{
		System.out.println("JOINED");
	}
}

 

Data on server presists and on client not (since Clonning is server-side). I am looking for something that's called ONCE after both EntityPlayers (client and server) are constructed, can't find anything. Will I really have to add additional boolean and check it client-side every tick then make requesting packet to server to send data? Anyone had similar problem? I need that data right after player is constructed (used by GUI).

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

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.

Announcements



×
×
  • Create New...

Important Information

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