Elrol_Arrowsend Posted November 5, 2019 Share Posted November 5, 2019 So, it was brought to my attention that the way that I am teleporting the player using commands seems to cause some rather bad happenings on the server. When I first tried it, after they found the issue, I tried to teleport from the overworld to the end. When I did it had me suspended in what looked like the end, but nothing was loaded, no blocks could be seen, I couldn't move, nothing. Eventually my client disconnected, and then when I tried to log back in the server crashed saying that the server took a 60 seconds for a single tick. The way that I am attempting to teleport the player is just like how they do it in minecrafts code (pulled from the end portal block code) entityIn.changeDimension(worldIn.dimension.getType() == DimensionType.THE_END ? DimensionType.OVERWORLD : DimensionType.THE_END); What I am doing is this: public static void teleport(ServerPlayerEntity player, Location loc) { PlayerData data = Main.database.get(player.getUniqueID()); data.prevLoc = getPlayerLocation(player); BlockPos pos = loc.getBlockPos(); if(!player.dimension.equals(loc.getDim())) { if(Main.isDev()) { player.changeDimension(loc.getDim()); }else { TextUtils.err(player.getCommandSource(), "The ability to teleport between dimensions has been disabled until it can be fixed."); return; } } player.setPositionAndUpdate((double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D); } I feel like something I am doing must be the issue, it is normally the reason, but I was fairly certain that this would work. 1 Quote Link to comment Share on other sites More sharing options...
Zarathul Posted November 8, 2019 Share Posted November 8, 2019 Teleporting players is a messy business. ServerPlayerEntity#changeDimension() has all kinds of hardcoded stuff that assumes it was called from a vanilla portal, and therefore isn't really suited for general purpose use. You can try ServerPlayerEntity#teleport() instead. Be warned though, ServerPlayerEntity#teleport() will not work from Block#onEntityCollision(). If your are using it only in a command you should be fine. Quote Link to comment Share on other sites More sharing options...
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.