@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
70 lines (69 loc) • 2.58 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TameableEntityTrait = void 0;
const ContentTraits_1 = require("./ContentTraits");
/**
* Tameable - can be tamed by the player.
*/
class TameableEntityTrait extends ContentTraits_1.EntityContentTrait {
get id() {
return "tameable";
}
getData(config) {
const tameItems = config?.tameItems ?? ["bone"];
const tameChance = config?.tameChance ?? 0.33;
return {
id: "tameable",
displayName: "Tameable",
description: "Can be tamed by the player with specific items",
category: "interaction",
components: {
"minecraft:tameable": {
probability: tameChance,
tame_items: tameItems,
tame_event: { event: "on_tame", target: "self" },
},
},
componentGroups: {
wild: {
"minecraft:behavior.avoid_mob_type": {
priority: 4,
entity_types: [
{
filters: { test: "is_family", subject: "other", value: "player" },
max_dist: 8,
walk_speed_multiplier: 1.0,
sprint_speed_multiplier: 1.0,
},
],
},
},
tamed: {
"minecraft:is_tamed": {},
"minecraft:behavior.follow_owner": {
priority: 4,
speed_multiplier: 1.0,
start_distance: 10,
stop_distance: 2,
},
"minecraft:behavior.owner_hurt_by_target": { priority: 1 },
"minecraft:behavior.owner_hurt_target": { priority: 2 },
"minecraft:sittable": {},
"minecraft:behavior.stay_while_sitting": { priority: 3 },
},
},
events: {
on_tame: {
remove: { component_groups: ["wild"] },
add: { component_groups: ["tamed"] },
},
},
spawnEvent: {
add: { component_groups: ["wild"] },
},
};
}
}
exports.TameableEntityTrait = TameableEntityTrait;