End lily water fix, some cleanup
This commit is contained in:
parent
04eb5f9dff
commit
11a0d52061
8 changed files with 118 additions and 31 deletions
|
@ -158,9 +158,9 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
state = world.getBlockState(POS.up());
|
||||
state = canReplace(state) ? (y < waterLevel ? WATER : AIR) : state;
|
||||
BlocksHelper.setWithoutUpdate(world, POS, state);
|
||||
if (y == waterLevel - 1 && !state.getFluidState().isEmpty()) {
|
||||
/*if (y == waterLevel - 1 && !state.getFluidState().isEmpty()) {
|
||||
world.getFluidTickScheduler().schedule(POS, state.getFluidState().getFluid(), 0);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
pos = POS.down();
|
||||
if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
|
@ -169,9 +169,9 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
pos = POS.up();
|
||||
while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState().isEmpty()) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
|
||||
if (y == waterLevel - 1) {
|
||||
/*if (y == waterLevel - 1) {
|
||||
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
|
||||
}
|
||||
}*/
|
||||
pos = pos.up();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Set;
|
|||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -37,8 +38,8 @@ public class RoundCaveFeature extends DefaultFeature {
|
|||
}
|
||||
|
||||
int radius = MHelper.randRange(10, 30, random);
|
||||
int bottom = BlocksHelper.upRay(world, new BlockPos(pos.getX(), 0, pos.getZ()), 32) + radius;
|
||||
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE, pos.getX(), pos.getZ()) - radius;
|
||||
int bottom = BlocksHelper.upRay(world, new BlockPos(pos.getX(), 0, pos.getZ()), 32) + radius + 5;
|
||||
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE, pos.getX(), pos.getZ()) - radius - 5;
|
||||
|
||||
Mutable bpos = new Mutable();
|
||||
bpos.setX(pos.getX());
|
||||
|
@ -56,12 +57,12 @@ public class RoundCaveFeature extends DefaultFeature {
|
|||
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, pos.getX(), pos.getZ()));
|
||||
|
||||
int x1 = pos.getX() - radius;
|
||||
int z1 = pos.getZ() - radius;
|
||||
int x2 = pos.getX() + radius;
|
||||
int z2 = pos.getZ() + radius;
|
||||
int y1 = MHelper.floor(pos.getY() - radius / 1.6);
|
||||
int y2 = MHelper.floor(pos.getY() + radius / 1.6);
|
||||
int x1 = pos.getX() - radius - 5;
|
||||
int z1 = pos.getZ() - radius - 5;
|
||||
int x2 = pos.getX() + radius + 5;
|
||||
int z2 = pos.getZ() + radius + 5;
|
||||
int y1 = MHelper.floor(pos.getY() - (radius + 5) / 1.6);
|
||||
int y2 = MHelper.floor(pos.getY() + (radius + 5) / 1.6);
|
||||
|
||||
double hr = radius * 0.75;
|
||||
double nr = radius * 0.25;
|
||||
|
@ -82,6 +83,7 @@ public class RoundCaveFeature extends DefaultFeature {
|
|||
ysq *= ysq;
|
||||
bpos.setY(y);
|
||||
double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr;
|
||||
double r2 = r + 5;
|
||||
double dist = xsq + ysq + zsq;
|
||||
if (dist < r * r) {
|
||||
BlockState state = world.getBlockState(bpos);
|
||||
|
@ -106,17 +108,23 @@ public class RoundCaveFeature extends DefaultFeature {
|
|||
BlocksHelper.setWithoutUpdate(world, bpos, terrain);
|
||||
}
|
||||
}
|
||||
else if (world.getBlockState(bpos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
if (world.isAir(bpos.down())) {
|
||||
int h = BlocksHelper.downRay(world, bpos.down(), 64);
|
||||
if (h > 6 && h < 32 && world.getBlockState(bpos.down(h + 3)).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
bushes.add(bpos.down());
|
||||
}
|
||||
else if (dist < r2 * r2) {
|
||||
BlockState state = world.getBlockState(bpos);
|
||||
if (!state.getFluidState().isEmpty()) {
|
||||
BlocksHelper.setWithoutUpdate(world, bpos, Blocks.END_STONE.getDefaultState());
|
||||
}
|
||||
else if (world.isAir(bpos.up())) {
|
||||
int h = BlocksHelper.upRay(world, bpos.up(), 64);
|
||||
if (h > 6 && h < 32 && world.getBlockState(bpos.up(h + 3)).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
bushes.add(bpos.up());
|
||||
else if (world.getBlockState(bpos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
if (world.isAir(bpos.down())) {
|
||||
int h = BlocksHelper.downRay(world, bpos.down(), 64);
|
||||
if (h > 6 && h < 32 && world.getBlockState(bpos.down(h + 3)).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
bushes.add(bpos.down());
|
||||
}
|
||||
}
|
||||
else if (world.isAir(bpos.up())) {
|
||||
int h = BlocksHelper.upRay(world, bpos.up(), 64);
|
||||
if (h > 6 && h < 32 && world.getBlockState(bpos.up(h + 3)).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
bushes.add(bpos.up());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package ru.betterend.world.structures.piece;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -27,6 +30,7 @@ import ru.betterend.util.MHelper;
|
|||
|
||||
public class LakePiece extends BasePiece {
|
||||
private static final BlockState WATER = Blocks.WATER.getDefaultState();
|
||||
private Map<Integer, Integer> heightmap = Maps.newHashMap();
|
||||
private OpenSimplexNoise noise;
|
||||
private BlockPos center;
|
||||
private float radius;
|
||||
|
@ -136,14 +140,31 @@ public class LakePiece extends BasePiece {
|
|||
}
|
||||
|
||||
private int getHeight(StructureWorldAccess world, BlockPos pos) {
|
||||
int p = ((pos.getX() & 2047) << 11) | (pos.getZ() & 2047);
|
||||
int h = heightmap.getOrDefault(p, Integer.MIN_VALUE);
|
||||
if (h > Integer.MIN_VALUE) {
|
||||
return h;
|
||||
}
|
||||
|
||||
if (BiomeRegistry.getFromBiome(world.getBiome(pos)) != BiomeRegistry.MEGALAKE) {
|
||||
heightmap.put(p, -4);
|
||||
return -4;
|
||||
}
|
||||
int h = world.getTopY(Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
|
||||
h = world.getTopY(Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
|
||||
if (h < 57) {
|
||||
heightmap.put(p, 0);
|
||||
return 0;
|
||||
}
|
||||
return h - 57;
|
||||
h -= 57;
|
||||
|
||||
if (h < 0) {
|
||||
heightmap.put(p, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
heightmap.put(p, h);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
private float getHeightClamp(StructureWorldAccess world, int radius, int posX, int posZ) {
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package ru.betterend.world.structures.piece;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtHelper;
|
||||
|
@ -20,10 +23,12 @@ import net.minecraft.world.gen.chunk.ChunkGenerator;
|
|||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.BiomeRegistry;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.registry.BlockTagRegistry;
|
||||
import ru.betterend.registry.StructureRegistry;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
public class MountainPiece extends BasePiece {
|
||||
private Map<Integer, Integer> heightmap = Maps.newHashMap();
|
||||
private OpenSimplexNoise noise;
|
||||
private BlockPos center;
|
||||
private float radius;
|
||||
|
@ -140,14 +145,39 @@ public class MountainPiece extends BasePiece {
|
|||
}
|
||||
|
||||
private int getHeight(StructureWorldAccess world, BlockPos pos) {
|
||||
int p = ((pos.getX() & 2047) << 11) | (pos.getZ() & 2047);
|
||||
int h = heightmap.getOrDefault(p, Integer.MIN_VALUE);
|
||||
if (h > Integer.MIN_VALUE) {
|
||||
return h;
|
||||
}
|
||||
|
||||
if (BiomeRegistry.getFromBiome(world.getBiome(pos)) != BiomeRegistry.END_HIGHLANDS) {
|
||||
heightmap.put(p, -4);
|
||||
return -4;
|
||||
}
|
||||
int h = world.getTopY(Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
|
||||
h = world.getTopY(Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
|
||||
if (h < 57) {
|
||||
heightmap.put(p, 0);
|
||||
return 0;
|
||||
}
|
||||
return h - 57;
|
||||
|
||||
Mutable m = new Mutable();
|
||||
m.set(pos.getX(), h - 1, pos.getZ());
|
||||
while (h > 56 && world.getBlockState(pos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||
m.setY(m.getY() - 1);
|
||||
}
|
||||
h = m.getY();
|
||||
|
||||
h -= 57;
|
||||
|
||||
if (h < 0) {
|
||||
heightmap.put(p, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
heightmap.put(p, h);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
private float getHeightClamp(StructureWorldAccess world, int radius, int posX, int posZ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue