Novârch Posted May 13, 2020 Posted May 13, 2020 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. Quote 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".
Novârch Posted May 14, 2020 Author Posted May 14, 2020 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. Quote 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".
Novârch Posted May 14, 2020 Author Posted May 14, 2020 (edited) 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 May 14, 2020 by Novârch Quote 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".
Novârch Posted May 14, 2020 Author Posted May 14, 2020 (edited) 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 May 14, 2020 by Novârch Quote 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".
Novârch Posted May 14, 2020 Author Posted May 14, 2020 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? Quote 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".
Novârch Posted May 14, 2020 Author Posted May 14, 2020 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. Quote 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".
Recommended Posts
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.