跳到正文

Cobalt Core

Run commands from items

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。

Run commands from custom item data!

Cobalt core is a datapack that allows for items to run commands from custom data!

To Use:
Enter the command you want to run into the proper custom data path:

{
    "components": {
        "custom_data": {
            "cobalt": {
                "onUse": {
                    "command": "say Hello World!"
                }
            }
        }
    }
}

#
Below are all current uses for Cobalt Core, along with example commands:

onUse: runs on item use when in mainhand (item must have consumable component with consume_seconds:2147483647,animation:"block")

/give @s stick[consumable={consume_seconds:2147483647,animation:"block"},custom_data={cobalt:{onUse:{command:"say Hello world!"}}}]

onShiftUse: runs on item use when in mainhand while sneaking (same requirements as onUse)

/give @s nether_star[consumable={consume_seconds:2147483647,animation:"block"},custom_data={cobalt:{onShiftUse:{command:"say Goodbye world!"}}}]

onAttack: runs upon successfully attacking a mob when in mainhand

/give @s iron_sword[custom_data={cobalt:{onAttack:{command:"effect give @n[nbt={HurtTime:10s},distance=..8] poison"}}}]

onBlock: runs upon successfully blocking damage when held (item must have blocks_attack component (1.21.5+) or be a shield)

/give @s shield[custom_data={cobalt:{onBlock:{command:"execute on attacker at @s run summon lightning_bolt"}}}]

onDamage: runs upon taking damage from a mob when held or worn

/give @s diamond_chestplate[custom_data={cobalt:{onDamage:{command:"execute on attacker run damage @s 2"}}}]

projectile.onHitMob: runs when a thrown or shot projectile from this item hits a mob

/give @s crossbow[custom_data={cobalt:{projectile:{onHitMob:{command:"summon tnt ~ ~ ~ {fuse:0}"}}}}]

projectile.onHitBlock: runs when a thrown or shot projectile from this item hits a block

/give @s bow[custom_data={cobalt:{projectile:{onHitBlock:{command:"execute on origin run tp @s ~ ~ ~"}}}}]

onHold: runs every tick when held or worn

/give @s lantern[custom_data={cobalt:{onHold:{command:"effect give @e[distance=..50] glowing 1 0 true"}}}]

projectile.onSpawn: runs for a single tick when the projectile is spawned

/give @s trident[custom_data={cobalt:{projectile:{onSpawn:{command:"summon lightning_bolt"}}}}]

projectile.onTravel: runs for every tick the projectile is travelling

/give @s bow[custom_data={cobalt:{projectile:{onTravel:{command:"execute on origin run tp @s ~ ~ ~"}}}}]

常见问题

Cobalt Core 支持哪些 Minecraft 版本?

Cobalt Core 支持 Minecraft Java 版 1.21.2–1.21.11,共 10 个版本。下载时注意选择和你游戏版本一致的文件。

Cobalt Core 怎么安装?

新建世界时在「数据包」里把下载的 .zip 拖进去;已有的存档,把文件放进存档目录下的 datapacks 文件夹,进游戏输入 /reload 即可生效。服务器同样放在世界目录的 datapacks 里。

评论

登录后评论和评分

TheCodingFlygon 的其他作品

查看全部 →