Discord Thread custom tag being removed from block

  • 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 comminuty!

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

This thread came from the skUnity Discord. You can't reply to it here but if you join the skUnity Discord, you'll be able to post a reply there. The thread link is part of the thread's message.
Status
Not open for further replies.
in my script below sometimes the "item display" will lose the custom tag that makes it function as the "item display" when retracted by a piston. does anyone know why this is happening?

code:
code_language.skript:
vb
command /loaditemdisplay:
    trigger:
        set {itemdisp} to iron trapdoor named "&fItem Display"
        give {itemdisp} to the player

on place:
    if 1 of player's tool is {itemdisp}:
        set tag "custom;itemdisp" of nbt of event-block to 1

function itemdispgui(p: player):
    set {_gui} to a new chest inventory with 1 row with name "Item Display"
    set slot 0, 1, 2, and 3 of {_gui} to black stained glass pane named " "
    set slot 5, 6, 7, and 8 of {_gui} to black stained glass pane named " "
    set slot 4 of {_gui} to {disp.%{locofitemdisp.%{_p}%}%}
    open {_gui} to {_p}

on right click:
    if nbt of event-block has tag "custom;itemdisp":
        if tag "custom;itemdisp" of nbt of event-block is 1:
            cancel event
            set {locofitemdisp.%player%} to location of event-block
            itemdispgui(player)

on inventory close:
    if name of event-inventory is "Item Display":
        set {disp.%{locofitemdisp.%player%}%} to slot 4 of event-inventory

on inventory click:
    if click action is double click using mouse or left mouse button with shift:
        event-item is black stained glass pane named " "
        cancel event
        stop
    if name of event-inventory is "Item Display":
        if event-inventory is player's top inventory:
            if index of event-slot != 4:
                cancel event

on break:
    if nbt of event-block has tag "custom;itemdisp":
        if tag "custom;itemdisp" of nbt of event-block is 1:
            cancel event
            set event-block to air
            drop {itemdisp} at location of event-block
Please try it on your own servers and see if you can find the issue because right now I’m clueless.

Posted by: nathan.5718 from the skUnity Discord.
 
so my testing leads to it only disappearing when using a non sticky piston and if it doesn't go back into the original place it was set

Posted by: fusezion from the skUnity Discord.
 
code_language.skript:
command /loaditemdisplay:
    trigger:
        give iron trapdoor named "&fItem Display" to the player

on place:
    add location of event-block to {blocks::*} if name of player's tool is "&fItem Display"
        
function itemdispgui(p: player):
    set {_gui} to a new chest inventory with 1 row with name "Item Display"
    set slots 1,2,3,4,5,6,7,8 of {_gui} to black stained glass pane named "&8*"
    set slot 4 of {_gui} to {disp.%{locofitemdisp.%{_p}%}%}
    open {_gui} to {_p}

on right click:
    {blocks::*} contains location of clicked block
    cancel event
    itemdispgui(player)

on inventory close:
    set {disp::%{locofitemdisp::%player%}%} to slot 4 of event-inventory if name of event-inventory is "Item Display"
        
on inventory click:
    event-inventory is not player's inventory
    click type is left mouse button
    name of event-inventory is "Item Display"
    cancel event

on break:
    {blocks::*} contains location of event-block
    cancel event
    remove location of event-block from {blocks::*}
    set event-block to air
    drop event-block at location of event-block
it seems to me that this is some error with nbt, i also corrected the code a bit, i didnt check if it works but there are no errors

Posted by: _grifin_ from the skUnity Discord.
 
the only interaction skbee has with pistons is this part of the api listener
code_language.skript:
java
    // If a piston moves a block with NBT, we remove the NBT
    @EventHandler(priority = EventPriority.MONITOR)
    private void onPistonPush(BlockPistonExtendEvent event) {
        if (!this.PISTON_EXTEND) return;
        if (event.isCancelled()) return;
        Block piston = event.getBlock();
        BlockState blockState = piston.getState();

        if (event.isSticky()) return;
        if (blockState instanceof TileState) return;
        if (!NBTApi.supportsBlockNBT()) return;
        event.getBlocks().forEach(this::breakBlock);
    }
My guess is nbt isn't saved to a block as much as it's saved to a location inside a chunk

Posted by: fusezion from the skUnity Discord.
 
Status
Not open for further replies.