Firestone Effect

基本信息

属性 值
来源物品 ItemFirestone(railcraft:firestone)
分类 特殊物品(Raw Firestone)
可堆叠 否
可修复 否

物品特性

自定义实体

Firestone 物品在世界中会以 EntityItemFirestone 实体形式存在(而非普通的 EntityItem)。

@Override
public boolean hasCustomEntity(ItemStack stack) {
    return true;
}

@Override
public EntityItemFirestone createEntity(World world, Entity original, ItemStack stack) {
    return FirestoneTools.createEntityItem(world, original, stack);
}

触发机制(FirestoneTools)

trySpawnFire

当 Firestone 物品实体被拿起或放置时,会尝试在周围生成火焰:

public static boolean trySpawnFire(World world, BlockPos pos, @Nullable ItemStack stack, @Nullable EntityPlayer holder)

条件:

  • 目标位置可以被点燃(canBurn)
  • 随机 chance

canBurn

检测方块是否可以被点燃,典型目标包括:

  • 木头类方块
  • 羊毛
  • 树叶
  • 草类
  • 藤蔓

spawnFire

在指定位置生成火焰方块,并播放火焰音效。

源码依据

  • ItemFirestone.java - 物品定义
  • FirestoneTools.java - 火焰生成逻辑
  • EntityItemFirestone.java - 自定义掉落物实体