[JE 1.21]魔咒效果组件的简单应用-实体爆炸弓
本帖最后由 luobojuo 于 2024-6-5 20:56 编辑本教程已写在了中文wiki上:https://zh.minecraft.wiki/w/Minecraft_Wiki:%E6%B2%99%E7%9B%92/%E6%95%99%E7%A8%8B/%E9%AD%94%E5%92%92%E6%95%88%E6%9E%9C%E7%BB%84%E4%BB%B6
b站效果视频:
https://www.bilibili.com/video/BV1zT421v7bW/?spm_id_from=333.999.0.0
本实例让你学会制作一个射中实体就爆炸的爆炸弓。你也可以通过修改相应的函数来增加更多功能。
首先增加一个test.json魔咒文件:
{
"anvil_cost": 4,
"description": {
"text": "123"
},
"effects": {
"minecraft:projectile_spawned": [
{
"effect": {
"type": "minecraft:run_function",
"function": "test:test1"
}
}
],
"minecraft:post_attack": [
{
"affected": "victim",
"effect": {
"type": "minecraft:explode",
"block_interaction": "trigger",
"knockback_multiplier": {
"type": "minecraft:lookup",
"fallback": {
"type": "minecraft:linear",
"base": 1.5,
"per_level_above_first": 0.35
},
"values": [
1.2,
1.75,
2.2
]
},
"large_particle": {
"type": "minecraft:explosion_emitter"
},
"radius": 3.5,
"small_particle": {
"type": "minecraft:explosion_emitter"
},
"sound": "minecraft:block.note_block.banjo"
},
"enchanted": "attacker"
},
{
"affected": "victim",
"enchanted": "attacker",
"effect": {
"type": "minecraft:run_function",
"function": "test:test"
}
}
]
},
"max_cost": {
"base": 50,
"per_level_above_first": 0
},
"max_level": 1,
"min_cost": {
"base": 20,
"per_level_above_first": 0
},
"slots": [
"mainhand"
],
"supported_items": "#minecraft:enchantable/bow",
"weight": 2
}
然后添加两个函数:
test.mcfunction:
say 我被打了
summon minecraft:area_effect_cloud ~ ~ ~ {Duration:200}
advancement revoke @s only test:testtest1.mcfunction:
say 我被射出去了
summon area_effect_cloud ~ ~ ~ {Tags:["test"],Duration:20,Particle:{type:"minecraft:end_rod"},Radius:2.0}
ride @n mount @s
重新进入世界,将加载以上数据文件。现在使用以下命令给自己一把附魔弓,弓上的魔咒其实就是我们自己添加的{{cd|test}}魔咒:
/give @p bow
/enchant @s test:test
然后你就可以试试弓箭的效果。运行过程中,弓箭刚被射出时将传递弓箭实体本身有关的上下文到test1函数中,弓箭射中实体后将传递有关被射中实体的上下文到test函数中。
感谢分享 是时候打破一下良作无人的局面了。 57253427356 感谢分享 感谢分享!
页: [1]