Topic category: Help with Minecraft modding (Java Edition)
Hello all,
Im trying to create a block with a GUI that can only be used by the person who first right clicks it. The If statement that i created doesn't seem to work, i'm fairly new to the modding world so im trying my best. I have a Global variable that is called "myplayerplacedsafeblock" which changes in the first procedure i created. That procedure changes the string to say "the players name" and changes the block state to the second form so that it can test if your the same person who placed the block. Yet it isn't working at all and i need help. (i dont understand how to post pictures)
my code:
}
Event trigger - triggered by external call
or when (global trigger): {no additional trigger}
if get (display) name of [event/target entity] = get global: [myplayerplacedsafeblock]
do open screen for [event/target enitity] pass location x: [x] y: [y] z: [z] Gui: {SafeGUI}
else close any GUI open for [event/target entity]
}
this could work:
{
if get nbt logic tag "hasOwner" of block at x y z if it has block entity = true
do
if get nbt text tag "owner" of block at x y z if block has block entity = get (display) name of event/target entity
do Open Screen for event target entity pass location x y z GUI: []
else send message "You are not the owner of this block!" to event/target entity show in action bar: true
else set nbt logic tag "hasOwner" of block at x y z to true if it has block entity
set nbt text tag "owner" of block at x y z to get (display) name of event/target entity
Open Screen for event target entity pass location x y z GUI: []
}
and btw activate block tile entity on the block settings