Store NBT without coordinates

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

  • LOOKING FOR A VERSION OF SKRIPT?

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

Status
Not open for further replies.

IMO0226

Member
Jul 28, 2019
1
0
1
25
Skript Version: Skript 2.3.6
Skellet Version: Skellet 1.9.6b
Minecraft Version: 1.13.2

I want to create a system what helps the players move entities with just clicking with an item.
The system removes the entity, stores the NBT of that entity without any problems, summons the new entity with the correct NBT, but it teleports back to location where is was captured.
As you can see, I tried to use metadatas and actually teleporting back the entity but non of them worked for me. How can I make the entity stay there where it was summoned?

Code:
on right click on an entity:
    if player's tool is lead:
        if player's tool's lore is "&9Entitás befogó":
            if clicked entity isn't a player:
                if {entity.%player%} isn't set:
                    cancel event
                    set {entity.nbt.%player%} to nbt of clicked entity
                    set {entity.%player%} to clicked entity
                    teleport clicked entity to location(0, -300, 0, world of player)

on right click:
    if player's tool is lead:
        if player's tool's lore is "&9Entitás befogó":
            if player is sneaking:
                if {entity.%player%} is set:
                    set {entity.x} to x location of clicked block
                    set {entity.y} to y location of clicked block
                    set {entity.z} to z location of clicked block
                    add 1 to {entity.y}
                    spawn villager above the clicked block with nbt "%{entity.nbt.%player%}%"
                    wait 1 tick
                    set metadata "Position" of last spawned villager to "[%{entity.x}%d,%{entity.y}%d,%{entity.z}%d]"
                    teleport last spawned villager above clicked block
                    delete {entity.%player%}
                    delete {entity.nbt.%player%}

There are no errors on reloading neither on using the tool.

Also is there a way to summon entities directly from variables so I don't have to do else-if sections like below?
Code:
...
if {entity.%player%} is villager:
    summon villager above the clicked block with nbt "%{entity.nbt.%player%}%"
else if {entity.%player%} is wolf:
    summon wolf above the clicked block with nbt "%{entity.nbt.%player%}%"
else if {entity.%player%} is chicken:
    summon chicken above the clicked block with nbt "%{entity.nbt.%player%}%"
...

I'm using these addons as well:
skUtilities 0.9.2, Skungee 1.0.9, SkQuery 4.1.1, skript-mirror 0.19.1, SK_NBeeT 2.4.2, Vixio 2.0.1
 
Status
Not open for further replies.