More fixes

This commit is contained in:
paulevsGitch 2020-10-04 15:06:21 +03:00
parent 26eb6165a7
commit e7a6bdaa93

View file

@ -7,6 +7,7 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FallingBlock;
import net.minecraft.state.property.Property;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
@ -114,7 +115,6 @@ public class BlocksHelper {
}
public static void fixBlocks(WorldAccess world, BlockPos start, BlockPos end) {
synchronized (world) {
BlockState state;
for (int x = start.getX(); x <= end.getX(); x++) {
POS.setX(x);
@ -123,7 +123,50 @@ public class BlocksHelper {
for (int y = start.getY(); y <= end.getY(); y++) {
POS.setY(y);
state = world.getBlockState(POS);
if (!state.canPlaceAt(world, POS)) {
// Falling blocks
if (state.getBlock() instanceof FallingBlock) {
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
if (state.getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.END_STONE.getDefaultState());
if (world.getRandom().nextBoolean()) {
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
if (state.getMaterial().isReplaceable()) {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.END_STONE.getDefaultState());
}
}
}
}
// Fluid fixes
else if (!state.getFluidState().isEmpty()) {
BlockState liquid = state;
BlockPos pos = POS.down();
state = world.getBlockState(pos);
boolean update = state.getMaterial().isReplaceable() && !state.getMaterial().isLiquid();
pos = POS.north();
state = world.getBlockState(pos);
update |= state.getMaterial().isReplaceable() && state.getFluidState().isEmpty();
pos = POS.south();
state = world.getBlockState(pos);
update |= state.getMaterial().isReplaceable() && state.getFluidState().isEmpty();
pos = POS.east();
state = world.getBlockState(pos);
update |= state.getMaterial().isReplaceable() && state.getFluidState().isEmpty();
pos = POS.west();
state = world.getBlockState(pos);
update |= state.getMaterial().isReplaceable() && state.getFluidState().isEmpty();
if (update) {
world.setBlockState(POS, liquid, 1 | 2 | 8);
}
}
else if (!state.canPlaceAt(world, POS)) {
// Is blue Vine
if (state.getBlock() instanceof BlockBlueVine) {
while (!state.canPlaceAt(world, POS)) {
@ -155,4 +198,3 @@ public class BlocksHelper {
}
}
}
}