Fixes
This commit is contained in:
parent
a7c3563b52
commit
14756c0ccf
2 changed files with 29 additions and 10 deletions
|
@ -6,11 +6,13 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtIo;
|
import net.minecraft.nbt.NbtIo;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.structure.Structure;
|
import net.minecraft.structure.Structure;
|
||||||
import net.minecraft.structure.StructurePlacementData;
|
import net.minecraft.structure.StructurePlacementData;
|
||||||
|
import net.minecraft.tag.BlockTags;
|
||||||
import net.minecraft.util.BlockMirror;
|
import net.minecraft.util.BlockMirror;
|
||||||
import net.minecraft.util.BlockRotation;
|
import net.minecraft.util.BlockRotation;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -81,6 +83,7 @@ public class StructureHelper {
|
||||||
|
|
||||||
public static void erode(StructureWorldAccess world, BlockBox bounds, int iterations, Random random) {
|
public static void erode(StructureWorldAccess world, BlockBox bounds, int iterations, Random random) {
|
||||||
Mutable mut = new Mutable();
|
Mutable mut = new Mutable();
|
||||||
|
boolean canDestruct = true;
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
for (int x = bounds.minX; x <= bounds.maxX; x++) {
|
for (int x = bounds.minX; x <= bounds.maxX; x++) {
|
||||||
mut.setX(x);
|
mut.setX(x);
|
||||||
|
@ -89,17 +92,17 @@ public class StructureHelper {
|
||||||
for (int y = bounds.maxY; y >= bounds.minY; y--) {
|
for (int y = bounds.maxY; y >= bounds.minY; y--) {
|
||||||
mut.setY(y);
|
mut.setY(y);
|
||||||
BlockState state = world.getBlockState(mut);
|
BlockState state = world.getBlockState(mut);
|
||||||
if (state.isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL) && random.nextInt(8) == 0 && world.isAir(mut.down(2))) {
|
if (canDestruct && state.isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL) && random.nextInt(8) == 0 && world.isAir(mut.down(2))) {
|
||||||
int r = MHelper.randRange(1, 3, random);
|
int r = MHelper.randRange(1, 4, random);
|
||||||
int cx = mut.getX();
|
int cx = mut.getX();
|
||||||
int cy = mut.getY();
|
int cy = mut.getY();
|
||||||
int cz = mut.getZ();
|
int cz = mut.getZ();
|
||||||
int x1 = mut.getX() - r;
|
int x1 = cx - r;
|
||||||
int y1 = mut.getY() - r;
|
int y1 = cy - r;
|
||||||
int z1 = mut.getZ() - r;
|
int z1 = cz - r;
|
||||||
int x2 = mut.getX() - r;
|
int x2 = cx + r;
|
||||||
int y2 = mut.getY() - r;
|
int y2 = cy + r;
|
||||||
int z2 = mut.getZ() - r;
|
int z2 = cz + r;
|
||||||
for (int px = x1; px <= x2; px++) {
|
for (int px = x1; px <= x2; px++) {
|
||||||
int dx = px - cx;
|
int dx = px - cx;
|
||||||
dx *= dx;
|
dx *= dx;
|
||||||
|
@ -121,9 +124,10 @@ public class StructureHelper {
|
||||||
mut.setX(cx);
|
mut.setX(cx);
|
||||||
mut.setY(cy);
|
mut.setY(cy);
|
||||||
mut.setZ(cz);
|
mut.setZ(cz);
|
||||||
|
canDestruct = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (state.isIn(EndTags.END_GROUND) || state.isOf(EndBlocks.ETERNAL_PEDESTAL) || state.isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL)) {
|
else if (ignore(state)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!state.isAir() && random.nextBoolean()) {
|
if (!state.isAir() && random.nextBoolean()) {
|
||||||
|
@ -158,7 +162,7 @@ public class StructureHelper {
|
||||||
for (int y = bounds.maxY; y >= bounds.minY; y--) {
|
for (int y = bounds.maxY; y >= bounds.minY; y--) {
|
||||||
mut.setY(y);
|
mut.setY(y);
|
||||||
BlockState state = world.getBlockState(mut);
|
BlockState state = world.getBlockState(mut);
|
||||||
if (!state.isIn(EndTags.END_GROUND) && !state.isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL) && !state.isAir() && world.isAir(mut.down())) {
|
if (!ignore(state) && world.isAir(mut.down())) {
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
|
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
|
||||||
for (int py = mut.getY(); y >= bounds.minY - 10; y--) {
|
for (int py = mut.getY(); y >= bounds.minY - 10; y--) {
|
||||||
mut.setY(py - 1);
|
mut.setY(py - 1);
|
||||||
|
@ -174,6 +178,16 @@ public class StructureHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean ignore(BlockState state) {
|
||||||
|
return state.isAir()
|
||||||
|
|| state.isIn(EndTags.END_GROUND)
|
||||||
|
|| state.isOf(EndBlocks.ETERNAL_PEDESTAL)
|
||||||
|
|| state.isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL)
|
||||||
|
|| state.isIn(BlockTags.LOGS)
|
||||||
|
|| state.isIn(BlockTags.LEAVES)
|
||||||
|
|| state.getMaterial().equals(Material.PLANT);
|
||||||
|
}
|
||||||
|
|
||||||
private static void shuffle(Random random) {
|
private static void shuffle(Random random) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int j = random.nextInt(4);
|
int j = random.nextInt(4);
|
||||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.world.StructureWorldAccess;
|
||||||
import net.minecraft.world.gen.StructureAccessor;
|
import net.minecraft.world.gen.StructureAccessor;
|
||||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||||
import ru.betterend.registry.EndStructures;
|
import ru.betterend.registry.EndStructures;
|
||||||
|
import ru.betterend.util.MHelper;
|
||||||
import ru.betterend.util.StructureHelper;
|
import ru.betterend.util.StructureHelper;
|
||||||
|
|
||||||
public class NBTPiece extends BasePiece {
|
public class NBTPiece extends BasePiece {
|
||||||
|
@ -74,6 +75,10 @@ public class NBTPiece extends BasePiece {
|
||||||
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
|
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
|
||||||
structure.place(world, pos, placementData, random);
|
structure.place(world, pos, placementData, random);
|
||||||
if (erosion > 0) {
|
if (erosion > 0) {
|
||||||
|
bounds.maxX = MHelper.min(bounds.maxX, boundingBox.maxX);
|
||||||
|
bounds.minX = MHelper.max(bounds.minX, boundingBox.minX);
|
||||||
|
bounds.maxZ = MHelper.min(bounds.maxZ, boundingBox.maxZ);
|
||||||
|
bounds.minZ = MHelper.max(bounds.minZ, boundingBox.minZ);
|
||||||
StructureHelper.erode(world, bounds, erosion, random);
|
StructureHelper.erode(world, bounds, erosion, random);
|
||||||
}
|
}
|
||||||
if (cover) {
|
if (cover) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue