Skip to content

Commit

Permalink
Major changes to Oasis biomes
Browse files Browse the repository at this point in the history
Some optimization to structures biome checking
  • Loading branch information
GirafiStudios committed Oct 14, 2020
1 parent d7c4497 commit aa75cd3
Show file tree
Hide file tree
Showing 18 changed files with 183 additions and 161 deletions.
28 changes: 15 additions & 13 deletions src/main/java/com/teammetallurgy/atum/init/AtumBiomes.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
package com.teammetallurgy.atum.init;

import com.teammetallurgy.atum.Atum;
import com.teammetallurgy.atum.misc.AtumConfig;
import com.teammetallurgy.atum.misc.AtumRegistry;
import com.teammetallurgy.atum.world.biome.AtumBiomeMaker;
import com.teammetallurgy.atum.world.biome.BiomeRegion;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
@Mod.EventBusSubscriber(modid = Atum.MOD_ID)
public class AtumBiomes {
public static final RegistryKey<Biome> DEAD_OASIS = registerBiome(AtumBiomeMaker.makeDeadOasis("dead_oasis"), "dead_oasis");
public static final RegistryKey<Biome> DEADWOOD_FOREST = registerBiome(AtumBiomeMaker.makeDeadwoodForest("deadwood_forest"), "deadwood_forest", 10);
public static final RegistryKey<Biome> DRIED_RIVER = registerBiome(AtumBiomeMaker.makeDriedRiver("dried_river"), "dried_river");
public static final RegistryKey<Biome> LIMESTONE_CRAGS = registerBiome(AtumBiomeMaker.makeLimestoneCrags("limestone_crags"), "limestone_crags", 3);
public static final RegistryKey<Biome> LIMESTONE_MOUNTAINS = registerBiome(AtumBiomeMaker.makeLimestoneMountain("limestone_mountains"), "limestone_mountains", 5);
public static final RegistryKey<Biome> OASIS = registerBiome(AtumBiomeMaker.makeOasis("oasis"), "oasis");
public static final RegistryKey<Biome> SAND_DUNES = registerBiome(AtumBiomeMaker.makeSandDunes("sand_dunes"), "sand_dunes", 15);
public static final RegistryKey<Biome> SAND_HILLS = registerBiome(AtumBiomeMaker.makeSandHills("sand_hills"), "sand_hills", 10);
public static final RegistryKey<Biome> SAND_PLAINS = registerBiome(AtumBiomeMaker.makeSandPlains("sand_plains"), "sand_plains", 30);
public static final RegistryKey<Biome> DEAD_OASIS = registerBiome(AtumBiomeMaker.makeDeadOasis("dead_oasis"), "dead_oasis", BiomeRegion.STRANGE_SANDS);
public static final RegistryKey<Biome> DEADWOOD_FOREST = registerBiome(AtumBiomeMaker.makeDeadwoodForest("deadwood_forest"), "deadwood_forest", 10, BiomeRegion.DESSICATED_WOODS);
public static final RegistryKey<Biome> DRIED_RIVER = registerBiome(AtumBiomeMaker.makeDriedRiver("dried_river"), "dried_river", BiomeRegion.STRANGE_SANDS);
public static final RegistryKey<Biome> LIMESTONE_CRAGS = registerBiome(AtumBiomeMaker.makeLimestoneCrags("limestone_crags"), "limestone_crags", 3, BiomeRegion.LIMESTONE_PEAKS);
public static final RegistryKey<Biome> LIMESTONE_MOUNTAINS = registerBiome(AtumBiomeMaker.makeLimestoneMountain("limestone_mountains"), "limestone_mountains", 5, BiomeRegion.LIMESTONE_PEAKS);
public static final RegistryKey<Biome> OASIS = registerBiome(AtumBiomeMaker.makeOasis("oasis"), "oasis", BiomeRegion.STRANGE_SANDS);
public static final RegistryKey<Biome> SAND_DUNES = registerBiome(AtumBiomeMaker.makeSandDunes("sand_dunes"), "sand_dunes", 15, BiomeRegion.STRANGE_SANDS);
public static final RegistryKey<Biome> SAND_HILLS = registerBiome(AtumBiomeMaker.makeSandHills("sand_hills"), "sand_hills", 10, BiomeRegion.STRANGE_SANDS);
public static final RegistryKey<Biome> SAND_PLAINS = registerBiome(AtumBiomeMaker.makeSandPlains("sand_plains"), "sand_plains", 30, BiomeRegion.STRANGE_SANDS);

public static RegistryKey<Biome> registerBiome(Biome biome, String biomeName) {
return registerBiome(biome, biomeName, 0);
public static RegistryKey<Biome> registerBiome(Biome biome, String biomeName, BiomeRegion biomeRegion) {
return registerBiome(biome, biomeName, 0, biomeRegion);
}

public static RegistryKey<Biome> registerBiome(Biome biome, String biomeName, int weight) {
public static RegistryKey<Biome> registerBiome(Biome biome, String biomeName, int weight, BiomeRegion biomeRegion) {
AtumRegistry.registerBiome(biome, biomeName);
if (weight > 0) {
new AtumConfig.Biome(AtumConfig.BUILDER, biomeName, weight); //Write config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
public class AtumFeatures {
private static final List<Feature<?>> FEATURES = new ArrayList<>();
//Features
public static final Feature<DoubleBlockStateFeatureConfig> OASIS_POND = register("oasis_pond", new OasisPondFeature(DoubleBlockStateFeatureConfig.DOUBLE_STATE_CODEC));
public static final Feature<BlockStateFeatureConfig> SURFACE_LAVA_LAKE = register("surface_lava_lake", new LakeFeature(BlockStateFeatureConfig.field_236455_a_));
public static final Feature<PalmConfig> PALM_TREE = register("palm_tree", new PalmFeature(PalmConfig.PALM_CODEC));
public static final BonusCrateFeature BONUS_CRATE = register("bonus_crate", new BonusCrateFeature(NoFeatureConfig.field_236558_a_));
Expand All @@ -35,6 +34,7 @@ public class AtumFeatures {
public static final DeadwoodFeature DEADWOOD_FEATURE = register("deadwood_tree", new DeadwoodFeature(BaseTreeFeatureConfig.CODEC));
public static final Feature<NoFeatureConfig> LIMESTONE_SPIKE = register("limestone_spike", new LimestoneSpikeFeature(NoFeatureConfig.field_236558_a_));
public static final Feature<BlockClusterFeatureConfig> ANPUTS_FINGERS = register("anputs_fingers", new AnputsFingersFeature(BlockClusterFeatureConfig.field_236587_a_));
public static final Feature<NoFeatureConfig> SAND_LAYER = register("sand_layer", new SandLayerFeature(NoFeatureConfig.field_236558_a_));

//Feature Configs
public static final BlockClusterFeatureConfig OASIS_GRASS_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(AtumBlocks.OASIS_GRASS.getDefaultState()), new SimpleBlockPlacer())).tries(30).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.WorldGenRegistries;
import net.minecraft.world.ISeedReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.biome.Biome;
Expand Down Expand Up @@ -41,11 +42,10 @@ public static int getSkyColorWithTemperatureModifier(float temperature) {
return MathHelper.hsvToRGB(0.62222224F - f * 0.05F, 0.5F + f * 0.1F, 1.0F);
}

public static boolean canPlaceSandLayer(RegistryKey<Biome> biome, IWorldReader world, BlockPos pos) {
public static boolean canPlaceSandLayer(ISeedReader world, BlockPos pos) {
BlockState state = world.getBlockState(pos);
BlockState stateDown = world.getBlockState(pos.down());
return biome != AtumBiomes.OASIS
&& state.getMaterial().isReplaceable()
return state.getMaterial().isReplaceable()
&& stateDown.getBlock() != AtumBlocks.LIMESTONE_CRACKED
&& Block.hasSolidSideOnTop(world, pos.down())
&& !(stateDown.getBlock() instanceof SandLayersBlock)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public class AtumBiomeMaker {

public static Biome makeDeadOasis(String biomeName) {
BiomeGenerationSettings.Builder biomeGen = (new BiomeGenerationSettings.Builder().withSurfaceBuilder(AtumSurfaceBuilders.GRAVEL_CRACKED));
biomeGen.withFeature(GenerationStage.Decoration.LOCAL_MODIFICATIONS, AtumFeatures.OASIS_POND.withConfiguration(new DoubleBlockStateFeatureConfig(Blocks.AIR.getDefaultState(), AtumBlocks.LIMESTONE_GRAVEL.getDefaultState())).withPlacement(Placement.WATER_LAKE.configure(new ChanceConfig(1))));
biomeGen.withFeature(VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(AtumFeatures.DEAD_GRASS_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(5));
biomeGen.withFeature(VEGETAL_DECORATION, AtumFeatures.PALM_TREE.withConfiguration(AtumFeatures.DEAD_PALM_TREE_CONFIG).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).withPlacement(Placement.field_242902_f.configure(new AtSurfaceWithExtraConfig(1, 0.1F, 1))));
addDefaultSpawns(biomeName);
addCamelSpawning(biomeName);
AtumDefaultFeatures.addCarvers(biomeGen);
AtumDefaultFeatures.addSandLayer(biomeGen);
AtumDefaultFeatures.addSprings(biomeGen);
AtumDefaultFeatures.addMaterialPockets(biomeGen);
AtumDefaultFeatures.addStoneVariants(biomeGen);
Expand All @@ -53,7 +53,7 @@ public static Biome makeDeadOasis(String biomeName) {
AtumDefaultFeatures.addRuins(biomeGen);
AtumDefaultFeatures.addMineshaft(biomeGen, false);

return new Builder().scale(0.0F).withGenerationSettings(biomeGen.build()).withMobSpawnSettings(MobSpawnInfo.EMPTY).setEffects(Builder.getBaseEffects().withFoliageColor(10189386).withGrassColor(10189386).build()).build();
return new Builder().depth(-0.18F).scale(0.0F).withGenerationSettings(biomeGen.build()).withMobSpawnSettings(MobSpawnInfo.EMPTY).setEffects(Builder.getBaseEffects().withFoliageColor(10189386).withGrassColor(10189386).build()).build();
}

public static Biome makeDeadwoodForest(String biomeName) {
Expand All @@ -62,6 +62,7 @@ public static Biome makeDeadwoodForest(String biomeName) {
addDefaultSpawns(biomeName);
AtumDefaultFeatures.addDeadwoodTrees(biomeGen, 20, 0.25F, 3);
AtumDefaultFeatures.addCarvers(biomeGen);
AtumDefaultFeatures.addSandLayer(biomeGen);
AtumDefaultFeatures.addSprings(biomeGen);
AtumDefaultFeatures.addMaterialPockets(biomeGen);
AtumDefaultFeatures.addStoneVariants(biomeGen);
Expand All @@ -80,6 +81,7 @@ public static Biome makeDeadwoodForest(String biomeName) {
public static Biome makeDriedRiver(String biomeName) {
BiomeGenerationSettings.Builder biomeGen = (new BiomeGenerationSettings.Builder().withSurfaceBuilder(AtumSurfaceBuilders.GRAVEL_CRACKED));
AtumDefaultFeatures.addCarvers(biomeGen);
AtumDefaultFeatures.addSandLayer(biomeGen);
AtumDefaultFeatures.addSprings(biomeGen);
AtumDefaultFeatures.addStoneVariants(biomeGen);
AtumDefaultFeatures.addOres(biomeGen);
Expand All @@ -100,6 +102,7 @@ public static Biome makeLimestoneCrags(String biomeName) {
addDefaultSpawns(biomeName);
addDesertWolfSpawning(biomeName);
AtumDefaultFeatures.addCarvers(biomeGen);
AtumDefaultFeatures.addSandLayer(biomeGen);
AtumDefaultFeatures.addSprings(biomeGen);
AtumDefaultFeatures.addMaterialPockets(biomeGen);
AtumDefaultFeatures.addStoneVariants(biomeGen);
Expand All @@ -122,6 +125,7 @@ public static Biome makeLimestoneMountain(String biomeName) {
addDefaultSpawns(biomeName);
addDesertWolfSpawning(biomeName);
AtumDefaultFeatures.addCarvers(biomeGen);
AtumDefaultFeatures.addSandLayer(biomeGen);
AtumDefaultFeatures.addSprings(biomeGen);
AtumDefaultFeatures.addMaterialPockets(biomeGen);
AtumDefaultFeatures.addStoneVariants(biomeGen);
Expand All @@ -138,7 +142,7 @@ public static Biome makeLimestoneMountain(String biomeName) {

public static Biome makeOasis(String biomeName) {
BiomeGenerationSettings.Builder biomeGen = (new BiomeGenerationSettings.Builder().withSurfaceBuilder(AtumSurfaceBuilders.OASIS));
biomeGen.withFeature(GenerationStage.Decoration.LOCAL_MODIFICATIONS, AtumFeatures.OASIS_POND.withConfiguration(new DoubleBlockStateFeatureConfig(Blocks.WATER.getDefaultState(), AtumBlocks.FERTILE_SOIL.getDefaultState())).withPlacement(Placement.WATER_LAKE.configure(new ChanceConfig(1))));
//biomeGen.withFeature(GenerationStage.Decoration.LOCAL_MODIFICATIONS, AtumFeatures.OASIS_POND.withConfiguration(new DoubleBlockStateFeatureConfig(Blocks.WATER.getDefaultState(), AtumBlocks.FERTILE_SOIL.getDefaultState())).withPlacement(Placement.WATER_LAKE.configure(new ChanceConfig(1))));
biomeGen.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(AtumFeatures.OASIS_GRASS_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(7));
//TODO Fix Papyrus feature. Breaks Oasis when enabled
//biomeGen.withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(AtumFeatures.PAPYRUS_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(250));
Expand All @@ -154,7 +158,7 @@ public static Biome makeOasis(String biomeName) {
AtumDefaultFeatures.addInfestedLimestone(biomeGen);
AtumDefaultFeatures.addFossils(biomeGen);
AtumDefaultFeatures.addMineshaft(biomeGen, false);
return new Builder().scale(0.0F).withGenerationSettings(biomeGen.build()).withMobSpawnSettings(MobSpawnInfo.EMPTY).setEffects(Builder.getBaseEffects().withFoliageColor(11987573).withGrassColor(11987573).build()).build();
return new Builder().depth(-0.18F).scale(0.0F).withGenerationSettings(biomeGen.build()).withMobSpawnSettings(MobSpawnInfo.EMPTY).setEffects(Builder.getBaseEffects().withFoliageColor(11987573).withGrassColor(11987573).build()).build();
}

public static Biome makeSandDunes(String biomeName) {
Expand All @@ -163,6 +167,7 @@ public static Biome makeSandDunes(String biomeName) {
addDefaultSpawns(biomeName);
addCamelSpawning(biomeName);
AtumDefaultFeatures.addCarvers(biomeGen);
AtumDefaultFeatures.addSandLayer(biomeGen);
AtumDefaultFeatures.addSprings(biomeGen);
AtumDefaultFeatures.addMaterialPockets(biomeGen);
AtumDefaultFeatures.addStoneVariants(biomeGen);
Expand All @@ -184,6 +189,7 @@ public static Biome makeSandHills(String biomeName) {
addDefaultSpawns(biomeName);
addDesertWolfSpawning(biomeName);
AtumDefaultFeatures.addCarvers(biomeGen);
AtumDefaultFeatures.addSandLayer(biomeGen);
AtumDefaultFeatures.addSprings(biomeGen);
AtumDefaultFeatures.addMaterialPockets(biomeGen);
AtumDefaultFeatures.addStoneVariants(biomeGen);
Expand All @@ -205,6 +211,7 @@ public static Biome makeSandPlains(String biomeName) {
addDefaultSpawns(biomeName);
addCamelSpawning(biomeName);
AtumDefaultFeatures.addCarvers(biomeGen);
AtumDefaultFeatures.addSandLayer(biomeGen);
AtumDefaultFeatures.addSprings(biomeGen);
AtumDefaultFeatures.addMaterialPockets(biomeGen);
AtumDefaultFeatures.addStoneVariants(biomeGen);
Expand Down Expand Up @@ -251,31 +258,6 @@ public static void addDesertWolfSpawning(String biomeName) {
addSpawn(biomeName, AtumEntities.DESERT_WOLF, 6, 2, 4, EntityClassification.CREATURE);
}

//TODO Make sure all this is reimplmented correctly
/*
@Override
public void decorate(@Nonnull GenerationStage.Decoration stage, @Nonnull ChunkGenerator<? extends GenerationSettings> chunkGenerator, @Nonnull IWorld world, long seed, @Nonnull SharedSeedRandom random, @Nonnull BlockPos pos) {
super.decorate(stage, chunkGenerator, world, seed, random, pos);
if (AtumConfig.WORLD_GEN.sandLayerEdge.get()) {
for (int x = 0; x < 16; ++x) {
for (int z = 0; z < 16; ++z) {
BlockPos height = world.getHeight(Heightmap.Type.MOTION_BLOCKING, pos.add(x, 0, z));
if (canPlaceSandLayer(world, height)) {
for (Direction facing : Direction.Plane.HORIZONTAL) {
BlockPos posOffset = height.offset(facing);
if (world.getBlockState(posOffset).isSolidSide(world, posOffset, Direction.UP)) {
int layers = MathHelper.nextInt(random, 1, 3);
world.setBlockState(height, AtumBlocks.SAND_LAYERED.getDefaultState().with(SandLayersBlock.LAYERS, layers), 2);
}
}
}
}
}
}
}*/

public static class Builder extends Biome.Builder {

public Builder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AtumBiomeProvider(long seed, boolean largeBiomes, Registry<Biome> lookupR
this.seed = seed;
this.largeBiomes = largeBiomes;
this.lookupRegistry = lookupRegistry;
this.genBiomes = AtumLayerUtil.getNoiseLayer(seed, largeBiomes ? 6 : 4, 4);
this.genBiomes = AtumLayerUtil.getNoiseLayer(seed, largeBiomes ? 6 : 4, 8);
}

public static Biome getBiome(RegistryKey<Biome> key) {
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/teammetallurgy/atum/world/biome/BiomeRegion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.teammetallurgy.atum.world.biome;

import net.minecraft.util.IStringSerializable;

import javax.annotation.Nonnull;

public enum BiomeRegion implements IStringSerializable {
STRANGE_SANDS("strange_sands"),
LIMESTONE_PEAKS("limestone_peaks"),
DESSICATED_WOODS("dessicated_woods"),
SCORCHED_CHASMS("scorched_chasms"),
SUNSCARRED_CLAIM("sunscarred_claim"),
ABYSSAL_REACHES("abyssal_reaches");

private final String name;

BiomeRegion(String name) {
this.name = name;
}

@Override
@Nonnull
public String getString() {
return this.name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public static void addCarvers(BiomeGenerationSettings.Builder builder) {
builder.withCarver(GenerationStage.Carving.AIR, AtumCarvers.CANYON_CONFIGURED);
}

public static void addSandLayer(BiomeGenerationSettings.Builder builder) { //TODO Figure out why it's not working
builder.withFeature(GenerationStage.Decoration.TOP_LAYER_MODIFICATION, AtumFeatures.SAND_LAYER.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
}

public static void addSprings(BiomeGenerationSettings.Builder builder) {
builder.withFeature(VEGETAL_DECORATION, Feature.SPRING_FEATURE.withConfiguration(AtumFeatures.WATER_SPRING_CONFIG).withPlacement(Placement.field_242908_m.configure(new TopSolidRangeConfig(8, 8, 50)).func_242728_a().func_242731_b(14)));
builder.withFeature(VEGETAL_DECORATION, Feature.SPRING_FEATURE.withConfiguration(AtumFeatures.LAVA_SPRING_CONFIG).withPlacement(Placement.field_242909_n.configure(new TopSolidRangeConfig(8, 16, 256)).func_242728_a().func_242731_b(8)));
Expand Down

0 comments on commit aa75cd3

Please sign in to comment.