那么,让我们按照顺序完成这个任务吧! 既然是一把剑,那么首先在components里添加:
- "tag:minecraft:sword"
伤害是26,创造模式下不能拿着它破坏方块,有附魔闪光。这3个条件分别代表3个组件,继续添加:
- "minecraft:damage": 26,
- "minecraft:can_destroy_in_creative": false,
- "minecraft:glint": true
附魔能力是70,可以用minecraft:enchantable解决。
- "minecraft:enchantable":{"value":70,"slot":"sword"}
耐久是5000,掉耐久几率是50%,可以用minecraft:durability解决。
- "minecraft:durability":{"damage_chance":0.5,"max_durability":5000}
接下来的一些功能有些复杂,我们先看最后的“不会刷新掉,可以放在副手”,可以用2个组件解决。
- "minecraft:should_despawn": false
- "minecraft:allow_off_hand": true
然后,让我们看看题目里的隐藏要求。既然是剑,那么应该是破坏蜘蛛网和竹子很快,而且是装备,所以要装备在手上,最大堆叠数量应该是1。后者可以很简单地解决,前者则需要一点点功夫。剑没有效率附魔,所以use_efficiency应该是false。然后还得定义一个耐久下降的事件。
- "minecraft:hand_equipped":true,"minecraft:max_stack_size":1,"minecraft:digger":{"use_efficiency":false,"destroy_speeds":[{"block":"minecraft:web","speed":30,"on_dig":{"event":"damage"}},{"block":"minecraft:bamboo","speed":30,"on_dig":{"event":"damage"}}]}
- //上面是组件,下面是事件
- "damage":{"damage":{"type":"durability","amount":1,"target":"self"}}
还有,剑应该能被修复,而且应该放在创造模式物品栏的“剑”这一类里。新版本中,同类自定义物品的修复无需额外组件。
- "minecraft:creative_category": {"parent":"itemGroup.name.sword"}
最后是最难的地方。“潜行打到生物会造成范围5格伤害并掉5点耐久,潜行打破方块会有4分之1几率给持有者清除所有状态效果,然后增加状态效果(力量5、急迫5,都是30秒),然后掉5点耐久。” 这一堆东西可以用一个组件搞定,主要是事件怎么写。组件如下。
- "minecraft:weapon":{
- "on_hit_block": "destroy",
- "on_hurt_entity": "hurt",
- "on_not_hurt_entity": "damage"
- } //注:1.20.40.21中移除了这个组件。
然后再运用sequence和randomize写一下事件。这个有点长,为了便于理解,我还没有像上面一样压缩代码,所以用折叠块折起来。 - "hurt": {
- "sequence": [
- {
- "damage": {
- "type": "durability",
- "amount": 5,
- "target": "self"
- }
- },
- {
- "condition": "q.is_sneaking",
- "run_command": {
- "command": "damage @e[r=5,rm=0.1] 26 entity_attack entity @p"
- }
- }
- ]
- },
- "destroy": {
- "randomize": [
- {
- "weight": 3,
- "sequence": [
- {
- "run_command": {
- "command": "effect @p clear"
- }
- },
- {
- "run_command": {
- "command": [
- "effect @p strength 30 4",
- "effect @p haste 30 4"
- ]
- }
- },
- {
- "damage": {
- "type": "durability",
- "amount": 5,
- "target": "self"
- }
- }
- ]
- },
- {
- "weight": 1
- }
- ]
- }
|
最后,把以上写的一大堆东西结合在一起,成为一个文件,游戏内就可以起效了!
|