Hey there!
This one has been driving me nuts for days... I've been up and down the docs, checked dozens of examples (most of which don't work) and even had an AI take a stab at it. Please help!
I have an item that can be used on an item frame (with an item, eventually) to lock the frame (orientation and item) until the frame is broken. This is part of a larger script, so this is just a snippet of my code. I'm trying to achieve this by adding an NBT tag to the Item Frame to simply indicate if it is locked or unlocked, and respond accordingly.
I've used nbt a number of times before so I understand the basics. I've set tool data, player head skins and attributes without issue. But I cannot for the life of me add a tag to the item frame, unless it already has the tag when the frame i placed (which is not helpful so please do not suggest this).
This is what I have tried so far, with most of the commented lines just attempts to set the NBT. I've been at this for a while now.
USING ONLY SKRIPT & SKBEE - Please do not suggest other addons.
Thoughts? Are there other ways to do this besides NBT? Metadata?
This one has been driving me nuts for days... I've been up and down the docs, checked dozens of examples (most of which don't work) and even had an AI take a stab at it. Please help!
I have an item that can be used on an item frame (with an item, eventually) to lock the frame (orientation and item) until the frame is broken. This is part of a larger script, so this is just a snippet of my code. I'm trying to achieve this by adding an NBT tag to the Item Frame to simply indicate if it is locked or unlocked, and respond accordingly.
I've used nbt a number of times before so I understand the basics. I've set tool data, player head skins and attributes without issue. But I cannot for the life of me add a tag to the item frame, unless it already has the tag when the frame i placed (which is not helpful so please do not suggest this).
This is what I have tried so far, with most of the commented lines just attempts to set the NBT. I've been at this for a while now.
USING ONLY SKRIPT & SKBEE - Please do not suggest other addons.
Code:
on right-click on item frame:
set {_frame} to player's target
player's target entity is an item frame # This is to confirm that the Item Frame is actually in view.
player's tool is slime ball with name "&aFraming Gloo"
set {_loc} to location of event-entity
cancel the event
set {_nbt} to nbt of {_frame}
set {_facing} to facing of event-entity
send "&1frame" to player
#set {_newnbt} to nbt compound from "{""customstuff:framinggloo"":""locked""}"
#set nbt of event-entity to nbt from "{""customstuff:framinggloo"":""locked""}"
#set compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of {_frame} to nbt from {_newnbt}
#set tile entity at event-location to item frame with nbt {_newnbt}
wait 2 ticks
#spawn 1 of item frame at event-location with nbt {_newnbt}
send "%nbt of {_frame}%" to player
modify nbt of event-entity:
set int tag "locked" of nbt to 1 # This doesn't work either
set {_nbt} to nbt of event-entity
send "&d%{_nbt}%" to player
set compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of event-entity to nbt from "{""customstuff:framinggloo"":""locked""}"
send "&6%nbt of event-entity%" to "Omanoctoa" parsed as player
# In theory, if the NBT data is set properly, this section would toggle it back and forth... Initially, clicking without a set NBT tag would lock it.
if compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of {_frame} is not set:
add compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of event-entity to nbt from "{""customstuff:framinggloo"":""locked""}"
else if compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of {_frame} is set:
if compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of {_frame} contains "{""customstuff:framinggloo"":""locked""}":
set {_gloo} to "%compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of event-item%"
send "UNLOCKED: &a%{_gloo}%" to player
set {_toggle} to "unlocked"
set compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of event-entity to nbt from "{""customstuff:framinggloo"":%{_toggle}%}"
else if compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of {_frame} contains "{""customstuff:framinggloo"":""unlocked""}":
set {_gloo} to "%compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of event-item%"
send "UNLOCKED: &a%{_gloo}%" to player
set {_toggle} to "locked"
set compound tag "minecraft:custom_data;PublicBukkitValues" of nbt of event-entity to nbt from "{""customstuff:framinggloo"":%{_toggle}%}"
Thoughts? Are there other ways to do this besides NBT? Metadata?