Jump to content

Recommended Posts

Posted (edited)

I have block which reads nbt data about position and dimension from an item in its inventory and sends any entities on top of it to that position and dimension. This works fine in most cases, but in particular when sending an item, player, or mob (that I have tested) from the end to the overworld, the entity will be sent to spawn instead of the specified position. I assume this is related to how hopping in the portal after defeating the dragon sends the player back to the overworld's spawn. Does anybody know how I can get around this?

Relevant code: https://github.com/eddie1101/Voidcraft/blob/master/src/main/java/erg/voidcraft/common/block/BlockPortalBase.java#L131-L181

Thanks

Edit: In addition, I noticed that when travelling to or from the nether near a nether portal, the entity will occasionally be teleported to the position of the portal rather than the specified position. Again, I assume this has something to do with how Minecraft syncs nether portals across dimensions, but the only way to change dimensions that I'm aware of is Entity#changeDimension, so I'm not sure how to get around this.

Edited by octa
  • octa changed the title to Issues with Changing an Entity's Dimension
Posted (edited)

So I tried this, and in looking at the vanilla code I'm making a few assumptions. It seems that when you call Entity#changeDimension, it will pass in the vanilla lambda for repositionEntity to your teleporter, which basically means in my code for Teleporter#placeEntity I want to completely ignore that lambda and do everything I need to do in placeEntity instead. I just want to teleport like normal, but without any of the vanilla portal shenanigans, so I basically just copied the vanilla lambda in changeDimension and removed the parts that I don't want, which gives me a null pointer. The problem is that using the EntityType factory gives me null instead of a ServerPlayerEntity. Maybe I'm missing something simple here, but for the life of me I can't figure this out. Any help is appreciated.

Here's my code

And here's my crash report

Edited by octa
Posted
3 hours ago, octa said:

I just want to teleport like normal, but without any of the vanilla portal shenanigans

You can use repositionEntity in that case, but supply it with false to prevent a portal from spawning. I suggest reading the javadoc in ITeleporter, it is very detailed!

Posted
7 hours ago, vemerion said:

You can use repositionEntity in that case, but supply it with false to prevent a portal from spawning. I suggest reading the javadoc in ITeleporter, it is very detailed!

This works, but it took me a little while to figure out why. I didn't realize that ITeleporter#getPortalInfo was responsible for a lot of the vanilla implementation. Thanks for the help!

Here's my code for anyone else struggling, but it's very simple.

  • octa changed the title to [SOLVED] Issues with Changing an Entity's Dimension

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.