Jump to content

[1.11.2]Teleport player from The End


YijunYuan

Recommended Posts

I'm developing a mod to provide bukkit-plugin-like /home, /sethome, /back command for vanilla server with forge installed. Everything goes fine, except for teleporting player from The End.

 

When player is in the world except for The End, I can use the following code to teleport the player to the dimension and the position I need:


if (entityPlayerMP.dimension != homeposition.getHomeDimensionId()) {
	entityPlayerMP.changeDimension(homeposition.getHomeDimensionId());
}

entityPlayerMP.setPositionAndUpdate( homeposition.getHomeCoordinates().xCoord,
                    		homeposition.getHomeCoordinates().yCoord,
                    		homeposition.getHomeCoordinates().zCoord);

 

However when entityPlayerMP is in The End, i.e. entityPlayerMP.dimension equals 1, this code will lead to an error, that is when the player travels from The End to Overworld, the entity in the Overworld will froze and if the dragon is not beated, it's hit point will appear in the Overworld.

The reason of this is the particularity of The End, and teleporting from it will make the player in the process of the End Poem, which is broken by the setPositionAndUpdate (it's hard to explain it in a few words but if you look into the implementation of changeDimension(), you will know clearly what I'm saying). That is to say, if I want the /back and /home command works for the player in The End, I need a user defined method of change dimension, which is beyond my ability.

Link to comment
Share on other sites

11 hours ago, Kriptikz said:

Here is what mcjty does in rftools, although you will probably have to go through his code a couple times as a couple of his own methods in different files.

https://github.com/McJty/RFTools/blob/b738a7e6b830c7f4ceb763914200fc98e1ed5a83/src/main/java/mcjty/rftools/blocks/teleporter/TeleportationTools.java#L354-L369

Well... I've tried his/her method without success......

Link to comment
Share on other sites

On 2017/4/19 at 2:20 AM, Kriptikz said:

Show your code. Also explain what you tried and how it didn't work.

                entityPlayerMP.sendMessage(new TextComponentString(TextFormatting.RED + "" + TextFormatting.ITALIC + " TESTING!"));
                WorldServer worldServer = entityPlayerMP.getEntityWorld().getMinecraftServer().worldServerForDimension(home_dim);
                entityPlayerMP.getServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, home_dim, new YJTeleporter(worldServer));
                entityPlayerMP.setPositionAndUpdate(home_x, home_y, home_z);
                entityPlayerMP.setPositionAndUpdate(home_x, home_y, home_z);
                worldServer.spawnEntity(entityPlayerMP);
                worldServer.updateEntityWithOptionalForce(entityPlayerMP, false);

The bossInfo bar of Dragon is still in the screen when I transport the player from The End to The Overworld when the Dragon is not beated. (The frozen entity problem has solved.)

 

I'm finding a way to make the bossInfo invisible in the Overworld.

Basicly, reconnecting to the server can solve it, but it's obviously not a perfect way.

Edited by YijunYuan
Link to comment
Share on other sites

15 hours ago, YijunYuan said:

The bossInfo bar of Dragon is still in the screen when I transport the player from The End to The Overworld when the Dragon is not beated. (The frozen entity problem has solved.)

 

I'm finding a way to make the bossInfo invisible in the Overworld.

Basicly, reconnecting to the server can solve it, but it's obviously not a perfect way.

Yea that's a common problem with most teleportation mods, I am planning on looking into it though as I also have a method of teleportation in a mod i'm working on. I know vanilla does a check when the player logs in to see if the dragon is there because it tries to render the boss bar or something like that. Atm I don't yet know of a way to remove the bar from in game properly.

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