#how do you make a mob that opens form when hit?

1 messages · Page 1 of 1 (latest)

charred tundra
#
function ui_1(player) {
  const form = new ActionFormData()
  .button("test1")
  .button("test2")
  .show(player).then(r=>player.sendMessage(`${r.selection}`))
}

world.afterEvents.entityHitEntity.subscribe(evd=>{
  if (!(evd.damagingEntity instanceof Player)) return;
  if (evd.hitEntity.typeId !== "minecraft:villager") return;
  ui_1(evd.damagingEntity)
})```
#

Mob still takes damage tho, add damage sensor on their entity json to cancel the damage

#

change "minecraft:villager" to your entity identifier