#Is there a way to do auto tame when a mob is summoned

1 messages · Page 1 of 1 (latest)

severe dome
#

So I'm making a addon and I need to know is there a way to make it so when you summon a mob it auto tames

rancid sleet
#

You can use scripts. This example summons a tamed wolf when a player right clicks with a bone:

import { world } from "@minecraft/server";

world.afterEvents.itemUse.subscribe(({ source, itemStack }) => {
    if (source.typeId !== 'minecraft:player') return;
    if (itemStack.typeId !== 'minecraft:bone') return;
    const location = source.location;
    const dimension = source.dimension;
    const target = dimension.spawnEntity('minecraft:wolf', location);
    const tameable = target.getComponent('tameable');
    if (tameable) {
        tameable.tame(source);
    }
});
torn mesa
rancid sleet
formal iron
torn mesa
#

Wait I'll find it

rancid sleet
# severe dome So I'm making a addon and I need to know is there a way to make it so when you s...

@torn mesa This is what you mean?

You can summon tamed mobs with just commands. But Wolfs and Cats will not be tamed to the player.

In this example, I added a hasitem activation method so mobs are only summoned once.

execute as @a[hasitem={item=stick, location=slot.weapon.mainhand}] at @s positioned ^^^2 run summon horse ~~1~ facing @s minecraft:on_tame

replaceitem entity @a[hasitem={item=stick, location=slot.weapon.mainhand}] slot.weapon.mainhand 0 air

This can have interesting results. Tamed Piglins do not transform into Pigmen in the Overworld. Zombies are crazy fast.

torn mesa
#
{
  "format_version": "1.16.0",
  "minecraft:entity": {
    "description": {
      "identifier": "minecraft:example",
      "runtime_identifier": "minecraft:arrow",
      "is_spawnable": false,
      "is_summonable": true,
      "is_experimental": false
    },
    "components":
      "minecraft:projectile": {},
      "minecraft:transformation": {
        "into": "minecraft:example<minecraft:on_tame>",
        "keep_owner": true
      }
    }
  }
}