#Entity spawns at last location

1 messages · Page 1 of 1 (latest)

hollow bear
#
    nbt compound from player's tool has tag "petleash"
    set {_n} to string tag "petleash" of nbt compound of player's tool
    if {_n} is "null":
        target entity is set
        owner of target entity is player
        cancel event
        if name of target entity is not set:
            set lore of player's tool to "&eCaptured: %target entity's type% (%target entity's type%)"
        else:
            set lore of player's tool to "&eCaptured: %name of target entity% (%target entity's type%)"
        set {_nbt} to nbt compound of target entity
        set string tag "petleash" of nbt compound of player's tool to "%{_nbt}%"
        set string tag "captured" of nbt compound of player's tool to "%target entity's type%"
        delete target entity
    else:
        cancel event
        set {_e} to string tag "captured" of nbt compound of player's tool
        set {_t} to nbt compound from string tag "petleash" of nbt compound of player's tool
        spawn {_e} parsed as entity type at player with nbt {_t}
        set string tag "petleash" of nbt compound of player's tool to "null"
        delete string tag "captured" of nbt compound of player's tool```
The entity is captured as intended and spawns with its nbt, but it spawns at the location you right click it from.
Ping on reply please : )
mild socket
#

i mean yeah

#

thats literally what you coded it to do

hollow bear
#

No like when you right click it to pick it up and then you right click again to place it it spawns at the first right click position

#

Does that make sense lmao

plain rune
hollow bear
#

No I want to spawn it at the player

#

Lemme record it

plain rune
#

okay :)

hollow bear
plain rune
#

so that's what happens. but you WANT it to spawn at where you click with your leash?

#

or where do you want it to spawn?

hollow bear
#

at the player

#

or target block

plain rune
#

maybe you can make it invisible and silent. that way you preserve its NBT data

hollow bear
#

but that doesn't work either

#

its nbt is saved

plain rune
#

it might be that the dog auto teleports because of some AI feature

#

oooh

#

wait

#

that's the problem! when you load in the NBT, it will load the previous location with the NBT. so you need to exclude the location from NBT

hollow bear
#

this is the nbt

#

I don't see location tho

#

am i missing it

plain rune
#

yup

hollow bear
#

uggg

plain rune
#

exclude the 'Pos' datatag

hollow bear
#

any idea on how to do that?

plain rune
#

that's a good problem to solve yourself 😊 you should be on the way now

hollow bear
#

lmao I hv no idea tho : (

#

skbee wiki time

plain rune
#

exactly! haha

#

or whatever wiki you prefer

hollow bear
#

Got it!

#

delete tag "Pos" of {_t}

#

Done

#

ty for ur help