More workarounds for arbitrary limitations set by Mojang

This commit is contained in:
Adubbz 2020-09-21 11:53:34 +10:00
parent 7798e91fa8
commit ca237aed5a
5 changed files with 103 additions and 1 deletions

View file

@ -9,6 +9,7 @@ package biomesoplenty.common.biome.overworld;
import biomesoplenty.api.enums.BOPClimates;
import biomesoplenty.common.biome.BiomeTemplate;
import biomesoplenty.common.util.biome.FeatureUtil;
import biomesoplenty.common.world.gen.feature.BOPConfiguredFeatures;
import biomesoplenty.common.world.gen.feature.BOPFeatures;
import com.google.common.collect.ImmutableList;
@ -60,7 +61,7 @@ public class LavenderFieldBiome extends BiomeTemplate
builder.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_SELECTOR.configured(new MultipleRandomFeatureConfig(ImmutableList.of(BOPFeatures.FLOWERING_OAK_TREE.configured(Features.OAK.config().withDecorators(ImmutableList.of(Features.Placements.BEEHIVE_005))).weighted(0.2F), BOPConfiguredFeatures.BIG_FLOWERING_OAK_TREE.weighted(0.1F), BOPFeatures.BIG_JACARANDA_TREE.configured(Features.OAK.config()).weighted(0.1F)), BOPFeatures.JACARANDA_TREE.configured(Features.OAK.config().withDecorators(ImmutableList.of(Features.Placements.BEEHIVE_002))))).decorated(Features.Placements.HEIGHTMAP_SQUARE).decorated(Placement.COUNT_EXTRA.configured(new AtSurfaceWithExtraConfig(1, 0.2F, 1))));
builder.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BOPFeatures.STANDARD_GRASS.configured(IFeatureConfig.NONE).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(12)));
builder.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BOPFeatures.LAVENDER_FLOWERS.configured(IFeatureConfig.NONE).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(128)));
builder.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, BOPFeatures.LAVENDER_FLOWERS.configured(IFeatureConfig.NONE).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE).decorated(FeatureUtil.denseCount(500)));
builder.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.configured(Features.Configs.SUGAR_CANE_CONFIG).decorated(Features.Placements.HEIGHTMAP_DOUBLE_SQUARE.count(10)));
////////////////////////////////////////////////////////////

View file

@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright 2014-2019, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.util.biome;
import biomesoplenty.common.world.gen.feature.DenseFeatureSpreadConfig;
import biomesoplenty.common.world.gen.placement.BOPPlacements;
import net.minecraft.world.gen.feature.FeatureSpreadConfig;
import net.minecraft.world.gen.placement.ConfiguredPlacement;
import net.minecraft.world.gen.placement.Placement;
public class FeatureUtil
{
public static ConfiguredPlacement<?> denseCount(int count)
{
return BOPPlacements.COUNT.configured(new DenseFeatureSpreadConfig(count));
}
}

View file

@ -0,0 +1,28 @@
package biomesoplenty.common.world.gen.feature;
import com.mojang.serialization.Codec;
import net.minecraft.world.gen.feature.FeatureSpread;
import net.minecraft.world.gen.feature.FeatureSpreadConfig;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.placement.IPlacementConfig;
public class DenseFeatureSpreadConfig implements IPlacementConfig, IFeatureConfig
{
public static final Codec<DenseFeatureSpreadConfig> CODEC = FeatureSpread.codec(-10, 1024, 1024).fieldOf("count").xmap(DenseFeatureSpreadConfig::new, DenseFeatureSpreadConfig::count).codec();
private final FeatureSpread count;
public DenseFeatureSpreadConfig(int count)
{
this.count = FeatureSpread.fixed(count);
}
public DenseFeatureSpreadConfig(FeatureSpread count)
{
this.count = count;
}
public FeatureSpread count()
{
return this.count;
}
}

View file

@ -0,0 +1,25 @@
package biomesoplenty.common.world.gen.placement;
import biomesoplenty.common.world.gen.feature.DenseFeatureSpreadConfig;
import com.mojang.serialization.Codec;
import java.util.Random;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.gen.feature.FeatureSpreadConfig;
import net.minecraft.world.gen.placement.SimplePlacement;
public class BOPCountPlacement extends SimplePlacement<DenseFeatureSpreadConfig>
{
public BOPCountPlacement(Codec<DenseFeatureSpreadConfig> codec)
{
super(codec);
}
public Stream<BlockPos> place(Random random, DenseFeatureSpreadConfig config, BlockPos pos)
{
return IntStream.range(0, config.count().sample(random)).mapToObj((p_242878_1_) -> {
return pos;
});
}
}

View file

@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright 2014-2020, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.world.gen.placement;
import biomesoplenty.common.world.gen.feature.DenseFeatureSpreadConfig;
import biomesoplenty.core.BiomesOPlenty;
import com.mojang.serialization.Codec;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.gen.feature.FeatureSpreadConfig;
import net.minecraft.world.gen.placement.*;
public class BOPPlacements
{
public static final Placement<DenseFeatureSpreadConfig> COUNT = register("count", new BOPCountPlacement(DenseFeatureSpreadConfig.CODEC));
private static <T extends IPlacementConfig, G extends Placement<T>> G register(String key, G placement)
{
return Registry.register(Registry.DECORATOR, new ResourceLocation(BiomesOPlenty.MOD_ID, key), placement);
}
}