zh_cn:tutorial:ores
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
zh_cn:tutorial:ores [2021/09/23 00:19] – [结论] solidblock | zh_cn:tutorial:ores [2022/08/18 03:25] – solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
许多模组会添加自己的矿石,您需要找到一种方法以将其放置在现有生物群系中让玩家寻找。在本教程中,我们将研究将矿石添加到现有生物群系以及其他模组添加的生物群系。将矿石添加到生物群系需要2个步骤。 | 许多模组会添加自己的矿石,您需要找到一种方法以将其放置在现有生物群系中让玩家寻找。在本教程中,我们将研究将矿石添加到现有生物群系以及其他模组添加的生物群系。将矿石添加到生物群系需要2个步骤。 | ||
- | * 制作一个 ConfiguredFeature,定义你的矿石方块如何生成。 | + | * 制作一个 ConfiguredFeature(已配置的地物),定义你的矿石方块如何生成。 |
* 使用 [[https:// | * 使用 [[https:// | ||
Line 10: | Line 10: | ||
本段落将会在主世界生成矿石。 | 本段落将会在主世界生成矿石。 | ||
- | 我们需要创建一个 | + | 我们需要创建一个已配置的地物,确保在 '' |
<code java> | <code java> | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | private static ConfiguredFeature<?, | + | private static ConfiguredFeature<?, |
- | .configure(new OreFeatureConfig( | + | (Feature.ORE, new OreFeatureConfig( |
- | | + | |
- | Blocks.WHITE_WOOL.getDefaultState(), | + | Blocks.WHITE_WOOL.getDefaultState(), |
- | 9)) // Vein size | + | 9)); // 矿脉大小 |
- | | + | |
- | | + | public static PlacedFeature OVERWORLD_WOOL_ORE_PLACED_FEATURE = new PlacedFeature( |
- | | + | |
- | .spreadHorizontally() | + | |
- | | + | CountPlacementModifier.of(20), // 每个区块的矿脉数量 |
+ | SquarePlacementModifier.of(), // 水平传播 | ||
+ | | ||
+ | )); // 高度 | ||
@Override | @Override | ||
public void onInitialize() { | public void onInitialize() { | ||
- | | + | |
- | new Identifier(" | + | new Identifier(" |
- | Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, oreWoolOverworld.getValue(), ORE_WOOL_OVERWORLD); | + | Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(" |
- | BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), | + | OVERWORLD_WOOL_ORE_PLACED_FEATURE); |
+ | BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), | ||
+ | RegistryKey.of(Registry.PLACED_FEATURE_KEY, | ||
+ | new Identifier(" | ||
} | } | ||
} | } | ||
Line 46: | Line 52: | ||
本段落将会基于前面的段落添加矿石到下界生物群系。 | 本段落将会基于前面的段落添加矿石到下界生物群系。 | ||
- | 在下界,需要替换的方块和主世界地不同,所以需要把 '' | + | 在下界,需要替换的方块和主世界地不同,所以需要把 '' |
<code java> | <code java> | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | private static ConfiguredFeature<?, | + | private static ConfiguredFeature<?, |
- | .configure(new OreFeatureConfig( | + | (Feature.ORE, new OreFeatureConfig( |
- | | + | |
- | Blocks.WHITE_WOOL.getDefaultState(), | + | Blocks.WHITE_WOOL.getDefaultState(), |
- | 9)) | + | 9)); |
- | | + | |
- | | + | public static PlacedFeature NETHER_WOOL_ORE_PLACED_FEATURE = new PlacedFeature( |
- | .spreadHorizontally() | + | |
- | | + | Arrays.asList( |
+ | CountPlacementModifier.of(20), | ||
+ | SquarePlacementModifier.of(), | ||
+ | | ||
@Override | @Override | ||
public void onInitialize() { | public void onInitialize() { | ||
- | | + | |
- | new Identifier(" | + | new Identifier(" |
- | Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, oreWoolNether.getValue(), ORE_WOOL_NETHER); | + | Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(" |
- | BiomeModifications.addFeature(BiomeSelectors.foundInTheNether(), | + | NETHER_WOOL_ORE_PLACED_FEATURE); |
+ | BiomeModifications.addFeature(BiomeSelectors.foundInTheNether(), | ||
+ | RegistryKey.of(Registry.PLACED_FEATURE_KEY, | ||
+ | new Identifier(" | ||
} | } | ||
} | } | ||
Line 73: | Line 85: | ||
本段落将会基于主世界的代码添加矿石到末地生物群系。 | 本段落将会基于主世界的代码添加矿石到末地生物群系。 | ||
- | 在末地,基础方块是末地石,所以需要把 '' | + | 在末地,基础方块是末地石,所以需要把 '' |
<code java> | <code java> | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | private static ConfiguredFeature<?, | + | private static ConfiguredFeature<?, |
- | .configure(new OreFeatureConfig( | + | (Feature.ORE, new OreFeatureConfig( |
- | new BlockMatchRuleTest(Blocks.END_STONE), | + | new BlockMatchRuleTest(Blocks.END_STONE), |
- | Blocks.WHITE_WOOL.getDefaultState(), | + | Blocks.WHITE_WOOL.getDefaultState(), |
- | 9)) | + | 9)); |
- | | + | |
- | | + | public static PlacedFeature END_WOOL_ORE_PLACED_FEATURE = new PlacedFeature( |
- | .spreadHorizontally() | + | |
- | | + | Arrays.asList( |
+ | CountPlacementModifier.of(20), | ||
+ | SquarePlacementModifier.of(), | ||
+ | | ||
@Override | @Override | ||
public void onInitialize() { | public void onInitialize() { | ||
- | | + | |
- | new Identifier(" | + | new Identifier(" |
- | Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, oreWoolEnd.getValue(), ORE_WOOL_END); | + | Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(" |
- | BiomeModifications.addFeature(BiomeSelectors.foundInTheEnd(), | + | END_WOOL_ORE_PLACED_FEATURE); |
+ | BiomeModifications.addFeature(BiomeSelectors.foundInTheEnd(), | ||
+ | RegistryKey.of(Registry.PLACED_FEATURE_KEY, | ||
+ | new Identifier(" | ||
} | } | ||
} | } |
zh_cn/tutorial/ores.txt · Last modified: 2023/12/18 01:03 by solidblock