hello everyone ๐ i have a custom entity, which is tameable. i would like to add the behavior.open_door and behavior.restrict_open_door after the entity is tamed. i tried to call a custom event (which would add the behaviors via component_group) in the minecraft:tameable component. but that doesn't seem to work. do i have to use the minecraft:on_tame event? how can i add a component / behavior when the entity is tamed? thanks in advance!
#[RESOLVED] how to add behavior to entity upon / after taming
1 messages ยท Page 1 of 1 (latest)
Take a look at events and component groups
And yes the tame event (you can call it differently if you want) plays in to it
sorry, for the late response, i have been busy. i have the following code:
"events": {
"my_namespace:enable_doors": {
"add": { "component_groups": [ "my_namespace:can_use_doors" ] }
}
},
"component_groups": {
"my_namespace:can_use_doors": {
"minecraft:behavior.open_door": {
"priority": 6,
"close_door_after": true
}
}
},
"minecraft:tameable": {
"probability": 1,
"tame_items": "bone",
"tame_event": {
"event": [ "my_namespace:enable_doors" ],
"target": "self"
}
},
and my navigation.generic contains
"can_pass_doors": true,
"can_open_doors": true,
if i add the behavior.open_door "directly" to the entity, like all the other components, it works. but i don't want "wild" entities to be able to go around and randomly open doors. am i missing something else in my code?
i should probably mention, the above are just snippets of the corresponding code parts, since i didn't want to dump the whole file here
You need to have the navigation like the door behavior to open the door so 2 navigation groups that change open your event (one event for opening doors and one for no longer opening them)
i have added the event
"minecraft:entity_spawned": {
"add": { "component_groups": [ "my_namespace:cannot_use_doors" ] },
"remove": { }
},
and the corresponding group
"my_namespace:cannot_use_doors": {
"minecraft:scale": {
"value": 1
}
}
so that the "can't open" behavior is the default and added to every entity spawned. i have also added the scale component (with different values) to my component groups, just to have a visual feedback if sth changes. also if i switch to "can_use_doors" (with a different scale) in the "entity_spawned" event, that works. so the components themselves, in the groups, work.
however, after taming neither the scale, nor the door behavior changes. it seems to me my custom event in the tameable component is not called. i have also made sure that there are no typos anywhere
Show me tameable and the corresponding event
"minecraft:tameable": {
"probability": 1,
"tame_items": "bone",
"tame_event": {
"event": [ "my_namespace:enable_doors" ],
"target": "self"
}
},
"events": {
"minecraft:entity_spawned": {
"add": { "component_groups": [ "my_namespace:cannot_use_doors" ] },
"remove": { }
},
"my_namespace:enable_doors": {
"add": { "component_groups": [ "my_namespace:can_use_doors" ] },
"remove": { "component_groups": [ "my_namespace:cannot_use_doors" ] }
}
},
"component_groups": {
"my_namespace:can_use_doors": {
"minecraft:behavior.open_door": {
"priority": 6,
"close_door_after": true
},
"minecraft:behavior.restrict_open_door": {
"priority": 5
},
"minecraft:scale": {
"value": 0.1
}
},
"my_namespace:cannot_use_doors": {
"minecraft:scale": {
"value": 0.5
}
}
},
omg, i finally got it. in the beginning i hat tried out, if you can have multiple tame events and therefore put them in square brackets and forgot to remove them after. but the brackets are, what's breaking it. i just noticed it ๐ i removed the brackets and it works now. tysm for your help though. knowing, that i should be able to put a custom event was still very important. so the correct code is
"minecraft:tameable": {
"probability": 1,
"tame_items": "bone",
"tame_event": {
"event": "my_namespace:enable_doors",
"target": "self"
}
},
sometimes it really is just sth stupid and easy to overlook like this ๐คฃ