#How to see if a tamed entity is owned by the player interacting with it?

7 messages · Page 1 of 1 (latest)

tropic yacht
#

so i'm working on a script where you give your cat a totem of undying and it makes it invincable, and using an example i got both the item and the identifying the entity done, but when i try and check the entity's owner all i get is an undefined response.

onEvent('item.entity_interact', event => {
  if(event.target.type == "minecraft:cat" && event.item.id == "minecraft:totem_of_undying"){
    event.player.tell(event.target.owner) // this gives the error
    if(event.target.owner == event.player.id){
      //make invincable
    }
  }
})
normal heraldBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

dusk rock
tropic yacht
idle crypt
#

you can just summon a lighting bolt

stiff flicker
#

event.target.block.spawnlightning(false)

tropic yacht
#

for anyone who wants to make cats immortal gods.

onEvent('item.entity_interact', event => {
  if(event.target.type == "minecraft:cat" && event.item.id == "minecraft:totem_of_undying"){
    if(event.target.minecraftEntity.owner == event.player.minecraftEntity){
      let n = ""
      if (event.target.name.text == undefined){
        n ="Your cat"
      }else{
        n = event.target.name.text
      }
      if (event.target.fullNBT.Invulnerable == 0){
        event.item.count--
    event.target.mergeFullNBT('{Invulnerable:1b}')
    event.target.block.spawnLightning(false)
    event.player.tell(n + " has accended to it's rightful place as a god!")
      }else{
    event.player.tell(n + " refuses to relinquish it's godhood.")
      }
    }
  }
})