Toggle to lock item frames with item on-click

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Omanoctoa

Member
Feb 4, 2025
36
3
8
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.
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?
 

Attachments

  • 2025-11-27_22.17.03.png
    2025-11-27_22.17.03.png
    302.3 KB · Views: 74
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.
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?
After trying to fix this for hours, I have taken another approach with simply tracking the UUID of the item frames stored in a list. But if anyone wants to try to make this work using NBT...I couldn't figure it out. I had CursorAI look at it too and even it was stumped.