【原创】实体全事件写法的精品教程
本帖最后由 送你的执念 于 2022-4-10 16:56 编辑特别注意//之后为注释 /*之间为注释*/
更多精品教程可加QQ群:1014557374获取
{/*由吃毛不吐毛球制作
事件名称可以使用":","_"等符号*/
"events": {//事件 通常写在组件后
//我们先来看一个简单的添加和移除组件组的事件
"event_1": {//事件名称
"add": {//添加
"component_groups": [
"cg_1"//组件组名称
]
},
"remove": {//移除
"component_groups": [
"cg_2"
]
}
},
//事件可以运行指令
"event_3": {
"run_command": {//运行指令
"command": [//指令部分
"give @s minecraft"//需要运行的指令
],
"target": "player"//运行指令的目标 默认为self
}
},
//指令可以做到随机触发
"event_2": {
"randomize": [//随机化
{
"weight": 95,//权重 这里为95%的概率 95/5+95 权重大小可以大于或小于100
"add": {
"component_groups": [
"cg_3"
]
}
},
{
"weight": 5,//这里为5%的概率
"add": {
"component_groups": [
"cg_4"
]
}
}
]
},
//随机触发空事件
"randomize": [
{
"weight": 60//60/65的概率触发一个空事件
},
{
"weight": 5,//这里为5/65的概率
"add": {
"component_groups": [
"cg_5"
]
}
}
]
//下面是一个原版僵尸转化为溺尸带条件的序列化事件
"minecraft:convert_to_drowned": {
"sequence": [//序列
{//第一个事件
"filters": {//过滤器 每一个过滤器仅作用于它所属的那一部分
"test": "has_component",
"operator": "!=",
"value": "minecraft:is_baby"
},
"add": {
"component_groups": [
"minecraft:convert_to_drowned"
]
},
"remove": {
"component_groups": [
"minecraft:start_drowned_transformation"
]
}
},//第一个事件结束 如果溺尸没有"minecraft:is_baby"组件,就添加"minecraft:convert_to_drowned"组件组并移除"minecraft:start_drowned_transformation"组件组
{//第二个事件
"filters": {
"test": "has_component",
//这里没有写"operator" 使用了默认值equals
"value": "minecraft:is_baby"
},
"add": {
"component_groups": [
"minecraft:convert_to_baby_drowned"
]
},
"remove": {
"component_groups": [
"minecraft:start_drowned_transformation"
]
}
}//第二个事件结束 如果溺尸有"minecraft:is_baby"组件,就添加"minecraft:convert_to_baby_drowned"组件组并移除"minecraft:start_drowned_transformation"组件组
]
},
"on_interact_es": {//触发器事件
"trigger": {//触发器
"filters": {//过滤器
"test": "has_tag",
"subject": "other",
"value": "test"
},
"event": "interacted",//触发的事件
"target": "other"//目标
//此事件在实体与玩家交互时运行。如果玩家拥有test这个tag,那么interacted事件将以player为命令使用者运行事件
}
},
"on_interact": {//一个带序列化的触发器事件
"sequence": [
{
"trigger": {
"filters": {
"test": "has_tag",
"subject": "other",
"value": "test"
},
"event": "wiki:interacted",
"target": "other"
}
},
{
"add": {
"component_groups": [
"wiki:interacted_with"
]
}
}
]
},
//mojang在实体中也内置了事件
"minecraft:entity_born": {//例如一个"minecraft:entity_born"事件,它将在实体出生时触发,这意味着实体需要通过"minecraft:behavior.breed"来触发
"add": {
"component_groups": [
"goat_baby"
]
}
},
"minecraft:entity_transformed": {//实体转化时触发
"trigger": "spawn_baby"//触发"spawn_baby"事件
}.
/*目前已知的内置事件:
"minecraft:entity_born" minecraft:entity_born triggers an event calls on an entity when the entity is born via breeding.生物出生时触发
"minecraft:entity_spawned" minecraft:entity_spawned triggers an event calls on an entity when the entity is spawned in the world.生物生成时触发
"minecraft:entity_transformed" minecraft:entity_transformed triggers an event call on an entity that transforms into another entity.生物转化时触发
"minecraft:on_prime" minecraft:on_prime triggers an event calls on an entity when the entity is set to explode.生物爆炸时触发*/
//下面是一个复杂的随机化和序列化结合的事件,作者就不一一注解了
"wiki:on_hit": {
"randomize": [
{
"weight": 60
},
{
"weight": 40,
"sequence": [
{
"trigger": "attack_event"
},
{
"filters": {
"test": "has_component",
"operator": "!=",
"value": "minecraft:is_sheared"
},
"sequence": [
{
"filters": {
"test": "distance_to_nearest_player",
"operator": "<=",
"value": 5.0
},
"randomize": [
{
"weight": 10,
"add": {
"component_groups": [
"explode"
]
}
},
{
"weight": 60,
"add": {
"component_groups": [
"attack"
]
}
},
{
"weight": 20,
"add": {
"component_groups": [
"range_attack"
]
}
},
{
"weight": 10
}
]
},
{
"filters": {
"all_of": [
{
"test": "distance_to_nearest_player",
"operator": ">",
"value": 5.0
},
{
"test": "has_target",
"operator": "equals",
"value": true
}
]
},
"randomize": [
{
"weight": 30,
"add": {
"component_groups": [
"attack"
]
}
},
{
"weight": 60,
"add": {
"component_groups": [
"range_attack"
]
}
},
{
"weight": 10
}
]
}
]
},
{
"filters": {
"test": "has_component",
"value": "minecraft:is_sheared"
},
"sequence": [
{
"filters": {
"test": "distance_to_nearest_player",
"operator": "<=",
"value": 5.0
},
"randomize": [
{
"weight": 20,
"add": {
"component_groups": [
"explode"
]
}
},
{
"weight": 60,
"add": {
"component_groups": [
"strong_attack"
]
}
},
{
"weight": 20,
"add": {
"component_groups": [
"strong_range_attack"
]
}
}
]
},
{
"filters": {
"all_of": [
{
"test": "distance_to_nearest_player",
"operator": ">",
"value": 5.0
},
{
"test": "has_target",
"operator": "equals",
"value": true
}
]
},
"randomize": [
{
"weight": 60,
"add": {
"component_groups": [
"strong_range_attack"
]
}
},
{
"weight": 40,
"randomize": [
{
"weight": 30,
"trigger": "rapid_fire"
},
{
"weight": 70,
"add": {
"component_groups": [
"strong_blast"
]
}
}
]
}
]
}
]
}
]
}
]
}
}
}
离线教程下载:
**** Hidden Message *****
这么好的教程没人看,心凉了 顶一下[哔哩_脱单] 我来看看 [哔哩_脱单] 谢谢分享 欧欧欧nice!!!!!!! 666666666666666666666666666666
好[哔哩_doge] 感谢苦力怕还有这样的作者
页: [1]