Erosion fix
This commit is contained in:
parent
3ad779b030
commit
99f5a20d0b
3 changed files with 22 additions and 5 deletions
|
@ -85,6 +85,18 @@ public class StructureHelper {
|
||||||
return new BlockBox(min.add(pos), max.add(pos));
|
return new BlockBox(min.add(pos), max.add(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BlockBox intersectBoxes(BlockBox box1, BlockBox box2) {
|
||||||
|
int x1 = MHelper.max(box1.minX, box2.minX);
|
||||||
|
int y1 = MHelper.max(box1.minY, box2.minY);
|
||||||
|
int z1 = MHelper.max(box1.minZ, box2.minZ);
|
||||||
|
|
||||||
|
int x2 = MHelper.min(box1.maxX, box2.maxX);
|
||||||
|
int y2 = MHelper.min(box1.maxY, box2.maxY);
|
||||||
|
int z2 = MHelper.min(box1.maxZ, box2.maxZ);
|
||||||
|
|
||||||
|
return BlockBox.create(x1, y1, z1, x2, y2, z2);
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
boolean canDestruct = true;
|
||||||
|
@ -209,7 +221,7 @@ public class StructureHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (random.nextInt(8) == 0 && !world.getBlockState(mut.up()).isOf(EndBlocks.ETERNAL_PEDESTAL)) {
|
else if (random.nextInt(8) == 0) {
|
||||||
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
|
BlocksHelper.setWithoutUpdate(world, mut, Blocks.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +319,9 @@ public class StructureHelper {
|
||||||
|| state.isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL)
|
|| state.isOf(EndBlocks.FLAVOLITE_RUNED_ETERNAL)
|
||||||
|| state.isIn(BlockTags.LOGS)
|
|| state.isIn(BlockTags.LOGS)
|
||||||
|| state.isIn(BlockTags.LEAVES)
|
|| state.isIn(BlockTags.LEAVES)
|
||||||
|| state.getMaterial().equals(Material.PLANT);
|
|| state.getMaterial().equals(Material.PLANT)
|
||||||
|
|| state.getMaterial().equals(Material.LEAVES)
|
||||||
|
|| state.getMaterial().equals(Material.WOOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void shuffle(Random random) {
|
private static void shuffle(Random random) {
|
||||||
|
|
|
@ -27,9 +27,7 @@ public class CrashedShipFeature extends NBTStructureFeature {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canSpawn(StructureWorldAccess world, BlockPos pos, Random random) {
|
protected boolean canSpawn(StructureWorldAccess world, BlockPos pos, Random random) {
|
||||||
int cx = pos.getX() >> 4;
|
return pos.getY() > 58 && world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN);
|
||||||
int cz = pos.getZ() >> 4;
|
|
||||||
return ((cx + cz) & 1) == 0 && pos.getY() > 58 && world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,6 +61,8 @@ public class CrashedShipFeature extends NBTStructureFeature {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println(center);
|
||||||
|
|
||||||
Structure structure = getStructure(world, center, random);
|
Structure structure = getStructure(world, center, random);
|
||||||
BlockRotation rotation = getRotation(world, center, random);
|
BlockRotation rotation = getRotation(world, center, random);
|
||||||
BlockMirror mirror = getMirror(world, center, random);
|
BlockMirror mirror = getMirror(world, center, random);
|
||||||
|
@ -70,6 +70,9 @@ public class CrashedShipFeature extends NBTStructureFeature {
|
||||||
center = center.add(0, getYOffset(structure, world, center, random) + 0.5, 0);
|
center = center.add(0, getYOffset(structure, world, center, random) + 0.5, 0);
|
||||||
|
|
||||||
BlockBox bounds = makeBox(center);
|
BlockBox bounds = makeBox(center);
|
||||||
|
BlockBox structB = StructureHelper.getStructureBounds(center, structure, rotation, mirror);
|
||||||
|
bounds = StructureHelper.intersectBoxes(bounds, structB);
|
||||||
|
|
||||||
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
|
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror).setBoundingBox(bounds);
|
||||||
addStructureData(placementData);
|
addStructureData(placementData);
|
||||||
center = center.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
|
center = center.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Loading…
Add table
Add a link
Reference in a new issue