Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

"Player moved wrongly"" causes teleportation to dimension to not work properly


ForgingMan
 Share

Recommended Posts

Trying to create a portal (using this tutorial) to another dimension that teleports back and forth like a nether portal. The portal works fine in creative mode, but in survival, it triggers a "Player moved wrongly!" message and sends the player to the coordinates of the Overworld portal in the other dimension, usually resulting in the player being spawned in the sky or underground (causing the player to suffocate).

 

Took a look at this post, which is a similar issue, but the solutions provided don't seem to be working.

 

Code:

 

Portal Tile Entity:

public class TileEntityDim extends TileEntity
{
	
	private static final String S_PLAYER_X = "PlayerPrevX";
	private static final String S_PLAYER_Y = "PlayerPrevY";
	private static final String S_PLAYER_Z = "PlayerPrevZ";
	private static final String S_PLAYER_X2 = "PlayerPrevX2";
	private static final String S_PLAYER_Y2 = "PlayerPrevY2";
	private static final String S_PLAYER_Z2 = "PlayerPrevZ2";
	private static final String dme = "DimEnter";
	private static int offsetX;
	private static int offsetZ;	
	public static double prevX;
	public static double prevY;
	public static double prevZ;
	public static double prevX2;
	public static double prevY2;
	public static double prevZ2;
	public static int dme2;
	
	public TileEntityDim()
	{
		super();
	}
	

	@Override
	public void readFromNBT(NBTTagCompound nbt)
	{
		super.readFromNBT(nbt);
		this.prevX = nbt.getDouble(S_PLAYER_X);
		this.prevY = nbt.getDouble(S_PLAYER_Y);
		this.prevZ = nbt.getDouble(S_PLAYER_Z);
		this.prevX2 = nbt.getDouble(S_PLAYER_X2);
		this.prevY2 = nbt.getDouble(S_PLAYER_Y2);
		this.prevZ2 = nbt.getDouble(S_PLAYER_Z2);
		this.dme2 = nbt.getInteger(dme);
	}

	@Override
	public NBTTagCompound writeToNBT(NBTTagCompound nbt)
	{
		super.writeToNBT(nbt);
		nbt.setDouble(S_PLAYER_X, prevX);
		nbt.setDouble(S_PLAYER_Y, prevY);
		nbt.setDouble(S_PLAYER_Z, prevZ);
		nbt.setDouble(S_PLAYER_X2, prevX2);
		nbt.setDouble(S_PLAYER_Y2, prevY2);
		nbt.setDouble(S_PLAYER_Z2, prevZ2);
		nbt.setInteger(dme, 2);
		return nbt;
	}

	public static void setOverworldXYZ(double posX, double posY, double posZ)
	{
		prevX = posX;
		prevY = posY;
		prevZ = posZ;
	}
	
	public static void setTestXYZ(double posX2, double posY2, double posZ2)
	{
		prevX2 = posX2;
		prevY2 = posY2;
		prevZ2 = posZ2;
	}

	public static void setDme22()
	{
		
		dme2 = 2;
		
	}
	
	public static void setDme21()
	{
		
		dme2 = 0;
		
	}
	
	public boolean onPlayerActivate(EntityPlayer player)
	{
		
		return true;
	}
	
	public static void tele(EntityPlayer player)
	{
		
		
		if ((player.getRidingEntity() == null) && ((player instanceof EntityPlayerMP)))
		{
			
			EntityPlayerMP player1 = (EntityPlayerMP)player;
			MinecraftServer mcServer = player1.getServer();
			
			if(player1.timeUntilPortal > 0)
			{
				
				player1.timeUntilPortal = 10;
				
			}else if(player1.dimension != Main.dimId){
				
				player1.timeUntilPortal = 10;
				
				if(prevX2 == 0.0 && prevY2 == 0.0 && prevZ2 == 0.0)
				{
					player1.timeUntilPortal = 10;
					setDme21();
					setOverworldXYZ(player1.posX, player1.posY, player1.posZ);
					mcServer.getPlayerList().transferPlayerToDimension(player1, Main.dimId, new TestTeleporter(mcServer.worldServerForDimension(Main.dimId), dme2, 0, 0 ,0));
					setTestXYZ(player1.posX, player1.posY, player1.posZ);
					
					
				}else if(prevX2 != 0.0 && prevY2 != 0.0 && prevZ2 != 0.0){
					player1.timeUntilPortal = 10;
					setDme22();
					setOverworldXYZ(player1.posX, player1.posY, player1.posZ);
mcServer.getPlayerList().transferPlayerToDimension(player1, Main.dimId, new TestTeleporter(mcServer.worldServerForDimension(Main.dimId), dme2, prevX2, prevY2, prevZ2));
					
				}
				
			}else if(player1.dimension == Main.dimId){
				
				player1.timeUntilPortal = 10;
				setDme22();
				setTestXYZ(player1.posX, player1.posY, player1.posZ);
				mcServer.getPlayerList().transferPlayerToDimension(player1, 0, new TestTeleporter(mcServer.worldServerForDimension(0), dme2, prevX, prevY, prevZ));
				
			}
		
		}
	}
}

 

Portal Block coded for colliding with portal:

 

public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
    {	
 
		if ((entityIn.getRidingEntity() == null) && ((entityIn instanceof EntityPlayerMP)))
		{
			
			EntityPlayerMP player1 = (EntityPlayerMP)entityIn;
		
			TileEntityDim.tele(player1);
		
		}
		
    }

 

 

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

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • # Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # #      102.54.94.97     rhino.acme.com          # source server #       38.25.63.10     x.acme.com              # x client host # localhost name resolution is handled within DNS itself. #    127.0.0.1       localhost #    ::1             localhost 127.0.0.1 checkhost.local 127.0.0.1 checkhost.local 109.94.209.70      *.fitgirl-repacks.xyz           # Fake FitGirl site 127.0.0.1 checkhost.local 127.0.0.1 checkhost.local 109.94.209.70      *.fitgirl-repacks.xyz           # Fake FitGirl site 109.94.209.70      fitgirlrepacks.in               # Fake FitGirl site 109.94.209.70      www.fitgirlrepacks.in           # Fake FitGirl site 109.94.209.70      fitgirlrepacks.co               # Fake FitGirl site 109.94.209.70      fitgirl-repacks.cc              # Fake FitGirl site 109.94.209.70      fitgirl-repacks.to              # Fake FitGirl site 109.94.209.70      fitgirl-repack.com              # Fake FitGirl site 109.94.209.70      fitgirl-repacks.website         # Fake FitGirl site 109.94.209.70      fitgirlrepack.games             # Fake FitGirl site 109.94.209.70      www.fitgirlrepacks.co           # Fake FitGirl site 109.94.209.70      www.fitgirl-repacks.cc          # Fake FitGirl site 109.94.209.70      www.fitgirl-repacks.to          # Fake FitGirl site 109.94.209.70      www.fitgirl-repack.com          # Fake FitGirl site 109.94.209.70      www.fitgirl-repacks.website     # Fake FitGirl site 109.94.209.70      ww9.fitgirl-repacks.xyz         # Fake FitGirl site 109.94.209.70      www.fitgirlrepack.games         # Fake FitGirl site 109.94.209.70      *.fitgirl-repacks.xyz           # Fake FitGirl site 109.94.209.70      fitgirl-repacks.xyz             # Fake FitGirl site 109.94.209.70      fitgirl-repack.net              # Fake FitGirl site 109.94.209.70      www.fitgirl-repack.net          # Fake FitGirl site 109.94.209.70      fitgirlpack.site                # Fake FitGirl site 109.94.209.70      www.fitgirlpack.site            # Fake FitGirl site 51.68.172.243 authserver.mojang.com 51.68.172.243 sessionserver.mojang.com 51.68.172.243 launchermeta.mojang.com  
    • Oh, I just found a similar question. I'll check it out.
    • I am trying to implement Mana. If I can add it to the Player after creating the Manadata, I think I can create it Is there a way to solve this or a class I can refer to?
    • I opened and waht is the next?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.