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

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
zh_cn:tutorial:ores [2021/09/23 00:19] – [结论] solidblockzh_cn:tutorial:ores [2022/08/18 03:25] solidblock
Line 1: Line 1:
-====== 在世界中添加矿石 ======+====== 生成自定义的矿石(1.18.2) ======
 许多模组会添加自己的矿石,您需要找到一种方法以将其放置在现有生物群系中让玩家寻找。在本教程中,我们将研究将矿石添加到现有生物群系以及其他模组添加的生物群系。将矿石添加到生物群系需要2个步骤。 许多模组会添加自己的矿石,您需要找到一种方法以将其放置在现有生物群系中让玩家寻找。在本教程中,我们将研究将矿石添加到现有生物群系以及其他模组添加的生物群系。将矿石添加到生物群系需要2个步骤。
-  * 制作一个 ConfiguredFeature,定义你的矿石方块如何生成。+  * 制作一个 ConfiguredFeature(已配置的地物),定义你的矿石方块如何生成。
   * 使用 [[https://github.com/FabricMC/fabric/pull/1097|Fabric API 中的 Biome Modification API]]以将地物添加到生物群系。   * 使用 [[https://github.com/FabricMC/fabric/pull/1097|Fabric API 中的 Biome Modification API]]以将地物添加到生物群系。
  
Line 10: Line 10:
 本段落将会在主世界生成矿石。 本段落将会在主世界生成矿石。
  
-我们需要创建一个 ConfiguredFeature,确保在 ''onInitialize'' 中注册你的 ConfiguredFeature,你可以自由地改变一些值以适应你的模组。+我们需要创建一个已配置的地物,确保在 ''onInitialize'' 中注册你的已配置的地物,你可以自由地改变一些值以适应你的模组。
  
 <code java> <code java>
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
-  private static ConfiguredFeature<?, ?> ORE_WOOL_OVERWORLD = Feature.ORE +  private static ConfiguredFeature<?, ?> OVERWORLD_WOOL_ORE_CONFIGURED_FEATURE new ConfiguredFeature 
-    .configure(new OreFeatureConfig( +      (Feature.OREnew OreFeatureConfig( 
-      OreFeatureConfig.Rules.BASE_STONE_OVERWORLD+          OreConfiguredFeatures.STONE_ORE_REPLACEABLES
-      Blocks.WHITE_WOOL.getDefaultState(), +          Blocks.WHITE_WOOL.getDefaultState(), 
-      9)) // Vein size +          9))// 矿脉大小 
-    .range(new RangeDecoratorConfig+ 
-      // You can also use one of the other height providers if you don't want a uniform distribution +  public static PlacedFeature OVERWORLD_WOOL_ORE_PLACED_FEATURE = new PlacedFeature
-      UniformHeightProvider.create(YOffset.aboveBottom(0), YOffset.fixed(64)))) // Inclusive min and max height +      RegistryEntry.of(OVERWORLD_WOOL_ORE_CONFIGURED_FEATURE), 
-    .spreadHorizontally() +      Arrays.asList( 
-    .repeat(20); // Number of veins per chunk+          CountPlacementModifier.of(20), // 每个区块的矿脉数量 
 +          SquarePlacementModifier.of()// 水平传播 
 +          HeightRangePlacementModifier.uniform(YOffset.getBottom(), YOffset.fixed(64)) 
 +      )); // 高度
  
   @Override   @Override
   public void onInitialize() {   public void onInitialize() {
-    RegistryKey<ConfiguredFeature<?, ?>> oreWoolOverworld = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY+    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE
-      new Identifier("tutorial", "ore_wool_overworld")); +        new Identifier("tutorial", "overworld_wool_ore"), OVERWORLD_WOOL_ORE_CONFIGURED_FEATURE); 
-    Registry.register(BuiltinRegistries.CONFIGURED_FEATUREoreWoolOverworld.getValue(), ORE_WOOL_OVERWORLD); +    Registry.register(BuiltinRegistries.PLACED_FEATUREnew Identifier("tutorial", "overworld_wool_ore"), 
-    BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), GenerationStep.Feature.UNDERGROUND_ORES, oreWoolOverworld);+        OVERWORLD_WOOL_ORE_PLACED_FEATURE); 
 +    BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), GenerationStep.Feature.UNDERGROUND_ORES, 
 +        RegistryKey.of(Registry.PLACED_FEATURE_KEY, 
 +            new Identifier("tutorial", "overworld_wool_ore")));
   }   }
 } }
Line 46: Line 52:
 本段落将会基于前面的段落添加矿石到下界生物群系。 本段落将会基于前面的段落添加矿石到下界生物群系。
  
-在下界,需要替换的方块和主世界地不同,所以需要把 ''OreFeatureConfig.Rules.BASE_STONE_OVERWORLD'' 替换成 ''OreFeatureConfig.Rules.BASE_STONE_NETHER''+在下界,需要替换的方块和主世界地不同,所以需要把 ''OreConfiguredFeatures.STONE_ORE_REPLACEABLES'' 替换成 ''OreConfiguredFeatures.NETHERRACK''
  
 <code java> <code java>
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
-  private static ConfiguredFeature<?, ?> ORE_WOOL_NETHER = Feature.ORE +  private static ConfiguredFeature<?, ?> NETHER_WOOL_ORE_CONFIGURED_FEATURE new ConfiguredFeature 
-    .configure(new OreFeatureConfig( +      (Feature.OREnew OreFeatureConfig( 
-      OreFeatureConfig.Rules.BASE_STONE_NETHER, // 对于下界,我们使用 OreFeatureConfig.Rules.BASE_STONE_NETHER +          OreConfiguredFeatures.NETHERRACK, // 我们这里使用 OreConfiguredFeatures.NETHERRACK 
-      Blocks.WHITE_WOOL.getDefaultState(), +          Blocks.WHITE_WOOL.getDefaultState(), 
-      9)) +          9)); 
-    .range(new RangeDecoratorConfig+ 
-      UniformHeightProvider.create(YOffset.fixed(0), YOffset.fixed(64)))+  public static PlacedFeature NETHER_WOOL_ORE_PLACED_FEATURE = new PlacedFeature
-    .spreadHorizontally() +      RegistryEntry.of(NETHER_WOOL_ORE_CONFIGURED_FEATURE), 
-    .repeat(20);+      Arrays.asList( 
 +          CountPlacementModifier.of(20), 
 +          SquarePlacementModifier.of(), 
 +          HeightRangePlacementModifier.uniform(YOffset.getBottom(), YOffset.fixed(64))));
  
   @Override   @Override
   public void onInitialize() {   public void onInitialize() {
-    RegistryKey<ConfiguredFeature<?, ?>> oreWoolNether = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN+    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE
-        new Identifier("tutorial", "ore_wool_nether")); +        new Identifier("tutorial", "nether_wool_ore"), NETHER_WOOL_ORE_CONFIGURED_FEATURE); 
-    Registry.register(BuiltinRegistries.CONFIGURED_FEATUREoreWoolNether.getValue(), ORE_WOOL_NETHER); +    Registry.register(BuiltinRegistries.PLACED_FEATUREnew Identifier("tutorial", "nether_wool_ore"), 
-    BiomeModifications.addFeature(BiomeSelectors.foundInTheNether(), GenerationStep.Feature.UNDERGROUND_ORES, oreWoolNether);+        NETHER_WOOL_ORE_PLACED_FEATURE); 
 +    BiomeModifications.addFeature(BiomeSelectors.foundInTheNether(), GenerationStep.Feature.UNDERGROUND_ORES, 
 +        RegistryKey.of(Registry.PLACED_FEATURE_KEY, 
 +            new Identifier("tutorial", "nether_wool_ore")));
   }   }
 } }
Line 73: Line 85:
 本段落将会基于主世界的代码添加矿石到末地生物群系。 本段落将会基于主世界的代码添加矿石到末地生物群系。
  
-在末地,基础方块是末地石,所以需要把 ''OreFeatureConfig.Rules.BASE_STONE_OVERWORLD'' 替换成 ''new BlockMatchRuleTest(Blocks.END_STONE)''+在末地,基础方块是末地石,所以需要把 ''OreConfiguredFeatures.STONE_ORE_REPLACEABLES'' 替换成 ''new BlockMatchRuleTest(Blocks.END_STONE)''
  
 <code java> <code java>
 public class ExampleMod implements ModInitializer { public class ExampleMod implements ModInitializer {
-  private static ConfiguredFeature<?, ?> ORE_WOOL_END = Feature.ORE +  private static ConfiguredFeature<?, ?> END_WOOL_ORE_CONFIGURED_FEATURE new ConfiguredFeature 
-    .configure(new OreFeatureConfig( +      (Feature.OREnew OreFeatureConfig( 
-      new BlockMatchRuleTest(Blocks.END_STONE), // 在末地生物群系,基础方块是末地石 +          new BlockMatchRuleTest(Blocks.END_STONE), // 我们这里使用 new BlockMatchRuleTest(Blocks.END_STONE) 
-      Blocks.WHITE_WOOL.getDefaultState(), +          Blocks.WHITE_WOOL.getDefaultState(), 
-      9)) +          9)); 
-    .range(new RangeDecoratorConfig+ 
-      UniformHeightProvider.create(YOffset.fixed(0), YOffset.fixed(64)))+  public static PlacedFeature END_WOOL_ORE_PLACED_FEATURE = new PlacedFeature
-    .spreadHorizontally() +      RegistryEntry.of(END_WOOL_ORE_CONFIGURED_FEATURE), 
-    .repeat(20);+      Arrays.asList( 
 +          CountPlacementModifier.of(20), 
 +          SquarePlacementModifier.of(), 
 +          HeightRangePlacementModifier.uniform(YOffset.getBottom(), YOffset.fixed(64))));
  
   @Override   @Override
   public void onInitialize() {   public void onInitialize() {
-    RegistryKey<ConfiguredFeature<?, ?>> oreWoolEnd = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY+    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE
-        new Identifier("tutorial", "ore_wool_end")); +        new Identifier("tutorial", "end_wool_ore"), END_WOOL_ORE_CONFIGURED_FEATURE); 
-    Registry.register(BuiltinRegistries.CONFIGURED_FEATUREoreWoolEnd.getValue(), ORE_WOOL_END); +    Registry.register(BuiltinRegistries.PLACED_FEATUREnew Identifier("tutorial", "end_wool_ore"), 
-    BiomeModifications.addFeature(BiomeSelectors.foundInTheEnd(), GenerationStep.Feature.UNDERGROUND_ORES, oreWoolEnd);+        END_WOOL_ORE_PLACED_FEATURE); 
 +    BiomeModifications.addFeature(BiomeSelectors.foundInTheEnd(), GenerationStep.Feature.UNDERGROUND_ORES, 
 +        RegistryKey.of(Registry.PLACED_FEATURE_KEY, 
 +            new Identifier("tutorial", "end_wool_ore")));
   }   }
 } }
zh_cn/tutorial/ores.txt · Last modified: 2023/12/18 01:03 by solidblock