Started by
GonzaloSurba
on
Topic category: Help with Minecraft modding (Java Edition)
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.
Edited by GonzaloSurba on Fri, 01/21/2022 - 22:29
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
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 this
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.
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.
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
ok so i manage to make a procedure combining urielito3010 and vGravity's procedure and this what i have came up with.
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.
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.