End lily water fix, some cleanup
This commit is contained in:
parent
04eb5f9dff
commit
11a0d52061
8 changed files with 118 additions and 31 deletions
|
@ -9,6 +9,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
|
@ -19,9 +20,11 @@ import net.minecraft.sound.BlockSoundGroup;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.WorldAccess;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.blocks.basis.BlockUnderwaterPlant;
|
import ru.betterend.blocks.basis.BlockUnderwaterPlant;
|
||||||
|
@ -43,6 +46,16 @@ public class BlockEndLily extends BlockUnderwaterPlant {
|
||||||
.noCollision());
|
.noCollision());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||||
|
if (!canPlaceAt(state, world, pos)) {
|
||||||
|
return state.get(SHAPE) == TripleShape.TOP ? Blocks.AIR.getDefaultState() : Blocks.WATER.getDefaultState();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
Vec3d vec3d = state.getModelOffset(view, pos);
|
Vec3d vec3d = state.getModelOffset(view, pos);
|
||||||
|
|
|
@ -24,8 +24,7 @@ public class LocateCommandMixin {
|
||||||
private static SimpleCommandExceptionType FAILED_EXCEPTION;
|
private static SimpleCommandExceptionType FAILED_EXCEPTION;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public static int sendCoordinates(ServerCommandSource source, String structure, BlockPos sourcePos,
|
public static int sendCoordinates(ServerCommandSource source, String structure, BlockPos sourcePos, BlockPos structurePos, String successMessage) {
|
||||||
BlockPos structurePos, String successMessage) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +35,8 @@ public class LocateCommandMixin {
|
||||||
BlockPos blockPos2 = StructureHelper.getNearestStructure(structureFeature, source.getWorld(), blockPos, 100);
|
BlockPos blockPos2 = StructureHelper.getNearestStructure(structureFeature, source.getWorld(), blockPos, 100);
|
||||||
if (blockPos2 == null) {
|
if (blockPos2 == null) {
|
||||||
throw FAILED_EXCEPTION.create();
|
throw FAILED_EXCEPTION.create();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
info.setReturnValue(sendCoordinates(source, structureFeature.getName(), blockPos, blockPos2, "commands.locate.success"));
|
info.setReturnValue(sendCoordinates(source, structureFeature.getName(), blockPos, blockPos2, "commands.locate.success"));
|
||||||
info.cancel();
|
info.cancel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,19 @@ public class BlocksHelper {
|
||||||
|
|
||||||
// Liquids
|
// Liquids
|
||||||
if (!state.getFluidState().isEmpty()) {
|
if (!state.getFluidState().isEmpty()) {
|
||||||
continue;
|
POS.setY(y - 1);
|
||||||
|
if (world.isAir(POS)) {
|
||||||
|
POS.setY(y);
|
||||||
|
while (!world.getFluidState(POS).isEmpty()) {
|
||||||
|
setWithoutUpdate(world, POS, AIR);
|
||||||
|
POS.setY(POS.getY() + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else for (Direction dir: HORIZONTAL) {
|
||||||
|
if (world.getBlockState(POS.offset(dir)).getMaterial().isReplaceable()) {
|
||||||
|
world.getFluidTickScheduler().schedule(POS, state.getFluidState().getFluid(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Falling blocks
|
// Falling blocks
|
||||||
else if (state.getBlock() instanceof FallingBlock) {
|
else if (state.getBlock() instanceof FallingBlock) {
|
||||||
|
|
|
@ -158,9 +158,9 @@ public class EndLakeFeature extends DefaultFeature {
|
||||||
state = world.getBlockState(POS.up());
|
state = world.getBlockState(POS.up());
|
||||||
state = canReplace(state) ? (y < waterLevel ? WATER : AIR) : state;
|
state = canReplace(state) ? (y < waterLevel ? WATER : AIR) : state;
|
||||||
BlocksHelper.setWithoutUpdate(world, POS, 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);
|
world.getFluidTickScheduler().schedule(POS, state.getFluidState().getFluid(), 0);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
pos = POS.down();
|
pos = POS.down();
|
||||||
if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||||
|
@ -169,9 +169,9 @@ public class EndLakeFeature extends DefaultFeature {
|
||||||
pos = POS.up();
|
pos = POS.up();
|
||||||
while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState().isEmpty()) {
|
while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState().isEmpty()) {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
|
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);
|
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
|
||||||
}
|
}*/
|
||||||
pos = pos.up();
|
pos = pos.up();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Set;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
import net.minecraft.client.util.math.Vector3f;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -37,8 +38,8 @@ public class RoundCaveFeature extends DefaultFeature {
|
||||||
}
|
}
|
||||||
|
|
||||||
int radius = MHelper.randRange(10, 30, random);
|
int radius = MHelper.randRange(10, 30, random);
|
||||||
int bottom = BlocksHelper.upRay(world, new BlockPos(pos.getX(), 0, pos.getZ()), 32) + 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;
|
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE, pos.getX(), pos.getZ()) - radius - 5;
|
||||||
|
|
||||||
Mutable bpos = new Mutable();
|
Mutable bpos = new Mutable();
|
||||||
bpos.setX(pos.getX());
|
bpos.setX(pos.getX());
|
||||||
|
@ -56,12 +57,12 @@ public class RoundCaveFeature extends DefaultFeature {
|
||||||
|
|
||||||
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, pos.getX(), pos.getZ()));
|
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, pos.getX(), pos.getZ()));
|
||||||
|
|
||||||
int x1 = pos.getX() - radius;
|
int x1 = pos.getX() - radius - 5;
|
||||||
int z1 = pos.getZ() - radius;
|
int z1 = pos.getZ() - radius - 5;
|
||||||
int x2 = pos.getX() + radius;
|
int x2 = pos.getX() + radius + 5;
|
||||||
int z2 = pos.getZ() + radius;
|
int z2 = pos.getZ() + radius + 5;
|
||||||
int y1 = MHelper.floor(pos.getY() - radius / 1.6);
|
int y1 = MHelper.floor(pos.getY() - (radius + 5) / 1.6);
|
||||||
int y2 = MHelper.floor(pos.getY() + radius / 1.6);
|
int y2 = MHelper.floor(pos.getY() + (radius + 5) / 1.6);
|
||||||
|
|
||||||
double hr = radius * 0.75;
|
double hr = radius * 0.75;
|
||||||
double nr = radius * 0.25;
|
double nr = radius * 0.25;
|
||||||
|
@ -82,6 +83,7 @@ public class RoundCaveFeature extends DefaultFeature {
|
||||||
ysq *= ysq;
|
ysq *= ysq;
|
||||||
bpos.setY(y);
|
bpos.setY(y);
|
||||||
double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr;
|
double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr;
|
||||||
|
double r2 = r + 5;
|
||||||
double dist = xsq + ysq + zsq;
|
double dist = xsq + ysq + zsq;
|
||||||
if (dist < r * r) {
|
if (dist < r * r) {
|
||||||
BlockState state = world.getBlockState(bpos);
|
BlockState state = world.getBlockState(bpos);
|
||||||
|
@ -106,17 +108,23 @@ public class RoundCaveFeature extends DefaultFeature {
|
||||||
BlocksHelper.setWithoutUpdate(world, bpos, terrain);
|
BlocksHelper.setWithoutUpdate(world, bpos, terrain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (world.getBlockState(bpos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
else if (dist < r2 * r2) {
|
||||||
if (world.isAir(bpos.down())) {
|
BlockState state = world.getBlockState(bpos);
|
||||||
int h = BlocksHelper.downRay(world, bpos.down(), 64);
|
if (!state.getFluidState().isEmpty()) {
|
||||||
if (h > 6 && h < 32 && world.getBlockState(bpos.down(h + 3)).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
BlocksHelper.setWithoutUpdate(world, bpos, Blocks.END_STONE.getDefaultState());
|
||||||
bushes.add(bpos.down());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (world.isAir(bpos.up())) {
|
else if (world.getBlockState(bpos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||||
int h = BlocksHelper.upRay(world, bpos.up(), 64);
|
if (world.isAir(bpos.down())) {
|
||||||
if (h > 6 && h < 32 && world.getBlockState(bpos.up(h + 3)).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
int h = BlocksHelper.downRay(world, bpos.down(), 64);
|
||||||
bushes.add(bpos.up());
|
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;
|
package ru.betterend.world.structures.piece;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -27,6 +30,7 @@ import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class LakePiece extends BasePiece {
|
public class LakePiece extends BasePiece {
|
||||||
private static final BlockState WATER = Blocks.WATER.getDefaultState();
|
private static final BlockState WATER = Blocks.WATER.getDefaultState();
|
||||||
|
private Map<Integer, Integer> heightmap = Maps.newHashMap();
|
||||||
private OpenSimplexNoise noise;
|
private OpenSimplexNoise noise;
|
||||||
private BlockPos center;
|
private BlockPos center;
|
||||||
private float radius;
|
private float radius;
|
||||||
|
@ -136,14 +140,31 @@ public class LakePiece extends BasePiece {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getHeight(StructureWorldAccess world, BlockPos pos) {
|
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) {
|
if (BiomeRegistry.getFromBiome(world.getBiome(pos)) != BiomeRegistry.MEGALAKE) {
|
||||||
|
heightmap.put(p, -4);
|
||||||
return -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) {
|
if (h < 57) {
|
||||||
|
heightmap.put(p, 0);
|
||||||
return 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) {
|
private float getHeightClamp(StructureWorldAccess world, int radius, int posX, int posZ) {
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package ru.betterend.world.structures.piece;
|
package ru.betterend.world.structures.piece;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtHelper;
|
import net.minecraft.nbt.NbtHelper;
|
||||||
|
@ -20,10 +23,12 @@ import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||||
import ru.betterend.noise.OpenSimplexNoise;
|
import ru.betterend.noise.OpenSimplexNoise;
|
||||||
import ru.betterend.registry.BiomeRegistry;
|
import ru.betterend.registry.BiomeRegistry;
|
||||||
import ru.betterend.registry.BlockRegistry;
|
import ru.betterend.registry.BlockRegistry;
|
||||||
|
import ru.betterend.registry.BlockTagRegistry;
|
||||||
import ru.betterend.registry.StructureRegistry;
|
import ru.betterend.registry.StructureRegistry;
|
||||||
import ru.betterend.util.MHelper;
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class MountainPiece extends BasePiece {
|
public class MountainPiece extends BasePiece {
|
||||||
|
private Map<Integer, Integer> heightmap = Maps.newHashMap();
|
||||||
private OpenSimplexNoise noise;
|
private OpenSimplexNoise noise;
|
||||||
private BlockPos center;
|
private BlockPos center;
|
||||||
private float radius;
|
private float radius;
|
||||||
|
@ -140,14 +145,39 @@ public class MountainPiece extends BasePiece {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getHeight(StructureWorldAccess world, BlockPos pos) {
|
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) {
|
if (BiomeRegistry.getFromBiome(world.getBiome(pos)) != BiomeRegistry.END_HIGHLANDS) {
|
||||||
|
heightmap.put(p, -4);
|
||||||
return -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) {
|
if (h < 57) {
|
||||||
|
heightmap.put(p, 0);
|
||||||
return 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) {
|
private float getHeightClamp(StructureWorldAccess world, int radius, int posX, int posZ) {
|
||||||
|
|
|
@ -181,5 +181,8 @@
|
||||||
"block.betterend.end_lotus_stairs": "End Lotus Stairs",
|
"block.betterend.end_lotus_stairs": "End Lotus Stairs",
|
||||||
"block.betterend.end_lotus_stripped_bark": "End Lotus Stripped Bark",
|
"block.betterend.end_lotus_stripped_bark": "End Lotus Stripped Bark",
|
||||||
"block.betterend.end_lotus_stripped_log": "End Lotus Stripped Log",
|
"block.betterend.end_lotus_stripped_log": "End Lotus Stripped Log",
|
||||||
"block.betterend.end_lotus_trapdoor": "End Lotus Trapdoor"
|
"block.betterend.end_lotus_trapdoor": "End Lotus Trapdoor",
|
||||||
|
|
||||||
|
"block.betterend.flavolite_runed": "Runed Flavolite",
|
||||||
|
"block.betterend.flavolite_runed_eternal": "Eternal Runed Flavolite"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue