Lakes, fixes

This commit is contained in:
paulevsGitch 2020-09-25 01:07:46 +03:00
parent 2061a12aff
commit c9326931d3
8 changed files with 191 additions and 24 deletions

View file

@ -15,6 +15,7 @@ import net.minecraft.client.render.Camera;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.fluid.FluidState; import net.minecraft.fluid.FluidState;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -49,13 +50,19 @@ public class BackgroundRendererMixin {
if (lerp > 1) lerp = 1; if (lerp > 1) lerp = 1;
FluidState fluidState = camera.getSubmergedFluidState(); FluidState fluidState = camera.getSubmergedFluidState();
Entity entity = camera.getFocusedEntity(); if (fluidState.isEmpty() && world.getDimension().hasEnderDragonFight()) {
boolean skip = entity instanceof LivingEntity && ((LivingEntity) entity).getStatusEffect(StatusEffects.NIGHT_VISION).getDuration() > 0; Entity entity = camera.getFocusedEntity();
if (!skip && fluidState.isEmpty() && world.getDimension().hasEnderDragonFight()) { boolean skip = false;
//RenderSystem.clearColor(SKY_RED, SKY_GREEN, SKY_BLUE, 0); if (entity instanceof LivingEntity) {
red *= NORMAL; StatusEffectInstance effect = ((LivingEntity) entity).getStatusEffect(StatusEffects.NIGHT_VISION);
green *= NORMAL; skip = effect != null && effect.getDuration() > 0;
blue *= NORMAL; }
if (!skip) {
//RenderSystem.clearColor(SKY_RED, SKY_GREEN, SKY_BLUE, 0);
red *= NORMAL;
green *= NORMAL;
blue *= NORMAL;
}
} }
} }

View file

@ -1,10 +1,12 @@
package ru.betterend.registry; package ru.betterend.registry;
import ru.betterend.world.features.EndFeature; import ru.betterend.world.features.EndFeature;
import ru.betterend.world.features.EndLakeFeature;
import ru.betterend.world.features.StoneSpiralFeature; import ru.betterend.world.features.StoneSpiralFeature;
public class FeatureRegistry { public class FeatureRegistry {
public static final EndFeature STONE_SPIRAL = new EndFeature("stone_spiral", new StoneSpiralFeature(), 2); public static final EndFeature STONE_SPIRAL = new EndFeature("stone_spiral", new StoneSpiralFeature(), 2);
public static final EndFeature END_LAKE = new EndFeature("end_lake", new EndLakeFeature());
public static void register() {} public static void register() {}
} }

View file

@ -52,4 +52,12 @@ public class MHelper {
public static int floor(double x) { public static int floor(double x) {
return x < 0 ? (int) (x - 1) : (int) x; return x < 0 ? (int) (x - 1) : (int) x;
} }
public static int min(int a, int b) {
return a < b ? a : b;
}
public static int max(int a, int b) {
return a > b ? a : b;
}
} }

View file

@ -47,7 +47,7 @@ public class BiomeDefinition {
private int waterFogColor = 329011; private int waterFogColor = 329011;
private int waterColor = 4159204; private int waterColor = 4159204;
private int fogColor = 3344392; private int fogColor = 10518688;
private float fogDensity = 1F; private float fogDensity = 1F;
private final Identifier id; private final Identifier id;
@ -185,19 +185,23 @@ public class BiomeDefinition {
features.forEach((info) -> generationSettings.feature(info.featureStep, info.feature)); features.forEach((info) -> generationSettings.feature(info.featureStep, info.feature));
effects.skyColor(0).waterColor(waterColor).waterFogColor(waterFogColor).fogColor(fogColor); effects.skyColor(0).waterColor(waterColor).waterFogColor(waterFogColor).fogColor(fogColor);
if (loop != null) if (loop != null) effects.loopSound(loop);
effects.loopSound(loop); if (mood != null) effects.moodSound(mood);
if (mood != null) if (additions != null) effects.additionsSound(additions);
effects.moodSound(mood); if (particleConfig != null) effects.particleConfig(particleConfig);
if (additions != null)
effects.additionsSound(additions);
if (particleConfig != null)
effects.particleConfig(particleConfig);
effects.music(MusicType.createIngameMusic(music != null ? music : SoundEvents.MUSIC_END)); effects.music(MusicType.createIngameMusic(music != null ? music : SoundEvents.MUSIC_END));
return new Biome.Builder().precipitation(Precipitation.NONE).category(Category.THEEND).depth(0.1F).scale(0.2F) return new Biome.Builder()
.temperature(2.0F).downfall(0.0F).effects(effects.build()).spawnSettings(spawnSettings.build()) .precipitation(Precipitation.NONE)
.generationSettings(generationSettings.build()).build(); .category(Category.THEEND)
.depth(0.1F)
.scale(0.2F)
.temperature(2.0F)
.downfall(0.0F)
.effects(effects.build())
.spawnSettings(spawnSettings.build())
.generationSettings(generationSettings.build())
.build();
} }
private static final class SpawnInfo { private static final class SpawnInfo {

View file

@ -1,7 +1,5 @@
package ru.betterend.world.biome; package ru.betterend.world.biome;
import net.minecraft.world.gen.GenerationStep.Feature;
import net.minecraft.world.gen.feature.ConfiguredFeatures;
import ru.betterend.registry.BlockRegistry; import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.FeatureRegistry; import ru.betterend.registry.FeatureRegistry;
@ -14,6 +12,6 @@ public class BiomeFoggyMushroomland extends EndBiome {
.setWaterFogColor(119, 227, 250) .setWaterFogColor(119, 227, 250)
.setSurface(BlockRegistry.END_MOSS, BlockRegistry.END_MYCELIUM) .setSurface(BlockRegistry.END_MOSS, BlockRegistry.END_MYCELIUM)
.addFeature(FeatureRegistry.STONE_SPIRAL) .addFeature(FeatureRegistry.STONE_SPIRAL)
.addFeature(Feature.LAKES, ConfiguredFeatures.LAKE_WATER)); .addFeature(FeatureRegistry.END_LAKE));
} }
} }

View file

@ -1,10 +1,22 @@
package ru.betterend.world.features; package ru.betterend.world.features;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Heightmap.Type;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.Feature;
public abstract class DefaultFeature extends Feature<DefaultFeatureConfig> { public abstract class DefaultFeature extends Feature<DefaultFeatureConfig> {
protected static final BlockState AIR = Blocks.AIR.getDefaultState();
protected static final BlockState WATER = Blocks.WATER.getDefaultState();
public DefaultFeature() { public DefaultFeature() {
super(DefaultFeatureConfig.CODEC); super(DefaultFeatureConfig.CODEC);
} }
protected BlockPos getTopPos(StructureWorldAccess world, BlockPos pos) {
return world.getTopPosition(Type.WORLD_SURFACE, pos);
}
} }

View file

@ -0,0 +1,138 @@
package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class EndLakeFeature extends DefaultFeature {
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152);
private static final Mutable POS = new Mutable();
@Override
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig featureConfig) {
double radius = MHelper.randRange(10.0, 20.0, random);
double depth = radius * 0.5 * MHelper.randRange(0.8, 1.2, random);
int dist = MHelper.floor(radius);
int dist2 = MHelper.floor(radius * 1.5);
int bott = MHelper.floor(depth);
blockPos = getTopPos(world, blockPos);
if (blockPos.getY() < 10) return false;
int waterLevel = blockPos.getY();
BlockPos pos = getTopPos(world, blockPos.north(dist));
if (pos.getY() < 10) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getTopPos(world, blockPos.south(dist));
if (pos.getY() < 10) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getTopPos(world, blockPos.east(dist));
if (pos.getY() < 10) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
pos = getTopPos(world, blockPos.west(dist));
if (pos.getY() < 10) return false;
waterLevel = MHelper.min(pos.getY(), waterLevel);
int minX = MHelper.floor((blockPos.getX() - dist - 16) >> 4) << 4;
int minZ = MHelper.floor((blockPos.getZ() - dist - 16) >> 4) << 4;
int maxX = MHelper.floor((blockPos.getX() + dist + 16) >> 4) << 4;
int maxZ = MHelper.floor((blockPos.getZ() + dist + 16) >> 4) << 4;
for (int y = blockPos.getY(); y <= blockPos.getY() + 10; y++) {
POS.setY(y);
for (int x = minX; x <= maxX; x++) {
POS.setX(x);
for (int z = minZ; z <= maxZ; z++) {
POS.setZ(z);
if (!world.getFluidState(POS).isEmpty())
BlocksHelper.setWithoutUpdate(world, POS, AIR);
}
}
}
for (int y = blockPos.getY(); y <= blockPos.getY() + 10; y++) {
POS.setY(y);
int add = y - blockPos.getY();
for (int x = blockPos.getX() - dist2; x <= blockPos.getX() + dist2; x++) {
POS.setX(x);
int x2 = x - blockPos.getX();
x2 *= x2;
for (int z = blockPos.getZ() - dist2; z <= blockPos.getZ() + dist2; z++) {
POS.setZ(z);
int z2 = z - blockPos.getZ();
z2 *= z2;
double r = add * 1.5 + radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75);
r *= r;
if (x2 + z2 <= r) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
pos = POS.down();
if (world.getBlockState(pos).getBlock() == Blocks.END_STONE)
{
BlockState state = world.getBiome(POS).getGenerationSettings().getSurfaceConfig().getTopMaterial();
if (y > waterLevel + 1)
BlocksHelper.setWithoutUpdate(world, POS.down(), state);
else if (y > waterLevel)
BlocksHelper.setWithoutUpdate(world, POS.down(), random.nextBoolean() ? state : BlockRegistry.ENDSTONE_DUST.getDefaultState());
else
BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState());
}
pos = POS.up();
if (!world.getBlockState(pos).isAir()) {
while (!world.getBlockState(pos).isAir()) {
BlocksHelper.setWithoutUpdate(world, pos, AIR);
pos = pos.up();
}
}
}
}
}
}
double aspect = ((double) radius / (double) depth);
for (int y = blockPos.getY() - bott; y < blockPos.getY(); y++) {
POS.setY(y);
double y2 = (double) (y - blockPos.getY()) * aspect;
y2 *= y2;
for (int x = blockPos.getX() - dist; x <= blockPos.getX() + dist; x++) {
POS.setX(x);
int x2 = x - blockPos.getX();
x2 *= x2;
for (int z = blockPos.getZ() - dist; z <= blockPos.getZ() + dist; z++) {
POS.setZ(z);
int z2 = z - blockPos.getZ();
z2 *= z2;
double r = radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75);
r *= r;
if (y2 + x2 + z2 <= r) {
BlocksHelper.setWithoutUpdate(world, POS, y < waterLevel ? WATER : AIR);
pos = POS.down();
if (world.getBlockState(pos).getBlock() == Blocks.END_STONE)
BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState());
pos = POS.up();
if (!world.getBlockState(pos).isAir()) {
while (!world.getBlockState(pos).isAir()) {
BlocksHelper.setWithoutUpdate(world, pos, y < waterLevel ? WATER : AIR);
pos = pos.up();
}
}
}
}
}
}
return true;
}
}

View file

@ -15,8 +15,6 @@ public class StoneSpiralFeature extends DefaultFeature {
public boolean generate(StructureWorldAccess world, ChunkGenerator generator, Random random, BlockPos pos, DefaultFeatureConfig config) { public boolean generate(StructureWorldAccess world, ChunkGenerator generator, Random random, BlockPos pos, DefaultFeatureConfig config) {
BlockPos topPos = world.getTopPosition(Type.WORLD_SURFACE, pos); BlockPos topPos = world.getTopPosition(Type.WORLD_SURFACE, pos);
Direction offset = Direction.NORTH; Direction offset = Direction.NORTH;
System.out.println(topPos);
for (int y = 1; y <= 15; y++) { for (int y = 1; y <= 15; y++) {
offset = offset.rotateYClockwise(); offset = offset.rotateYClockwise();