好的,所以我开始按照教程和带有代码示例的官方织物文档站点使用织物进行改装。我做了一棵树,我可以通过对我做的树苗进行骨粉化来得到它。但它不会在世界上产生。我用了
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, TreeStructure.ANCIENT_TREES_KEY.getValue(), TreeStructure.ANCIENT_TREES);
BiomeModifications.addFeature(BiomeSelectors.all(), GenerationStep.Feature.VEGETAL_DECORATION, TreeStructure.ANCIENT_TREES_KEY);
对于产卵(在 onInitialize() 方法中)和树本身:
public class TreeStructure {
public static final TreeFeatureConfig ANCIENT_TREE_CONFIG = new TreeFeatureConfig.Builder(
new SimpleBlockStateProvider(ModBlocks.ANCIENT_WOOD.getDefaultState()), // Trunk block provider
new StraightTrunkPlacer(8, 3, 0), // places a straight trunk i=base height j=height-variance1 k=height-variance2
new SimpleBlockStateProvider(Blocks.BROWN_STAINED_GLASS.getDefaultState()), // Foliage block provider
new SimpleBlockStateProvider(ModBlocks.ANCIENT_SAPLING.getDefaultState()),// Sapling provider; used to determine what blocks the tree can generate on
new BlobFoliagePlacer(ConstantIntProvider.create(5), ConstantIntProvider.create(0), 3), // Place leaves as a blob (radius, offset from trunk, height)
new TwoLayersFeatureSize(1, 0, 1) // The width of the tree at different layers; used to see how tall the tree can be without clipping into blocks
).build();
public static final ConfiguredFeature<TreeFeatureConfig, ?> ANCIENT_TREE = Feature.TREE.configure(ANCIENT_TREE_CONFIG);
public static final ConfiguredFeature<?, ?> ANCIENT_TREES = Feature.TREE.configure(ANCIENT_TREE_CONFIG).spreadHorizontally().applyChance(3);
public static RegistryKey<ConfiguredFeature<?, ?>> ANCIENT_TREES_KEY = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY, new Identifier(Druids.MOD_ID, "ancient_trees"));
}
我知道 BiomeModificaions 已被弃用,但它应该仍然有效,对吧?我做错了什么让树木在这个世界上产卵?