Fix worldgen and rubber trees. For now datapack driven worldgen isnt working.
This commit is contained in:
parent
22a50d2ecd
commit
e7ab7e26d3
3 changed files with 15 additions and 13 deletions
|
@ -35,6 +35,7 @@ import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.Pair;
|
import net.minecraft.util.Pair;
|
||||||
import net.minecraft.util.collection.DataPool;
|
import net.minecraft.util.collection.DataPool;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.math.intprovider.ConstantIntProvider;
|
||||||
import net.minecraft.util.math.intprovider.UniformIntProvider;
|
import net.minecraft.util.math.intprovider.UniformIntProvider;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
|
@ -62,7 +63,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class DefaultWorldGen {
|
public class DefaultWorldGen {
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public class DefaultWorldGen {
|
||||||
new StraightTrunkPlacer(6, 3, 0),
|
new StraightTrunkPlacer(6, 3, 0),
|
||||||
new SimpleBlockStateProvider(TRContent.RUBBER_LEAVES.getDefaultState()),
|
new SimpleBlockStateProvider(TRContent.RUBBER_LEAVES.getDefaultState()),
|
||||||
new SimpleBlockStateProvider(TRContent.RUBBER_SAPLING.getDefaultState()),
|
new SimpleBlockStateProvider(TRContent.RUBBER_SAPLING.getDefaultState()),
|
||||||
new RubberTreeFeature.FoliagePlacer(UniformIntProvider.create(2, 0), UniformIntProvider.create(0, 0), 3, 3, TRContent.RUBBER_LEAVES.getDefaultState()),
|
new RubberTreeFeature.FoliagePlacer(ConstantIntProvider.create(2), ConstantIntProvider.create(0), 3, 3, TRContent.RUBBER_LEAVES.getDefaultState()),
|
||||||
new TwoLayersFeatureSize(1, 0, 1)
|
new TwoLayersFeatureSize(1, 0, 1)
|
||||||
).build();
|
).build();
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ public class DefaultWorldGen {
|
||||||
|
|
||||||
|
|
||||||
features.add(new DataDrivenFeature(
|
features.add(new DataDrivenFeature(
|
||||||
new Identifier("techreborn", "rubber_tree"),
|
RubberSaplingGenerator.IDENTIFIER,
|
||||||
BiomeSelectors.categories(Biome.Category.FOREST, Biome.Category.TAIGA, Biome.Category.SWAMP),
|
BiomeSelectors.categories(Biome.Category.FOREST, Biome.Category.TAIGA, Biome.Category.SWAMP),
|
||||||
getRubberTree(),
|
getRubberTree(),
|
||||||
GenerationStep.Feature.VEGETAL_DECORATION
|
GenerationStep.Feature.VEGETAL_DECORATION
|
||||||
|
|
|
@ -35,17 +35,17 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class RubberSaplingGenerator extends SaplingGenerator {
|
public class RubberSaplingGenerator extends SaplingGenerator {
|
||||||
private final Identifier identifier = new Identifier("techreborn", "techreborn/features/rubber_tree.json");
|
public static final Identifier IDENTIFIER = new Identifier("techreborn", "techreborn/features/rubber_tree.json");
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
protected ConfiguredFeature<TreeFeatureConfig, ?> createTreeFeature(Random random, boolean bl) {
|
protected ConfiguredFeature<TreeFeatureConfig, ?> createTreeFeature(Random random, boolean bl) {
|
||||||
MutableRegistry<ConfiguredFeature<?, ?>> registry = WorldGenerator.worldGenObseravable.getA();
|
MutableRegistry<ConfiguredFeature<?, ?>> registry = WorldGenerator.worldGenObseravable.getA();
|
||||||
if (!registry.getIds().contains(identifier)) {
|
if (!registry.getIds().contains(IDENTIFIER)) {
|
||||||
throw new RuntimeException("Could not find registered rubber tree feature!");
|
throw new RuntimeException("Could not find registered rubber tree feature!");
|
||||||
}
|
}
|
||||||
|
|
||||||
DecoratedFeatureConfig decoratedFeatureConfig = (DecoratedFeatureConfig) registry.get(identifier).getConfig();
|
DecoratedFeatureConfig decoratedFeatureConfig = (DecoratedFeatureConfig) registry.get(IDENTIFIER).getConfig();
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (ConfiguredFeature<TreeFeatureConfig, ?>) decoratedFeatureConfig.feature.get();
|
return (ConfiguredFeature<TreeFeatureConfig, ?>) decoratedFeatureConfig.feature.get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,17 +67,19 @@ public class WorldGenerator {
|
||||||
// DefaultWorldGen.export();
|
// DefaultWorldGen.export();
|
||||||
|
|
||||||
worldGenObseravable.listen(WorldGenerator::applyToActiveRegistry);
|
worldGenObseravable.listen(WorldGenerator::applyToActiveRegistry);
|
||||||
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(new WorldGenConfigReloader());
|
|
||||||
|
|
||||||
|
// FIXME 1.17 datadriven worldgen, for now we just use the default
|
||||||
|
//ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(new WorldGenConfigReloader());
|
||||||
|
worldGenObseravable.pushB(DefaultWorldGen.getDefaultFeatures());
|
||||||
|
|
||||||
|
|
||||||
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
|
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
|
||||||
worldGenObseravable.pushA(registryManager.getMutable(BuiltinRegistries.CONFIGURED_FEATURE.getKey()));
|
worldGenObseravable.pushA(registryManager.getMutable(BuiltinRegistries.CONFIGURED_FEATURE.getKey()));
|
||||||
});
|
});
|
||||||
|
|
||||||
BiomeModifications.create(new Identifier("techreborn", "features")).add(ModificationPhase.ADDITIONS, BiomeSelectors.all(), (biomeSelectionContext, biomeModificationContext) -> {
|
BiomeModifications.create(new Identifier("techreborn", "features")).add(ModificationPhase.ADDITIONS, BiomeSelectors.all(),
|
||||||
if (!worldGenObseravable.hasBoth()) {
|
(biomeSelectionContext, biomeModificationContext) -> {
|
||||||
LOGGER.warn("TR world gen not ready for biome modification");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (DataDrivenFeature feature : worldGenObseravable.getB()) {
|
for (DataDrivenFeature feature : worldGenObseravable.getB()) {
|
||||||
if (feature.getBiomeSelector().test(biomeSelectionContext)) {
|
if (feature.getBiomeSelector().test(biomeSelectionContext)) {
|
||||||
biomeModificationContext.getGenerationSettings().addFeature(feature.getGenerationStep(), feature.getRegistryKey());
|
biomeModificationContext.getGenerationSettings().addFeature(feature.getGenerationStep(), feature.getRegistryKey());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue