Error with a mod that I am not able to fix

Started by GonzaloSurba on

Topic category: Help with modding (Java Edition)

Last seen on 11:37, 2. Nov 2023
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Error with a mod that I am not able to fix
Fri, 01/21/2022 - 22:29 (edited)

I have made the following code in blocks, it consists of an item that when you make "Shift + Right Click" saves your location and when you make "right click" the game teleports you to the saved location, the problem is that if you press "right click" without having saved any location the game sends you to the void and you die. I hope you can help me and thank you in advance. I attach an image with the code below.

Mod code

 

Edited by GonzaloSurba on Fri, 01/21/2022 - 22:29
Last seen on 11:43, 29. Mar 2024
Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can try to add another…
Sun, 01/23/2022 - 02:12

You can try to add another tag that will detect if you set your position to true. Something like this

 

If= event/target entity is sneaking and PosSet = false

 

Do= set nbt logic tag of event target Entity to true

 

        Add here the other part of the procedure

 

Else If PosSet = true

 

Do = the teleport thing

 

Else if PosSet = false

 

Do = anything like sending an error message etc

 

I can't send a screenshot rn I'm not in my laptop

Last seen on 02:51, 19. Feb 2022
Joined Dec 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Maybe try to create a local…
Sun, 01/23/2022 - 07:37

Maybe try to create a local variable called "locationSet" or something and in your if statement, after "play enderman sound", do "set locationSet=true". In the else part of your procedure and an if statement surrounding all of that code. In the if statement do "if get local variable locationSet=true"... Something like thislocationSet

Last seen on 11:37, 2. Nov 2023
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for both replies, I…
Sun, 01/23/2022 - 22:27

Thanks for both replies, I have done what vGravity has asked me and it has worked halfway, the first time you right click it works well and simply nothing happens but the other times (from the second onwards) if you press right click without having any saved location you fall into the void equally, can it be to use a global variable instead of local?. I hope you can help me.

Regarding ClOud1076, I do not understand well what it refers to with certain things, especially with the principle. If you could send me an image I would appreciate it.

Last seen on 11:37, 2. Nov 2023
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for both replies, I…
Sun, 01/23/2022 - 22:33

Thanks for both replies, I have done what vGravity has asked me and it has worked halfway, the first time you right click it works well and simply nothing happens but the other times (from the second onwards) if you press right click without having any saved location you fall into the void equally, can it be to use a global variable instead of local?. I hope you can help me.

Regarding ClOud1076, I do not understand well what it refers to with certain things, especially with the principle. If you could send me an image I would appreciate it.

I leave you an image of the code currently.

P.T: I do not know if this message will be repeated in the previous message, I clicked on delete but it was not deleted.

Mod code two

Last seen on 15:22, 26. Apr 2024
Joined Dec 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
To do this: Check if the X,…
Sun, 01/23/2022 - 23:54

To do this: Check if the X, Y and Z nbt tags are 0. If they are all 0, don't Teleport. If they are different than 0, then allow the Teleport

Last seen on 11:43, 29. Mar 2024
Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ok so i manage to make a…
Mon, 01/24/2022 - 04:03

ok so i manage to make a procedure combining urielito3010 and vGravity's  procedure and this what i have came up with.

the procedure

So "test" is a player persistent global variable.  you can rename it to setPosition or anything you want. tx,ty and tz is x y z just renamed.

Last seen on 11:37, 2. Nov 2023
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have done what ClOud1076…
Mon, 01/24/2022 - 15:36

I have done what ClOud1076 told me and it has worked, thank you very much. Any questions I have I will comment on in the forum.