(SOLVED) Need help coding a two way teleporting item.

Started by Onyx12133 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(SOLVED) Need help coding a two way teleporting item.
Tue, 10/26/2021 - 18:51 (edited)

I'm trying to make a food that teleports you to a custom dimension when you eat it in the overworld, but also have that same food teleport you back to the overworld when you eat it in the custom dimension. 

Here is the code I have for it so far. (hopefully it isn't to hard to understand)

Event Trigger- no additional trigger

If: [ID of Dimension (Event/target entity) is in = (Surface)]

Do: Switch dimension of (Event/target entity) to (Custom Dimension)

 

if: [ID of dimension (Event/target entity) is in = (Custom Dimension)]

Do: Switch dimension of (Event/target entity) to (Surface)

When I eat it in the overworld, it shows the "loading world" screen for about a quarter second and then I load back into the overworld without traveling to the custom dimension, does anyone know how to fix this?

 

Also it would appreciate it if anyone could tell me how to make your x y z coordinates the coordinates you teleport to when you enter the dimension

Edited by Onyx12133 on Tue, 10/26/2021 - 18:51
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Your problem is that the…
Mon, 10/25/2021 - 01:44

Your problem is that the game is detecting you are in the overworld, then teleporting you to the custom dimension. It then runs the second part of your command, now you are in the custom dimension so it would just teleport you back. To fix this you should make that if block a if, else if block the if being if your in the overworld, and the else if being if your in the custom dimension. This will make it so only one of those if statements run at a time.

 

For your problem with the x y z you could try to do this with local variables and make a variable for x, y, and z. Then when you enter the dimension it would teleport you to those coordinates.