User Tools

Site Tools


zh_cn:tutorial:ores

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
zh_cn:tutorial:ores [2020/01/08 11:56] – created lightcolourzh_cn:tutorial:ores [2021/09/23 00:15] – [在群系中添加矿石] solidblock
Line 1: Line 1:
 ====== 在世界中添加矿石 ====== ====== 在世界中添加矿石 ======
-许多mod会添加自己的矿石,您需要一种将它们放置在现有生物群系中以便玩家寻找的方法。 在本教程中,我们将研究将矿石添加到现有生物群系以及其他mod添加的生物群系。 将矿石添加到生物群系需要执行2个步骤。 +许多模组会添加自己的矿石,您需要找到一种方法以放置在现有生物群系中玩家寻找。在本教程中,我们将研究将矿石添加到现有生物群系以及其他模组添加的生物群系。将矿石添加到生物群系需要2个步骤。 
-   *遍历生物群系注册表以将您的矿石添加到现有物群系中。 +  制作一个 ConfiguredFeature,定义你的矿石方块如何。 
-   *使用RegistryEntryAddedCallback确保您的矿石被添加到mod添加的任何生物群系+  * 使用 [[https://github.com/FabricMC/fabric/pull/1097|Fabric API 中的 Biome Modification API]]将地物添加到生物群系。
  
-我们假设您此时已经创建了自己矿石。 石英矿石将替代我们我们的目标是在整个世界生物群系中生成它。 适当时用您的矿石替换对石英矿石的引用+注意 Biome Modification API 仍是实验性的。如果 API 不起作用考虑 [[?rev=1599388827|mixin 版本]]
  
-==== 在群系中添加矿石 ====+我们假设您此时已经创建了自己的矿石。本教程中,我们使用羊毛方块进行替换。你可以适时将羊毛改成你自己的矿石。 
 +==== 添加到主世界生物群系 ==== 
 +本段落将会在主世界生成矿石。
  
-首先,我们需要创建一种方法来处理生物群系检查其是否为有效生物群系然后添加矿石。 +我们需要创建一个 ConfiguredFeature确保在 ''onInitialize'' 中注册你的 ConfiguredFeature你可以自由地改变一些值以适应你的模组 
-<code java [enable_line_numbers="true"]+ 
-private void handleBiome(Biome biome) +<code java> 
- if(biome.getCategory() !Biome.Category.NETHER && biome.getCategory() != Biome.Category.THEEND) { +public class ExampleMod implements ModInitializer 
- biome.addFeature( +  private static ConfiguredFeature<?, ?> ORE_WOOL_OVERWORLD = Feature.ORE 
-            GenerationStep.Feature.UNDERGROUND_ORES, +    .configure(new OreFeatureConfig( 
-             Biome.configureFeature( +      OreFeatureConfig.Rules.BASE_STONE_OVERWORLD
-                Feature.ORE, +      Blocks.WHITE_WOOL.getDefaultState(), 
-        new OreFeatureConfig( +      9)) // Vein size 
-         OreFeatureConfig.Target.NATURAL_STONE+    .range(new RangeDecoratorConfig( 
-         Blocks.NETHER_QUARTZ_ORE.getDefaultState(), +      // You can also use one of the other height providers if you don't want a uniform distribution 
-                 8 //Ore vein size +      UniformHeightProvider.create(YOffset.aboveBottom(0)YOffset.fixed(64)))) // Inclusive min and max height 
-         ), +    .spreadHorizontally() 
-                Decorator.COUNT_RANGE, +    .repeat(20); // Number of veins per chunk 
-        new RangeDecoratorConfig( + 
-         8, //Number of veins per chunk +  @Override 
-         0, //Bottom Offset +  public void onInitialize(
-         0, //Min y level +    RegistryKey<ConfiguredFeature<?, ?>> oreWoolOverworld = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY, 
-         64 //Max y level +      new Identifier("tutorial", "ore_wool_overworld")); 
-         ))); +    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, oreWoolOverworld.getValue(), ORE_WOOL_OVERWORLD); 
- }+    BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), GenerationStep.Feature.UNDERGROUND_ORES, oreWoolOverworld); 
 +  }
 } }
 </code> </code>
  
-此方法通过提供的生成设置将您的矿石添加到整个世界。 随意更改值适合您mod+=== 结果 === 
 +检查你世界生成结果时,记得要创建新世界。你应该看见羊毛在主世界生成了。你可使用下面命令移除周围的石头方块 
 +<code> 
 +/fill ~-8 0 ~-8 ~8 ~ ~8 minecraft:air replace minecraft:stone 
 +</code> 
 + 
 +{{tutorial:ores.png?800}}
  
 ==== 迭代生物群系注册表 ==== ==== 迭代生物群系注册表 ====
zh_cn/tutorial/ores.txt · Last modified: 2023/12/18 01:03 by solidblock