Skip to content

Commit

Permalink
Completely change how water level is handled in Atum, to allow for be…
Browse files Browse the repository at this point in the history
…tter looking water in Oasis
  • Loading branch information
GirafiStudios committed Nov 5, 2020
1 parent 4af20ae commit 27572f7
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 63 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/teammetallurgy/atum/Atum.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import net.minecraft.world.gen.NoiseChunkGenerator;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.eventbus.api.IEventBus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.teammetallurgy.atum.items.artifacts.atem.EyesOfAtemItem;
import com.teammetallurgy.atum.items.artifacts.nuit.NuitsVanishingItem;
import com.teammetallurgy.atum.misc.AtumConfig;
import com.teammetallurgy.atum.world.DimensionHelper;
import com.teammetallurgy.atum.world.SandstormHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
Expand Down Expand Up @@ -54,7 +55,7 @@ public static void renderFog(EntityViewRenderEvent.RenderFogEvent event) {
if (helmet.getItem() == AtumItems.WANDERER_HELMET || helmet.getItem() == AtumItems.DESERT_HELMET_IRON || helmet.getItem() == AtumItems.DESERT_HELMET_GOLD || helmet.getItem() == AtumItems.DESERT_HELMET_DIAMOND) {
fogDensity = fogDensity / 1.5F;
}
if (player.getPosY() >= player.world.getSeaLevel() - 8) {
if (player.getPosY() >= DimensionHelper.GROUND_LEVEL - 8) {
fogDensity *= 1 + sandstormFog - (sandstormFog - sandstormFog * SandstormHandler.INSTANCE.stormStrength);
}
RenderSystem.fogDensity(fogDensity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@Mod.EventBusSubscriber(modid = Atum.MOD_ID)
public class DimensionHelper {
public static final AtumDimensionData DATA = new AtumDimensionData();
public static final int GROUND_LEVEL = 63;

@SubscribeEvent
public static void onSleepFinished(SleepFinishedTimeEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.Features;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.feature.structure.StructureFeatures;
import net.minecraft.world.gen.foliageplacer.AcaciaFoliagePlacer;
import net.minecraft.world.gen.placement.AtSurfaceWithExtraConfig;
import net.minecraft.world.gen.placement.IPlacementConfig;
import net.minecraft.world.gen.placement.NoiseDependant;
import net.minecraft.world.gen.placement.Placement;
import net.minecraft.world.gen.trunkplacer.ForkyTrunkPlacer;

import static net.minecraft.world.gen.GenerationStage.Decoration.SURFACE_STRUCTURES;
import static net.minecraft.world.gen.GenerationStage.Decoration.VEGETAL_DECORATION;
Expand Down Expand Up @@ -95,7 +94,7 @@ public static Biome makeDriedRiver(String biomeName) {
AtumDefaultFeatures.addDungeon(biomeGen);
AtumDefaultFeatures.addTomb(biomeGen);
AtumDefaultFeatures.addMineshaft(biomeGen, false);
return new Builder().withGenerationSettings(biomeGen.build()).withMobSpawnSettings(MobSpawnInfo.EMPTY).depth(-0.5F).scale(0.0F).build();
return new Builder().withGenerationSettings(biomeGen.build()).withMobSpawnSettings(MobSpawnInfo.EMPTY).depth(-0.3F).scale(0.0F).build();
}

public static Biome makeLimestoneCrags(String biomeName) {
Expand All @@ -117,7 +116,7 @@ public static Biome makeLimestoneCrags(String biomeName) {
AtumDefaultFeatures.addDungeon(biomeGen);
AtumDefaultFeatures.addTomb(biomeGen);
AtumDefaultFeatures.addMineshaft(biomeGen, false);
return new Builder().withGenerationSettings(biomeGen.build()).withMobSpawnSettings(MobSpawnInfo.EMPTY).depth(0.225F).scale(0.45F).build();
return new Builder().withGenerationSettings(biomeGen.build()).withMobSpawnSettings(MobSpawnInfo.EMPTY).depth(0.75F).scale(0.45F).build();
}

public static Biome makeLimestoneMountain(String biomeName) {
Expand Down Expand Up @@ -146,11 +145,12 @@ public static Biome makeLimestoneMountain(String biomeName) {

public static Biome makeOasis(String biomeName) {
BiomeGenerationSettings.Builder biomeGen = (new BiomeGenerationSettings.Builder().withSurfaceBuilder(AtumSurfaceBuilders.OASIS));
biomeGen.withCarver(GenerationStage.Carving.AIR, AtumCarvers.CAVE_CONFIGURED);
biomeGen.withFeature(VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(AtumFeatures.OASIS_GRASS_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(16));
biomeGen.withFeature(VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(AtumFeatures.PAPYRUS_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(48));
biomeGen.withFeature(VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.LILY_PAD.getDefaultState()), SimpleBlockPlacer.PLACER)).tries(7).build()).withPlacement(Features.Placements.PATCH_PLACEMENT).func_242731_b(2));
biomeGen.withFeature(VEGETAL_DECORATION, AtumFeatures.ATUM_TREE.withConfiguration(AtumFeatures.PALM_TREE_CONFIG).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).withPlacement(Placement.COUNT_EXTRA.configure(new AtSurfaceWithExtraConfig(9, 0.25F, 2))));
biomeGen.withCarver(GenerationStage.Carving.AIR, AtumCarvers.CAVE_CONFIGURED);
biomeGen.withFeature(VEGETAL_DECORATION, AtumFeatures.ATUM_TREE.withConfiguration(new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(Blocks.ACACIA_LOG.getDefaultState()), new SimpleBlockStateProvider(Blocks.ACACIA_LEAVES.getDefaultState()), new AcaciaFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(0)), new ForkyTrunkPlacer(5, 2, 2), new TwoLayerFeature(1, 0, 2)).setIgnoreVines().build()).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).withPlacement(Placement.COUNT_EXTRA.configure(new AtSurfaceWithExtraConfig(1, 0.1F, 1))));
addCamelSpawning(biomeName);
biomeGen.withFeature(VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(Features.Configs.GRASS_PATCH_CONFIG).withPlacement(Features.Placements.PATCH_PLACEMENT).withPlacement(Placement.COUNT_NOISE.configure(new NoiseDependant(-0.8D, 5, 10))));
biomeGen.withFeature(VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(Features.Configs.TALL_GRASS_CONFIG).withPlacement(Features.Placements.VEGETATION_PLACEMENT).withPlacement(Features.Placements.FLOWER_TALL_GRASS_PLACEMENT).square().withPlacement(Placement.COUNT_NOISE.configure(new NoiseDependant(-0.8D, 0, 7))));
Expand All @@ -162,7 +162,7 @@ public static Biome makeOasis(String biomeName) {
AtumDefaultFeatures.addInfestedLimestone(biomeGen);
AtumDefaultFeatures.addFossils(biomeGen);
AtumDefaultFeatures.addMineshaft(biomeGen, false);
return new Builder().depth(-0.33F).scale(0.0F).temperature(1.85F).withGenerationSettings(biomeGen.build()).withMobSpawnSettings(new MobSpawnInfo.Builder().isValidSpawnBiomeForPlayer().copy()).setEffects(Builder.getBaseEffects().withFoliageColor(11987573).withGrassColor(11987573).build()).build();
return new Builder().depth(-0.42F).scale(0.0F).temperature(1.85F).withGenerationSettings(biomeGen.build()).withMobSpawnSettings(new MobSpawnInfo.Builder().isValidSpawnBiomeForPlayer().copy()).setEffects(Builder.getBaseEffects().withFoliageColor(11987573).withGrassColor(11987573).build()).build();
}

public static Biome makeSandDunes(String biomeName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.teammetallurgy.atum.init.AtumBiomes;
import com.teammetallurgy.atum.world.DimensionHelper;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectList;
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
Expand Down Expand Up @@ -39,7 +40,6 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.function.Predicate;
import java.util.function.Supplier;
Expand Down Expand Up @@ -199,7 +199,7 @@ private void fillNoiseColumn(double[] noiseColumn, int noiseX, int noiseZ) {
float f = 0.0F;
float f1 = 0.0F;
float f2 = 0.0F;
int j = this.getSeaLevel();
int j = DimensionHelper.GROUND_LEVEL;
float f3 = this.biomeProvider.getNoiseBiome(noiseX, j, noiseZ).getDepth();

for (int k = -2; k <= 2; ++k) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class AtumSurfaceBuilders {
//Surface Builders
private static final List<SurfaceBuilder<?>> SURFACE_BUILDERS = new ArrayList<>();
public static final SurfaceBuilder<SurfaceBuilderConfig> OASIS_SURFACE_BUILDER = registerBuilder("oasis", new OasisSurfaceBuilder(SurfaceBuilderConfig.field_237203_a_));
//public static final SurfaceBuilder<SurfaceBuilderConfig> OASIS_SURFACE_BUILDER = registerBuilder("oasis", new OasisSurfaceBuilder(SurfaceBuilderConfig.field_237203_a_));

//States
public static final BlockState SAND = AtumBlocks.SAND.getDefaultState();
Expand All @@ -39,7 +39,7 @@ public class AtumSurfaceBuilders {
public static final ConfiguredSurfaceBuilder<SurfaceBuilderConfig> SANDY = registerConfig("sandy", SurfaceBuilder.DEFAULT.func_242929_a(SANDY_CONFIG));
public static final ConfiguredSurfaceBuilder<SurfaceBuilderConfig> SANDY_LIMESTONE = registerConfig("sandy_limestone", SurfaceBuilder.DEFAULT.func_242929_a(SANDY_LIMESTONE_CONFIG));
public static final ConfiguredSurfaceBuilder<SurfaceBuilderConfig> GRAVEL_CRACKED = registerConfig("gravel_cracked", SurfaceBuilder.DEFAULT.func_242929_a(GRAVEL_CRACKED_CONFIG));
public static final ConfiguredSurfaceBuilder<SurfaceBuilderConfig> OASIS = registerConfig("oasis", OASIS_SURFACE_BUILDER.func_242929_a(OASIS_CONFIG));
public static final ConfiguredSurfaceBuilder<SurfaceBuilderConfig> OASIS = registerConfig("oasis", SurfaceBuilder.DEFAULT.func_242929_a(OASIS_CONFIG));

private static <C extends ISurfaceBuilderConfig, F extends SurfaceBuilder<C>> F registerBuilder(String name, F builder) {
ResourceLocation id = new ResourceLocation(Atum.MOD_ID, name);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public boolean generate(@Nonnull ISeedReader genReader, @Nonnull ChunkGenerator
BlockState state = world.getBlockState(down);
boolean isSoil = state.getBlock() == AtumBlocks.SAND;

if (genReader.isAreaLoaded(pos, 10)) {
if (genReader.isAreaLoaded(pos, 16)) {
if (isSoil && pos.getY() < world.getHeight() - baseHeight - 1) {
for (int height = 0; height < baseHeight; ++height) {
BlockPos upN = pos.up(height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.serialization.Codec;
import com.teammetallurgy.atum.init.AtumBlocks;
import com.teammetallurgy.atum.init.AtumStructures;
import com.teammetallurgy.atum.world.DimensionHelper;
import com.teammetallurgy.atum.world.gen.structure.StructureHelper;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
Expand Down Expand Up @@ -30,7 +31,7 @@ public boolean generate(@Nonnull ISeedReader seedReader, @Nonnull ChunkGenerator
pos = pos.down();
}

if (pos.getY() <= seedReader.getSeaLevel()) {
if (pos.getY() <= DimensionHelper.GROUND_LEVEL) {
return false;
} else {
pos = pos.down(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.serialization.Codec;
import com.teammetallurgy.atum.init.AtumBlocks;
import com.teammetallurgy.atum.world.DimensionHelper;
import com.teammetallurgy.atum.world.gen.structure.StructureHelper;
import net.minecraft.util.Rotation;
import net.minecraft.util.SharedSeedRandom;
Expand Down Expand Up @@ -31,7 +32,7 @@ public GirafiTombStructure(Codec<NoFeatureConfig> config) {

@Override
protected boolean func_230363_a_(@Nonnull ChunkGenerator generator, @Nonnull BiomeProvider provider, long seed, @Nonnull SharedSeedRandom seedRandom, int chunkX, int chunkZ, @Nonnull Biome biome, @Nonnull ChunkPos chunkPos, @Nonnull NoFeatureConfig config) {
for (Biome b : provider.getBiomes(chunkX * 16 + 9, generator.getSeaLevel(), chunkZ * 16 + 9, 20)) {
for (Biome b : provider.getBiomes(chunkX * 16 + 9, DimensionHelper.GROUND_LEVEL, chunkZ * 16 + 9, 20)) {
if (!b.getGenerationSettings().hasStructure(this)) {
return false;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mojang.serialization.Codec;
import com.teammetallurgy.atum.init.AtumBlocks;
import com.teammetallurgy.atum.init.AtumEntities;
import com.teammetallurgy.atum.world.DimensionHelper;
import com.teammetallurgy.atum.world.gen.structure.StructureHelper;
import net.minecraft.util.Rotation;
import net.minecraft.util.SharedSeedRandom;
Expand Down Expand Up @@ -47,7 +48,7 @@ public boolean getDefaultRestrictsSpawnsToInside() {

@Override
protected boolean func_230363_a_(@Nonnull ChunkGenerator generator, @Nonnull BiomeProvider provider, long seed, @Nonnull SharedSeedRandom seedRandom, int chunkX, int chunkZ, @Nonnull Biome biome, @Nonnull ChunkPos chunkPos, @Nonnull NoFeatureConfig config) {
for (Biome b : provider.getBiomes(chunkX * 16 + 9, generator.getSeaLevel(), chunkZ * 16 + 9, 12)) {
for (Biome b : provider.getBiomes(chunkX * 16 + 9, DimensionHelper.GROUND_LEVEL, chunkZ * 16 + 9, 12)) {
if (!b.getGenerationSettings().hasStructure(this)) {
return false;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.teammetallurgy.atum.init.AtumStructures;
import com.teammetallurgy.atum.network.NetworkHandler;
import com.teammetallurgy.atum.network.packet.SyncHandStackSizePacket;
import com.teammetallurgy.atum.world.DimensionHelper;
import com.teammetallurgy.atum.world.gen.structure.StructureHelper;
import net.minecraft.block.Block;
import net.minecraft.block.TorchBlock;
Expand Down Expand Up @@ -54,7 +55,7 @@ protected boolean func_230365_b_() {

@Override
protected boolean func_230363_a_(@Nonnull ChunkGenerator generator, @Nonnull BiomeProvider provider, long seed, @Nonnull SharedSeedRandom seedRandom, int chunkX, int chunkZ, @Nonnull Biome biome, @Nonnull ChunkPos chunkPos, @Nonnull NoFeatureConfig config) {
for (Biome b : provider.getBiomes(chunkX * 16 + 9, generator.getSeaLevel(), chunkZ * 16 + 9, 32)) {
for (Biome b : provider.getBiomes(chunkX * 16 + 9, DimensionHelper.GROUND_LEVEL, chunkZ * 16 + 9, 32)) {
if (!b.getGenerationSettings().hasStructure(this)) {
return false;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.serialization.Codec;
import com.teammetallurgy.atum.init.AtumBlocks;
import com.teammetallurgy.atum.world.DimensionHelper;
import com.teammetallurgy.atum.world.gen.structure.StructureHelper;
import net.minecraft.util.Rotation;
import net.minecraft.util.SharedSeedRandom;
Expand Down Expand Up @@ -31,7 +32,7 @@ public RuinStructure(Codec<NoFeatureConfig> config) {

@Override
protected boolean func_230363_a_(@Nonnull ChunkGenerator generator, @Nonnull BiomeProvider provider, long seed, @Nonnull SharedSeedRandom seedRandom, int chunkX, int chunkZ, @Nonnull Biome biome, @Nonnull ChunkPos chunkPos, @Nonnull NoFeatureConfig config) {
for (Biome b : provider.getBiomes(chunkX * 16 + 9, generator.getSeaLevel(), chunkZ * 16 + 9, 17)) {
for (Biome b : provider.getBiomes(chunkX * 16 + 9, DimensionHelper.GROUND_LEVEL, chunkZ * 16 + 9, 17)) {
if (!b.getGenerationSettings().hasStructure(this)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.teammetallurgy.atum.world.gen.structure.tomb;

import com.mojang.serialization.Codec;
import com.teammetallurgy.atum.world.DimensionHelper;
import com.teammetallurgy.atum.world.gen.structure.StructureHelper;
import net.minecraft.util.Rotation;
import net.minecraft.util.SharedSeedRandom;
Expand All @@ -26,8 +27,8 @@ public TombStructure(Codec<NoFeatureConfig> config) {
}

@Override
protected boolean func_230363_a_(ChunkGenerator generator, BiomeProvider provider, long seed, @Nonnull SharedSeedRandom seedRandom, int chunkX, int chunkZ, @Nonnull Biome biome, @Nonnull ChunkPos chunkPos, @Nonnull NoFeatureConfig config) {
for (Biome b : provider.getBiomes(chunkX * 16 + 9, generator.getSeaLevel(), chunkZ * 16 + 9, 16)) {
protected boolean func_230363_a_(@Nonnull ChunkGenerator generator, BiomeProvider provider, long seed, @Nonnull SharedSeedRandom seedRandom, int chunkX, int chunkZ, @Nonnull Biome biome, @Nonnull ChunkPos chunkPos, @Nonnull NoFeatureConfig config) {
for (Biome b : provider.getBiomes(chunkX * 16 + 9, DimensionHelper.GROUND_LEVEL, chunkZ * 16 + 9, 16)) {
if (!b.getGenerationSettings().hasStructure(this)) {
return false;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"bedrock_roof_position": -10,
"bedrock_floor_position": 0,
"sea_level": 63,
"sea_level": 58,
"disable_mob_generation": false,
"structures": {
"structures": {
Expand Down Expand Up @@ -74,6 +74,9 @@
"Name": "atum:limestone"
},
"default_fluid": {
"Name": "minecraft:air"
"Properties": {
"level": "0"
},
"Name": "minecraft:water"
}
}

0 comments on commit 27572f7

Please sign in to comment.