Block Condition (Break / Place / Interact)

基本信息

属性 值
父类 BlockConditionHandler(抽象)
子类 ID block.break, block.place, block.interact
事件订阅 Forge MinecraftForge.EVENT_BUS
优先级 LOWEST

注意:源码中 BlockConditionHandler.Interact 虽已实现且 ID 为 block.interact,但 AmazingTrophies.registerConditionHandlers() 未注册该 ID,当前版本无法通过配置加载;下游兼容场景下需自行额外注册。

共享配置字段

字段 类型 默认 含义
block 字符串 当前条目 ID 方块注册名(modid:blockname),找不到则抛 IllegalArgumentException
meta int OreDictionary.WILDCARD_VALUE(32767) damage 值;范围 [0, 32767];-1 或超出范围抛异常

当 meta == 32767 时任何 meta 都会触发;具体 meta 命中时也会顺带触发 wildcard 条目(见 handleEvent 双查)。

过滤细节

  • 玩家为 null 或 FakePlayer 时直接丢弃(避免 build/sponge/ProjectRed 等自动化触发)。
  • Block + meta 作为 BlockMeta 复合键匹配;查询时既查精确 meta 也查 WILDCARD_VALUE 元条目。

子类差异

子类 ID 监听事件 触发细节
block.break BlockEvent.BreakEvent event.getPlayer(), event.block, event.blockMetadata
block.place BlockEvent.PlaceEvent event.player, event.block, event.blockMetadata
block.interact PlayerInteractEvent 仅 action == RIGHT_CLICK_BLOCK 通过;取 world.getBlock(x, y, z) 及对应 meta

JSON 示例

{
  "id": "first_pickaxe",
  "x": 1, "y": 0,
  "icon": { "registryName": "minecraft:stone_pickaxe" },
  "condition": {
    "type": "block.break",
    "block": "minecraft:stone",
    "meta": 0
  }
}

相关条目

源码

src/main/java/glowredman/amazingtrophies/condition/BlockConditionHandler.java