Skip to content

Rewards and Failures

hp-1e edited this page Jul 15, 2026 · 1 revision

Rewards and Failures / 奖励与失败惩罚

Reward methods are available on the gateway builder for completion rewards and on a wave builder for wave rewards.

奖励方法既可以用于顶层网关 Builder 作为通关奖励,也可以用于 WaveBuilder 作为波次奖励。

Reward methods / 奖励方法

Method Result / 结果
addReward(itemId, count[, nbt]) Item stack reward / 物品奖励
addStackListReward(stacks) Multiple item stacks / 多物品栈奖励
addLootTableReward(table, rolls[, description]) Loot table rolls / 战利品表抽取
addEntityLootReward(entity, rolls) Entity loot-table rolls / 实体战利品表抽取
addExperienceReward(xp[, orbSize]) Experience reward / 经验奖励
addCommandReward(command, description) Server command / 服务端命令
addSummonReward(entity, count) Summon entities / 召唤实体
addChancedReward(json, chance) Chanced nested reward / 概率嵌套奖励
addRewardJson(json) Any registered reward codec / 任意已注册奖励 codec

Use namespaced IDs for vanilla or modded content.

原版和模组内容都应使用带命名空间的 ID。

// 原版战利品和实体掉落奖励
wave.addLootTableReward('minecraft:chests/simple_dungeon', 1)
wave.addEntityLootReward('minecraft:zombie', 3)
wave.addReward('minecraft:iron_ingot', 4)

For Minecraft 1.21.1 component-heavy stacks, use addRewardJson when custom components are required. The old NBT overload writes custom data and does not replace native data components.

在 Minecraft 1.21.1 中,如果奖励物品需要自定义数据组件,请使用 addRewardJson。旧 NBT 重载只会写入自定义数据,不能代替原生数据组件。

Failure methods / 失败惩罚方法

Failure actions run when a gateway challenge fails.

当网关挑战失败时会执行失败惩罚。

  • addCommandFailure(command, description)
  • addSummonFailure(entityId, count)
  • addExplosionFailure(strength, fire, blockDamage)
  • addMobEffectFailure(effect, duration[, amplifier])
  • addChancedFailure(json, chance)
  • addFailureJson(json)
// 超时或越界失败时执行的惩罚
builder
  .failOnOutOfBounds(true)
  .addExplosionFailure(2, false, false)
  .addMobEffectFailure('minecraft:slowness', 200, 1)

Raw codec fallback / 原始 codec 兜底

addRewardJson, addFailureJson, and addEntityJson decode through Gateways codec registries. They are the compatibility path for third-party Gateways extensions not represented by a dedicated helper method.

addRewardJsonaddFailureJsonaddEntityJson 会通过 Gateways codec 注册表解码,适用于没有专用辅助方法的第三方 Gateways 扩展。