Jump to content

[SOLVED][1.15.2] Problem with sending players to other dimension in multiplayer


Novârch

Recommended Posts

I'm trying to transport players to a modded dimension if they are near another player using an ability. I'm using Entity#getDistance for the distance calculation and World#getPlayers to get the players. I'm then sending a client to server packet to transport the players, I have no idea why, but it only works if I do it in a client to server packet.

The code where the distance is being calculated and the method is being called can be found here on GitHub,

and the packet code can be found here.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

19 minutes ago, diesieben07 said:

Also, wtf is this

I...have no idea, that code is horrible, I wrote the mod's core functionality 3 months ago on 1.12 and haven't changed it since, I should really fix some of that

horrible code, thanks for pointing that out.

58 minutes ago, diesieben07 said:

Your code never checks that is on the server.

I added a !World#isRemote to the packet before teleporting, but the server host still can't teleport other players, but they can teleport him.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

29 minutes ago, diesieben07 said:

You don't need a packet... you are in an entity. Which ticks on the server side already.

Nope, gives me a java.lang.IllegalStateException: Removing entity while ticking!, already detailed in this thread.

 

*Edit: I'm trying to teleport a PLAYER, not a normal entity, changeDimension works fine on ENTITES, but not PLAYERS.

Edited by Novârch

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

5 minutes ago, diesieben07 said:

Then we need to figure out what causes that. And not start just randomly sending packets around...

Please update your code to call changeDimension on the server only.  changeDimension should definitely work for players, ServerPlayerEntity even overrides it and vanilla portals use it.

Updated the method, here's the debug.log.

Edited by Novârch

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

30 minutes ago, diesieben07 said:

Ah. Yes, that makes sense. You cannot remove entities from worlds while that world is updating it's entities (which is the case here, because you are in an entity tick method).

You have to keep a list of dimension changes and then process them after the fact, probably using ServerTickEvent (note that you will need to check the phase field, you probably want END, to process the teleports at the end of the server tick, after entities have been updated).

Would it be a good idea to make a List of UUIDs and store it in the players capability?

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

5 hours ago, diesieben07 said:

Not sure why a player capability. Really you can just make a static List of ServerPlayerEntity and put them in there, as it is only until the end of the server tick anyways.

Thanks for all the help! Got it working flawlessly now.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

  • Novârch changed the title to [SOLVED][1.15.2] Problem with sending players to other dimension in multiplayer

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.