HiveDecorator
基本信息
| 属性 | 值 |
|---|---|
| 类 | forestry.apiculture.worldgen.HiveDecorator(abstract class,只有 static 方法) |
| 触发时机 | Forge PopulateChunkEvent 自定义事件类型 FORESTRY_HIVES |
| 放置的方块 | Forestry:beehives(BlockBeehives),metadata 1-7 |
| 注册表 | forestry.apiculture.worldgen.HiveRegistry(实例挂在 PluginApiculture.hiveRegistry) |
[!WARNING] 已订正(源码回核)
- 注册键全错(幻觉模式 1/4)。原文写
forestry.bee.sw.comb/forestry.bee.sw.meadow等 —— 源码里不存在这些字符串。真实注册键是IHiveRegistry的常量:"Forestry:forest"、"Forestry:meadows"、"Forestry:desert"、"Forestry:jungle"、"Forestry:end"、"Forestry:snow"、"Forestry:swamp"(api/apiculture/hives/IHiveRegistry.java:15-21)。注意是meadows不是meadow。- 生成方块错。原文写
BlockForestryHive—— 该类不存在。实际放置的是Forestry:beehives方块,metadata 取HiveDescription.getMeta()(1-7)(apiculture/worldgen/HiveDescription.javagetBlock()/getMeta())。- 「生成类型」分类错:
HiveDecorator是 abstract 且全静态方法,不存在populateChunk/populateChunkRetroGen实例方法。真实入口是decorateHives(IChunkProvider, World, Random, int chunkX, int chunkZ, boolean),通过TerrainGen.populate(..., EVENT_TYPE)挂到自定义PopulateChunkEvent.Populate.EventType.FORESTRY_HIVES。- 「genChance 0-1 概率」错。
HiveDecorator.genHive的判定是hive.genChance() * Config.getBeehivesAmount() < rand.nextFloat() * 100.0f——genChance量纲是百分比(1.0~4.0),右端是rand.nextFloat() * 100,不是 0-1。- 「Y=3-62」编造。源码里没有任何 3~62 的高度限制。Y 由
HiveGen.getYForHive从world.getHeightValue(x, z)向下逐格回退到地面得出(apiculture/worldgen/HiveGenGround.java:35-45),树型蜂巢走HiveGenTree。- 原文遗漏:每个蜂巢在每区块最多尝试 4 次落点(
for (int tries = 0; tries < 4; tries++)),成功即return,因此每区块最多 1 个蜂巢(原文这条结论是对的,但漏了 4 次尝试与群系/温湿度前置校验)。
生成机制
decorateHives取PluginApiculture.hiveRegistry.getHives()全部蜂巢- 若
Config.generateBeehivesDebug为真 → 走decorateHivesDebug(对区块内 16×16 每格尝试所有匹配蜂巢,调试用) - 否则
Collections.shuffle打乱顺序,依次调用genHive,任一成功即返回 genHive判定genChance * Config.getBeehivesAmount() < rand.nextFloat() * 100.0f则跳过- 校验
hive.isGoodBiome(biome)与hive.isGoodHumidity(humidity)(湿度由biome.rainfall推出) - 最多 4 次随机落点,每次走
tryGenHive:getYForHive→canReplace→isGoodTemperature→isValidLocation→setHive
蜂巢类型(HiveDescription)
| 蜂巢 | 注册键 | 方块 metadata | genChance | 生成条件 | 地面/树木 |
|---|---|---|---|---|---|
| Forest | Forestry:forest |
1 | 3.0 | 非地狱群系 + 温湿度在 FOREST 容忍范围 | tree() |
| Meadows | Forestry:meadows |
2 | 1.0 | 同上 | ground(dirt, grass) |
| Desert | Forestry:desert |
3 | 1.0 | 同上 | ground(dirt, grass, sand, sandstone) |
| Jungle | Forestry:jungle |
4 | 4.0 | 同上 | tree() |
| End | Forestry:end |
5 | 4.0 | 必须 END 群系(覆写 isGoodBiome) |
ground(end_stone) |
| Snow | Forestry:snow |
6 | 2.0 | 同上;生成后在上方补一层雪 | ground(dirt, grass, snow) |
| Swamp | Forestry:swamp |
7 | 2.0 | 同上 | ground(dirt, grass) |
掉落(PluginApiculture.registerBeehiveDrops)
| 蜂巢 | 掉落蜜蜂(权重) | 掉落蜂巢脾 |
|---|---|---|
| Forest | FOREST 80(ignobleShare 0.7)、FOREST 雨抗 8、VALIANT 3 | EnumHoneyComb.HONEY |
| Meadows | MEADOWS 80(0.7)、VALIANT 3 | EnumHoneyComb.HONEY |
| Desert | MODEST 80(0.7)、VALIANT 3 | EnumHoneyComb.PARCHED |
| Jungle | TROPICAL 80(0.7)、VALIANT 3 | EnumHoneyComb.SILKY |
| End | ENDED 90 | EnumHoneyComb.MYSTERIOUS |
| Snow | WINTRY 80(0.5)、VALIANT 3 | EnumHoneyComb.FROZEN |
| Swamp | MARSHY 80(0.4)、VALIANT 3 | EnumHoneyComb.MOSSY |
原文的「蜂巢 → 掉落蜂巢脾」一列 7 项全部正确(已逐条核对),此处补上了原文缺失的权重与
ignobleShare。
生成条件
- 落点方块必须
canReplace:材质可替换且非液体,或空气,或Material.plants(HiveGen.canReplace) - 落点下方(
y-1)材质必须在该蜂巢的groundMaterials中,或(树型)满足HiveGenTree的树木条件 - 放置后调用
hiveBlock.onBlockAdded,非 debug 模式再调hive.postGen(SNOW 会在y+1补Blocks.snow_layer) - 蜂巢方块硬度 1.0(
BlockBeehives.java:51),破坏后产出TileSwarm蜂群
生成概率
- 每蜂巢有
genChance(1.0~4.0,单位:%) - 判定式:
genChance * Config.getBeehivesAmount() < rand.nextFloat() * 100.0f→ 跳过 Config.getBeehivesAmount()返回配置项generateBeehivesAmount(core/config/Config.java:158-160)Config.generateBeehivesDebug为真时跳过概率判定,对区块内每格强行尝试
第三方 mod 集成
- IC2:无直接集成
- BuildCraft:无直接集成
相关条目
- Alveary - 玩家建造的蜂箱多方块(
Forestry:alveary,与本条目的Forestry:beehives是不同方块)