zh_cn:tutorial:ores
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
zh_cn:tutorial:ores [2021/09/23 00:12] – [在世界中添加矿石] solidblock | zh_cn:tutorial:ores [2022/08/18 03:25] – solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
许多模组会添加自己的矿石,您需要找到一种方法以将其放置在现有生物群系中让玩家寻找。在本教程中,我们将研究将矿石添加到现有生物群系以及其他模组添加的生物群系。将矿石添加到生物群系需要2个步骤。 | 许多模组会添加自己的矿石,您需要找到一种方法以将其放置在现有生物群系中让玩家寻找。在本教程中,我们将研究将矿石添加到现有生物群系以及其他模组添加的生物群系。将矿石添加到生物群系需要2个步骤。 | ||
- | * 制作一个 ConfiguredFeature,定义你的矿石方块如何生成。 | + | * 制作一个 ConfiguredFeature(已配置的地物),定义你的矿石方块如何生成。 |
* 使用 [[https:// | * 使用 [[https:// | ||
Line 7: | Line 7: | ||
我们假设您此时已经创建了自己的矿石。本教程中,我们使用羊毛方块进行替换。你可以适时将羊毛改成你自己的矿石。 | 我们假设您此时已经创建了自己的矿石。本教程中,我们使用羊毛方块进行替换。你可以适时将羊毛改成你自己的矿石。 | ||
- | ==== 在群系中添加矿石 | + | ==== 添加到主世界生物群系 |
+ | 本段落将会在主世界生成矿石。 | ||
- | 首先,我们需要创建一种方法来处理生物群系,检查其是否为有效的生物群系,然后添加矿石。 | + | 我们需要创建一个已配置的地物,确保在 '' |
- | <code java [enable_line_numbers=" | + | |
- | 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( | + | |
- | | + | |
- | | + | OreConfiguredFeatures.STONE_ORE_REPLACEABLES, |
- | | + | Blocks.WHITE_WOOL.getDefaultState(), |
- | new OreFeatureConfig( | + | 9)); // 矿脉大小 |
- | OreFeatureConfig.Target.NATURAL_STONE, | + | |
- | | + | public static PlacedFeature OVERWORLD_WOOL_ORE_PLACED_FEATURE = new PlacedFeature( |
- | | + | |
- | ), | + | |
- | | + | |
- | new RangeDecoratorConfig( | + | |
- | 8, //Number of veins per chunk | + | |
- | 0, //Bottom Offset | + | |
- | 0, //Min y level | + | |
- | 64 //Max y level | + | @Override |
- | ))); | + | public void onInitialize() { |
- | } | + | |
+ | new Identifier(" | ||
+ | | ||
+ | | ||
+ | BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), | ||
+ | | ||
+ | new Identifier(" | ||
+ | } | ||
} | } | ||
</ | </ | ||
- | 此方法通过提供的生成设置将您的矿石添加到整个世界。 | + | === 结果 === |
+ | 检查你的世界生成结果时,记得要创建新世界。你应该看见羊毛在主世界生成了。你可以使用下面的命令移除周围的石头方块。 | ||
+ | < | ||
+ | /fill ~-8 0 ~-8 ~8 ~ ~8 minecraft: | ||
+ | </ | ||
- | ==== 迭代生物群系注册表 ==== | + | {{tutorial: |
- | 接下来,我们需要处理已注册的所有生物群系以及将来将要注册的所有生物群落(由其他模块添加)。 我们首先遍历当前注册表,然后注册一个侦听器,以供将来添加。 | + | ==== 添加到下界生物群系 |
+ | 本段落将会基于前面的段落添加矿石到下界生物群系。 | ||
- | <code java [enable_line_numbers=" | + | 在下界,需要替换的方块和主世界地不同,所以需要把 '' |
- | @Override | + | |
- | public void onInitialize() { | + | |
- | //Loop over existing biomes | + | |
- | Registry.BIOME.forEach(this:: | + | |
- | //Listen for other biomes being registered | + | <code java> |
- | RegistryEntryAddedCallback.event(Registry.BIOME).register((i, identifier, biome) -> handleBiome(biome)); | + | public class ExampleMod implements ModInitializer { |
+ | private static ConfiguredFeature<?, | ||
+ | (Feature.ORE, | ||
+ | OreConfiguredFeatures.NETHERRACK, | ||
+ | | ||
+ | 9)); | ||
+ | |||
+ | public static PlacedFeature NETHER_WOOL_ORE_PLACED_FEATURE = new PlacedFeature( | ||
+ | RegistryEntry.of(NETHER_WOOL_ORE_CONFIGURED_FEATURE), | ||
+ | Arrays.asList( | ||
+ | CountPlacementModifier.of(20), | ||
+ | SquarePlacementModifier.of(), | ||
+ | HeightRangePlacementModifier.uniform(YOffset.getBottom(), | ||
+ | |||
+ | @Override | ||
+ | public void onInitialize() { | ||
+ | | ||
+ | new Identifier(" | ||
+ | Registry.register(BuiltinRegistries.PLACED_FEATURE, | ||
+ | NETHER_WOOL_ORE_PLACED_FEATURE); | ||
+ | BiomeModifications.addFeature(BiomeSelectors.foundInTheNether(), GenerationStep.Feature.UNDERGROUND_ORES, | ||
+ | RegistryKey.of(Registry.PLACED_FEATURE_KEY, | ||
+ | new Identifier(" | ||
+ | } | ||
} | } | ||
</ | </ | ||
- | ==== 结论 | + | ==== 添加到末地生物群系 |
- | 您应该会在整个世界中看到石英矿石的生成: | + | 本段落将会基于主世界的代码添加矿石到末地生物群系。 |
+ | |||
+ | 在末地,基础方块是末地石,所以需要把 '' | ||
+ | |||
+ | <code java> | ||
+ | public class ExampleMod implements ModInitializer { | ||
+ | private static ConfiguredFeature<?, | ||
+ | (Feature.ORE, | ||
+ | new BlockMatchRuleTest(Blocks.END_STONE), | ||
+ | Blocks.WHITE_WOOL.getDefaultState(), | ||
+ | 9)); | ||
+ | |||
+ | public static PlacedFeature END_WOOL_ORE_PLACED_FEATURE = new PlacedFeature( | ||
+ | RegistryEntry.of(END_WOOL_ORE_CONFIGURED_FEATURE), | ||
+ | Arrays.asList( | ||
+ | CountPlacementModifier.of(20), | ||
+ | SquarePlacementModifier.of(), | ||
+ | HeightRangePlacementModifier.uniform(YOffset.getBottom(), | ||
+ | |||
+ | @Override | ||
+ | public void onInitialize() { | ||
+ | Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, | ||
+ | new Identifier(" | ||
+ | Registry.register(BuiltinRegistries.PLACED_FEATURE, | ||
+ | END_WOOL_ORE_PLACED_FEATURE); | ||
+ | BiomeModifications.addFeature(BiomeSelectors.foundInTheEnd(), | ||
+ | RegistryKey.of(Registry.PLACED_FEATURE_KEY, | ||
+ | new Identifier(" | ||
+ | } | ||
+ | } | ||
+ | </ | ||
- | {{https:// | ||
zh_cn/tutorial/ores.txt · Last modified: 2023/12/18 01:03 by solidblock