Enchantment Creator
概览
Enchantment Creator 为你的服务器添加真正的附魔,完全通过 TypeWriter 网页面板定义。它们注册在 Minecraft 自带的附魔注册表中,位于 typewriter 命名空间下,因此会像原版附魔一样出现在物品上、铁砧里和附魔台中,无需任何资源包或额外插件。
你在定义条目中描述附魔(名称、颜色、支持的物品、最高等级、花费、生效槽位),然后赋予它行为。有两种方式:标准定义会在附魔物品被穿戴或手持时运行 TypeWriter 触发器;自定义定义则列出若干机制,每个机制对一种游戏事件(攻击、破坏方块、射箭、摔落伤害……)作出反应并运行动作。该扩展自带 70 多个现成的动作条目(生命偷取、连锁挖矿、追踪箭、冰霜护甲……),可供你接入机制。
功能
- 真正的附魔 — 注册在服务器的附魔注册表中,带有彩色名称、最高等级、铁砧花费、权重和附魔台花费。
- 两种定义类型 — 基于触发器(
enchantment_definition)或基于机制(custom_enchantment_definition)。 - 16 种游戏事件 — 攻击、防御、破坏方块、射箭、弹射物命中、摔落伤害、物品损坏、装备盔甲、移动、潜行、疾跑等。
- 70 多种现成效果 — 盔甲、弓、战斗、工具和特殊动作,每个都有自己的字段。
- 附魔书 — 通过动作或命令发放附魔书,可自定义名称和 lore。
- 世界集成 — 附魔书会出现在生成的战利品箱中(
treasureChance)和图书管理员的交易中(tradeChance)。 - 附魔台与铁砧 — 自定义附魔可由附魔台提供,限定于受支持的物品,并可在铁砧中设为互斥。
- 原版黑名单 — 从附魔台中移除指定的原版附魔。
- 按机制设置概率和等级 — 让机制只在一定比例的时间运行,或仅在某个附魔等级运行。
- 客户端粒子 — 仅对玩家本人显示的粒子动作。
安装
- 使用 Paper 1.21 或更高版本的服务器,并使用 Java 21。该扩展通过服务器的注册表构建附魔,因此无法在更旧的版本上工作。
- 确认已安装 TypeWriter 的 Basic 扩展(参见 TypeWriter 文档)。
- 将 Enchantment Creator 的 JAR 放入
plugins/Typewriter/extensions/并重启服务器。
不需要其他插件。
快速上手
创建一个名为 “Vampiric Strike” 的剑附魔,让持有者每次命中时回复生命值:
- 在 TypeWriter 网页面板中,打开一个**清单(manifest)**页面,添加一个 Custom Enchantment Definition。
- 将
name设为Vampiric Strike,displayName设为Vampiric Strike,nameColor设为dark_red,maxLevel设为3,并将各种剑的材质添加到supportedItems。 - 在一个**序列(sequence)**页面上添加一个 Lifesteal 动作条目,并将
healPercentage设为0.2。 - 回到定义中,在
mechanics里添加一个机制。将event设为PLAYER_ATTACK,并在actions中选择 Lifesteal 条目。 - 添加一个 Give Enchantment Book 动作,在
customEnchantment中选择你的定义,并设置level。发布。 - 触发该动作即可获得附魔书,或者在添加 Enchantment Command Manifest 之后运行
/enchantcreator give <player> Vampiric_Strike 2。在铁砧中将附魔书与剑合并,然后攻击一只生物。
效果本身不会随附魔等级自动增强。若要让 3 级更强,请添加多个机制,将 runOnLevel 分别设为 1、2 和 3,每个机制运行具有不同数值的动作。runOnLevel 为 0 表示所有等级。
工作原理
扩展每 5 tick(四分之一秒)检查一次每位在线玩家,以得知他们正在使用你的哪些附魔。只有主手、副手和盔甲会被计入,并且只计入材质在 supportedItems 中的物品。找到的最高等级即为所用的等级。因此,从装备物品到其效果开始生效之间可能会有短暂的延迟。
两种定义类型的工作方式不同:
- 标准定义(
enchantment_definition)会运行当前等级对应的activeTriggers。开启cooldownEnabled时,在附魔生效期间它们会每隔cooldown再次运行;关闭时,它们在附魔变为生效时运行一次。inactiveTriggers在附魔停止生效时运行。criteria必须通过。 - 自定义定义(
custom_enchantment_definition)会在匹配的游戏事件发生时运行其机制。
动作条目会读取触发它们的游戏事件。只有在机制中使用的事件与其编写时所针对的事件相符时,动作才会起作用(例如,Vein Miner 只在 BLOCK_BREAK 上有效)。
附魔事件
机制的 event 为以下之一:
| 事件 | 触发时机 |
|---|---|
PLAYER_ATTACK | 玩家直接击中一个实体。 |
PLAYER_DEFEND | 玩家被实体伤害。 |
SHIELD_BLOCK | 玩家在用盾牌格挡时被击中。 |
BLOCK_BREAK | 玩家破坏一个方块。 |
BOW_SHOOT | 玩家射出弓或弩。 |
PROJECTILE_HIT | 玩家射出的弹射物击中了某物。 |
ITEM_CONSUME | 玩家进食或饮用。 |
PLAYER_DEATH | 玩家死亡。 |
PLAYER_INTERACT | 玩家右键或左键点击。 |
ARMOR_EQUIP | 玩家装备或卸下盔甲。 |
ITEM_DAMAGE | 物品损失耐久度。 |
FALL_DAMAGE | 玩家受到摔落伤害。 |
ENVIRONMENTAL_DAMAGE | 玩家受到并非由实体造成的伤害(摔落伤害时也会触发)。 |
PLAYER_MOVE | 玩家移动到另一个方块(每四个 tick 检查一次)。 |
SNEAK | 玩家开始潜行。 |
SPRINT | 玩家开始疾跑。 |
当玩家是直接的伤害来源时(即近战攻击),会触发 PLAYER_ATTACK。箭矢造成的伤害是由箭矢造成的,因此在当前版本中不会触发 PLAYER_ATTACK。因此,读取伤害事件的箭矢动作(下文已标注)只会对直接命中生效。
现成动作
所有动作条目都在机制(actions)中使用,或者在任意序列中使用。每个动作都有标准的 criteria、modifiers 和 triggers 字段,以及它自己的字段:请参见各条目页面。事件一列说明该动作需要机制的哪个 event。
| 分组 | 动作 | 事件 |
|---|---|---|
| 战斗 | Armor Pierce, Beheading, Bleed, Blindness Strike, Cleave, Disarm, Executioner, Freeze Strike, Lifesteal, Lightning Strike, Poison Strike, Silence, Vampiric Aura, Wither Strike | PLAYER_ATTACK |
| 盔甲,被击中时 | Deflect, Enlightened Armor, Evasion, Frozen Armor, Molten Armor, Regeneration Aura, Resistance Aura, Thorns Advanced, Toxic Aura, Voodoo Armor, Gearing | PLAYER_DEFEND |
| 盔甲,伤害 | Angel Wings | FALL_DAMAGE |
| 盔甲,伤害 | Implosion Armor, Curse of Vulnerability | 任意伤害事件(PLAYER_DEFEND、FALL_DAMAGE、ENVIRONMENTAL_DAMAGE) |
| 盔甲,装备 | Anti Knockback, Health Boost | ARMOR_EQUIP |
| 盔甲,耐久 | Hardened Armor | ITEM_DAMAGE |
| 弓,射击 | Homing Arrow, Volley Arrow | BOW_SHOOT |
| 弓,命中 | Explosive Arrow, Teleport Arrow | PROJECTILE_HIT |
| 弓,伤害 | Ender Arrow, Healing Arrow, Lightning Arrow, Piercing Shot, Pull Arrow, Push Arrow, Sniper Arrow, Venom Arrow, Web Arrow, Wither Arrow | PLAYER_ATTACK(仅直接命中,见注释) |
| 工具 | Area Miner, Auto Smelt, Experience Boost, Haste, Indestructible, Magnet, Oxygenate, Spawners Silk Touch, Telepathy, Timber, Treasure Hunter, Vein Miner | BLOCK_BREAK |
| 工具 | Bedrock Breaker, Green Thumb, Night Vision | PLAYER_INTERACT |
| 工具 | Agricultural Harvest | BLOCK_BREAK;它会收获被破坏方块周围的成熟作物(最多 radius 8) |
| 特殊 | Aquatic Speed, Feeder, Lava Walker | PLAYER_MOVE |
| 特殊 | Elytra Boost, Launch | PLAYER_INTERACT |
| 特殊 | Curse of Sluggishness | PLAYER_ATTACK |
| 特殊 | Elytra Shield | ENVIRONMENTAL_DAMAGE |
| 特殊 | Soulbound | PLAYER_DEATH |
| 实用 | Client Particle Effect, Give Enchantment Book | 任意 |
命令
该命令是由你创建的 Enchantment Command Manifest 条目。它的名称、权限和消息都是该条目的字段;此处显示的是默认值。
| 命令 | 说明 |
|---|---|
/enchantcreator give <player> <enchant> [level] | 向在线玩家发放一本附魔书。<enchant> 为条目的 name 或 displayName,以下划线代替空格。等级默认为 1。 |
权限
| 权限 | 授予 |
|---|---|
enchantcreator.admin | /enchantcreator give(条目的 adminPermission 字段)。 |
条目
75 个条目,由扩展源码生成。
动作71
- Agricultural Harvest ActionOptimized action for harvesting crops in an AOE, replanting immediately, and merging drops.
- Angel Wings ActionReduces or completely negates fall damage
- Anti Knockback ActionProvides knockback resistance when equipped
- Aquatic Speed ActionDrastically increases movement speed underwater (Dolphin's Grace)
- Area Miner ActionMines blocks in a 3x3 area based on the block broken
- Armor Pierce ActionIgnores armor calculations during melee combat
- Auto Smelt ActionAutomatically smelts mined blocks and yields slightly more experience
- Bedrock Breaker ActionExtremely rare chance to successfully mine Bedrock when left-clicking it
- Beheading ActionHas a chance to drop the victim's head on kill
- Bleed ActionApplies a bleeding effect over time to the target
- Blindness Strike ActionBlinds the target struck
- Cleave ActionDeals area-of-effect (AoE) damage to enemies around the target
- Client Particle EffectRender a Typewriter-aware client particle effect
- Curse of Sluggishness ActionCurse: Applies Slowness and Weakness to the user when attacking
- Curse of Vulnerability ActionCurse: Multiplies all damage taken by the player
- Deflect ActionChance to deflect incoming projectiles back at the attacker
- Disarm ActionForces the attacked player to drop the item in their main hand
- Elytra Boost ActionGives a periodic boost while gliding with Elytra when right-clicking
- Elytra Shield ActionReduces kinetic damage taken from flying into walls
- Ender Arrow ActionDeals massive bonus true damage to End mobs (Enderman, Shulker, Dragon, Endermite)
- Enlightened Armor ActionHas a chance to heal you when attacked
- Evasion ActionGives a chance to completely dodge and cancel incoming damage
- Executioner ActionHas a chance to instantly kill targets below a certain health threshold
- Experience Boost ActionMined blocks drop extra experience
- Explosive Arrow ActionCauses a projectile to explode on impact without breaking blocks
- Feeder ActionPassively restores food while walking
- Freeze Strike ActionSlows and freezes the target
- Frozen Armor ActionSlows and freezes the attacker when they strike you
- Gearing ActionGrants brief speed when hit
- Give Enchantment BookGive a book with a custom enchantment
- Green Thumb ActionPassively bone-meals nearby crops when right-clicking
- Hardened Armor ActionHas a chance to ignore durability loss
- Haste ActionPassively grants Haste while breaking blocks
- Healing Arrow ActionHeals the target instead of damaging them
- Health Boost ActionGrants extra maximum health when equipped
- Homing Arrow ActionModifies a shot arrow to magnetically track the nearest enemy
- Implosion Armor ActionTriggers a massive shockwave when your health drops critically low
- Indestructible ActionHas a chance to repair the tool instead of taking damage when mining
- Launch ActionLaunches the player forward when right clicking with the item
- Lava Walker ActionFreezes lava under your feet into basalt temporarily
- Lifesteal ActionHeals the player based on the damage dealt
- Lightning Arrow ActionStrikes lightning where the arrow hits
- Lightning Strike ActionStrikes lightning on the hit target
- Magnet ActionSucks nearby items towards the player when mining
- Molten Armor ActionSets the attacker on fire when they strike you
- Night Vision ActionApplies Night Vision when interacting with the tool
- Oxygenate ActionRestores breath while breaking blocks underwater
- Piercing Shot ActionCauses the arrow to act as true damage, ignoring armor
- Poison Strike ActionPoisons the target struck
- Pull Arrow ActionPulls the struck target towards the shooter
- Push Arrow ActionInflicts massive knockback to the struck target
- Regeneration Aura ActionGrants passive regeneration when attacked
- Resistance Aura ActionGrants a defensive buff (resistance) when attacked in combat
- Silence ActionSilences the target, applying severe mining fatigue and weakness to prevent them from fighting back effectively
- Sniper Arrow ActionIncreases damage based on the distance the arrow traveled
- Soulbound ActionKeeps the enchanted item in your inventory upon death
- Spawners Silktouch ActionAllows the player to mine and collect Mob Spawners
- Telepathy ActionPlaces mined blocks and items directly into your inventory
- Teleport Arrow ActionTeleports the shooter to the arrow's impact location
- Thorns Advanced ActionReflects a percentage of incoming melee damage back to the attacker
- Timber ActionChops down an entire tree by breaking its bottom log
- Toxic Aura ActionEmits a toxic cloud, poisoning nearby enemies when you take heavy damage
- Treasure Hunter ActionMining simple blocks like Dirt or Stone has a chance to drop Emeralds
- Vampiric Aura ActionHeals all nearby allies when an enemy is killed
- Vein Miner ActionMines a vein of connected identical ores
- Venom Arrow ActionPoisons the target struck by the arrow
- Volley Arrow ActionShoots additional arrows in a cone shape
- Voodoo Armor ActionHas a chance to apply Weakness to the attacker
- Web Arrow ActionEncases the target in a temporary cobweb
- Wither Arrow ActionApplies wither effect to the target struck by the arrow
- Wither Strike ActionApplies wither effect to the target struck
命令1
- Enchantment Command ManifestAdmin command for giving custom enchantment books
清单3
- Custom Enchantment DefinitionDefines a custom enchantment with modular mechanics
- Enchantment DefinitionDefines a custom enchantment
- Vanilla Enchantment Blacklist DefinitionBlacklist vanilla enchantments from the enchanting table
故障排查
效果没有任何作用。 动作必须与机制的 event 相匹配(见上表):读取方块破坏事件的动作在 PLAYER_ATTACK 上不会有任何作用。物品必须在 supportedItems 中,且被手持或作为盔甲穿戴,并且机制的 criteria、chance 和 runOnLevel 都必须通过。runOnLevel 为 2 的机制仅在最高等级恰好为 2 时才会运行。
游戏中缺少该附魔。 定义会在扩展启动时、玩家加入时以及发放附魔书时注册。请在控制台中检查是否有 Failed to reflectively register 或 Failed to register enchantments during pre-login,并确认服务器为 Paper 1.21 或更高版本。
附魔书无法应用到我的物品上。 在铁砧中,附魔书只能应用于 supportedItems 中列出的物品。在彼此的 exclusiveWith 中列出的两个附魔无法合并:铁砧的结果会被移除。这种互斥仅在铁砧中生效。
玩家在附魔台中始终看不到我的附魔。 在附魔台中,weight 被当作百分比使用:1 表示每次抽取约有 1% 的概率。请调高它,或设置 treasureChance 和 tradeChance,通过战利品和图书管理员发放附魔书。weight 为 0 会禁用附魔台的提供。
/enchantcreator give 提示该附魔未知。 名称会与条目的 name 或 displayName 进行匹配,转换为小写并将空格替换为下划线。请使用条目中的确切名称,并先发布页面。
原版附魔仍然出现。 黑名单只会移除附魔台的提供;铁砧、战利品和交易不受影响。如果名称无效,控制台会报告 Unable to resolve vanilla enchantments for blacklist。