UID1633427性别保密经验 EP铁粒 粒回帖0主题精华在线时间 小时注册时间2024-2-26最后登录1970-1-1
| 本帖最后由 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站效果视频:
本实例让你学会制作一个射中实体就爆炸的爆炸弓。你也可以通过修改相应的函数来增加更多功能。
首先增加一个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:test
复制代码 test1.mcfunction:
- say 我被射出去了
- summon area_effect_cloud ~ ~ ~ {Tags:["test"],Duration:20,Particle:{type:"minecraft:end_rod"},Radius:2.0}
- ride @n[tag=test] mount @s
复制代码
重新进入世界,将加载以上数据文件。现在使用以下命令给自己一把附魔弓,弓上的魔咒其实就是我们自己添加的{{cd|test}}魔咒:
- /give @p bow
- /enchant @s test:test
复制代码
然后你就可以试试弓箭的效果。运行过程中,弓箭刚被射出时将传递弓箭实体本身有关的上下文到test1函数中,弓箭射中实体后将传递有关被射中实体的上下文到test函数中。
|
|