Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.