Jump to content

Recommended Posts

Posted

Hi,

 

I'm trying to move entities from one dimension to another.

The task sounds quite simple. The parameters should look like this:

void teleport(Entity entity, int dimension, BlockPos pos)

 

code:

             
                        Teleporter tele = new PortalTeleporter((WorldServer) target.getWorld(worldObj), tar.selfLanding);
		if (entity instanceof EntityPlayerMP) {
			worldObj.getMinecraftServer().getPlayerList().transferPlayerToDimension((EntityPlayerMP) entity, target.getDimension(), tele);
		} else {
			worldObj.getMinecraftServer().getPlayerList().transferEntityToWorld(entity, entity.worldObj.provider.getDimension(), (WorldServer) entity.worldObj, (WorldServer) target.getWorld(worldObj), tele);
		}

 

public class PortalTeleporter extends Teleporter {

BlockPos pos;
WorldServer world;

public PortalTeleporter(WorldServer worldIn, BlockPos pos) {
	super(worldIn);
	this.world = worldIn;
	this.pos = pos;
}

@Override
public void placeInPortal(Entity entityIn, float rotationYaw) {
	this.world.getBlockState(pos);
	entityIn.setPosition(pos.getX() + .5, pos.getY() + .05, pos.getZ() + .5);
}

}

 

It works fine for players but other entities are not working correctly. Sometimes they vanish or duplicate.

 

Some warnings in the logs:

[01:56:31] [server thread/WARN]: Wrong location! (12, 10) should be (5, 0), EntityItem['item.item.fireball'/3960, l='New World', x=194,51, y=64,00, z=174,04]
[01:56:31] [server thread/WARN]: Tried to add entity Item but it was marked as removed already
[01:56:31] [server thread/WARN]: Keeping entity Item that already exists with UUID d27bbf73-764b-4f91-9877-c6679b958684

 

Is there a better solution for teleporting non-player entities (e.g. mobs,animals,items)?

thx

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.

Announcements



×
×
  • Create New...

Important Information

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