I'm currently trying to use iron golems as guards that, when triggered, seemingly attack players and "send" them to prison.
The way I'm doing this at the moment is by running the following command on repeat:
/execute at @e[name=spiderous,nbt={HurtTime:10s}] run tp @p[scores={prisoner=1..}] 817 9 -478
, and tping the spider above the player when the player moves. This seems to work if the spider is damaged by a player, however when the spider is damaged by the iron golem the command does not trigger.
I am summoning a custom iron golem and so am not sure if it needs to be on a specific team, which I have not done, or if mobs in general don't trigger HurtTime like players do.
The iron golem command I am using currently is:
/execute as @a[scores={theif=1..}] run summon minecraft:iron_golem 828 56 -502 {CustomName:"\"Guard\"",CustomNameVisible:1,PersistenceRequired:1b,Attributes:[{Name:"generic.followRange",Base:300},{Name:"generic.movementSpeed",Base:0.4f},{Name:"generic.attackDamage",Base:1}],Invulnerable:1}
I think I'm misunderstanding something about the way HurtTime works and am unable to solve this. I am having difficulty finding clues to a solution elsewhere and any help is welcome.
Thank you
Edit:
I've found a solution for causing the golem to appear to chase the player by summoning a golem with an invisible creeper (with a very long fuse timer) on top and then sensing when a player is within a certain distance to activate it.
I'm still not sure if HurtTime can be triggered by another mob, but it's no longer blocking the solution at least.
Hello,
I'm currently trying to use iron golems as guards that, when triggered, seemingly attack players and "send" them to prison.
The way I'm doing this at the moment is by running the following command on repeat:
/execute at @e[name=spiderous,nbt={HurtTime:10s}] run tp @p[scores={prisoner=1..}] 817 9 -478
, and tping the spider above the player when the player moves. This seems to work if the spider is damaged by a player, however when the spider is damaged by the iron golem the command does not trigger.
I am summoning a custom iron golem and so am not sure if it needs to be on a specific team, which I have not done, or if mobs in general don't trigger HurtTime like players do.
The iron golem command I am using currently is:
/execute as @a[scores={theif=1..}] run summon minecraft:iron_golem 828 56 -502 {CustomName:"\"Guard\"",CustomNameVisible:1,PersistenceRequired:1b,Attributes:[{Name:"generic.followRange",Base:300},{Name:"generic.movementSpeed",Base:0.4f},{Name:"generic.attackDamage",Base:1}],Invulnerable:1}
I think I'm misunderstanding something about the way HurtTime works and am unable to solve this. I am having difficulty finding clues to a solution elsewhere and any help is welcome.
Thank you
Edit:
I've found a solution for causing the golem to appear to chase the player by summoning a golem with an invisible creeper (with a very long fuse timer) on top and then sensing when a player is within a certain distance to activate it.
I'm still not sure if HurtTime can be triggered by another mob, but it's no longer blocking the solution at least.