Merge pull request #753 from Vaern/quickPR

Fixed Infinite loop, added safety for foundation placement
This commit is contained in:
HbmMods 2022-10-01 23:46:31 +02:00 committed by GitHub
commit 3d1a195da5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 96 deletions

View File

@ -79,11 +79,7 @@ public class CivilianFeatures {
}
//System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
for(byte i = 0; i < this.sizeX + 1; i++) {
for(byte j = 0; j < this.sizeZ + 1; j++) {
this.func_151554_b(world, Blocks.sandstone, 0, i, -1, j, box);
}
}
placeFoundationUnderneath(world, Blocks.sandstone, 0, 0, 0, sizeX, sizeZ, -1, box);
//Walls
this.fillWithRandomizedBlocks(world, box, 0, 0, 0, sizeX, 0, 0, false, rand, RandomSandstone); //Back Wall
@ -163,17 +159,8 @@ public class CivilianFeatures {
}
//System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
for(byte i = 0; i < 7; i++) {
for(byte j = 0; j < this.sizeZ + 1; j++) {
this.func_151554_b(world, Blocks.sandstone, 0, i, -1, j, box);
}
}
for(byte i = 9; i < this.sizeX + 1; i++) {
for(byte j = 0; j < this.sizeZ + 1; j++) {
this.func_151554_b(world, Blocks.sandstone, 0, i, -1, j, box);
}
}
placeFoundationUnderneath(world, Blocks.sandstone, 0, 0, 0, 6, sizeZ, -1, box);
placeFoundationUnderneath(world, Blocks.sandstone, 0, 9, 0, sizeX, sizeZ, -1, box);
this.fillWithAir(world, box, 1, 0, 1, 5, sizeY, sizeZ - 1);
@ -318,21 +305,12 @@ public class CivilianFeatures {
}
//System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
for(byte i = 0; i < this.sizeX + 1; i++) {
for(byte j = 0; j < this.sizeZ - 1; j++) {
this.func_151554_b(world, Blocks.stonebrick, 0, i, -1, j, box);
}
}
for(byte i = 3; i < this.sizeX + 1; i++) {
for(byte j = 6; j < this.sizeZ + 1; j++) {
this.func_151554_b(world, Blocks.stonebrick, 0, i, -1, j, box);
}
}
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 0, sizeX, sizeZ - 2, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 3, 6, sizeX, sizeZ, -1, box);
if(this.getBlockAtCurrentPosition(world, 2, 0, sizeZ - 1, box).getMaterial().isReplaceable()
|| this.getBlockAtCurrentPosition(world, 2, 0, sizeZ - 1, box) == Blocks.air) {
this.func_151554_b(world, Blocks.stonebrick, 0, 2, -1, sizeZ - 1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 2, sizeZ - 1, 2, sizeZ - 1, -1, box);
this.placeBlockAtCurrentPosition(world, Blocks.stone_brick_stairs, getStairMeta(0), 2, 0, sizeZ - 1, box);
}
@ -455,23 +433,13 @@ public class CivilianFeatures {
this.boundingBox.offset(0, -7, 0);
//System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
for(byte i = 0; i < sizeX + 1; i++) {
for(byte j = 0; j < sizeZ - 1; j++) {
this.func_151554_b(world, Blocks.stonebrick, 0, i, 6, j, box);
}
}
for(byte i = 0; i < 7; i++) {
for(byte j = 7; j < sizeZ + 1; j++) {
this.func_151554_b(world, Blocks.stonebrick, 0, i, 6, j, box);
}
}
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 0, sizeX, sizeZ - 2, 6, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 7, 6, sizeZ, 6, box);
if(this.getBlockAtCurrentPosition(world, sizeX - 3, sizeY - 4, 7, box).getMaterial().isReplaceable()
|| this.getBlockAtCurrentPosition(world, sizeX - 3, sizeY - 4, 7, box) == Blocks.air) {
int stairMeta = this.getMetadataWithOffset(Blocks.stone_brick_stairs, 2);
this.func_151554_b(world, Blocks.stonebrick, 0, sizeX - 3, sizeY - 4, 7, box);
this.func_151554_b(world, Blocks.stonebrick, 0, sizeX - 2, sizeY - 4, 7, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, sizeX - 3, 7, sizeX - 2, 7, sizeY - 4, box);
this.fillWithMetadataBlocks(world, box, sizeX - 3, sizeY - 4, 7, sizeX - 2, sizeY - 4, 7, Blocks.stone_brick_stairs, stairMeta, Blocks.air, 0, false);
}
@ -633,17 +601,8 @@ public class CivilianFeatures {
}
//System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
for(byte i = 1; i < sizeX - 2; i++) {
for(byte j = 0; j < sizeZ + 1; j++) {
this.func_151554_b(world, Blocks.stonebrick, 0, i, -1, j, box);
}
}
for(byte i = 8; i < sizeX + 1; i++) {
for(byte j = 1; j < 7; j++) {
this.func_151554_b(world, Blocks.dirt, 0, i, -1, j, box);
}
}
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 1, 0, sizeX - 3, sizeZ, -1, box);
placeFoundationUnderneath(world, Blocks.dirt, 0, 8, 1, sizeX, 6, -1, box);
this.fillWithAir(world, box, 1, 0, 0, sizeX - 3, sizeY - 2, sizeZ);
this.fillWithAir(world, box, sizeX - 2, 0, 2, sizeX - 1, 2, 5);
@ -653,9 +612,7 @@ public class CivilianFeatures {
int stairMeta = this.getMetadataWithOffset(Blocks.stone_brick_stairs, 1);
this.placeBlockAtCurrentPosition(world, Blocks.stone_brick_stairs, stairMeta, 0, 0, 5, box);
for(byte i = 1; 1 < sizeZ; i++) {
this.func_151554_b(world, Blocks.stonebrick, 0, 0, -1, i, box);
}
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 1, 0, sizeZ - 1, -1, box);
this.fillWithMetadataBlocks(world, box, 0, 0, 1, 0, 0, sizeZ - 1, Blocks.stone_slab, 5, Blocks.air, 0, false);
}

View File

@ -342,10 +342,16 @@ abstract public class Feature extends StructureComponent {
if(box.isVecInside(posX, posY, posZ)) {
Block block = world.getBlock(posX, posY, posZ);
int brake = 0;
while ((world.isAirBlock(posX, posY, posZ) || !block.getMaterial().isSolid() || (block.isFoliage(world, posX, posY, posZ) || block.getMaterial() == Material.leaves)) && posY > 1) {
while ((world.isAirBlock(posX, posY, posZ) ||
!block.getMaterial().isSolid() ||
(block.isFoliage(world, posX, posY, posZ) || block.getMaterial() == Material.leaves)) &&
posY > 1 && brake <= 15) {
world.setBlock(posX, posY, posZ, placeBlock, meta, 2);
block = world.getBlock(posX, --posY, posZ);
brake++;
}
}
}

View File

@ -67,17 +67,16 @@ public class MilitaryBaseFeatures {
for(int i = 1; i < sizeX; i++) {
for(int j = 1; j < sizeZ; j++) {
func_151554_b(world, Blocks.stonebrick, 0, i, -1, j, box);
clearCurrentPositionBlocksUpwards(world, i, 1, j, box);
}
}
for(int i = 0; i <= sizeX; i++) {
for(int j = 0; j <= sizeZ; j++) {
if(i == 0 || i == sizeX || j == 0 || j == sizeX)
func_151554_b(world, Blocks.stonebrick, 0, i, 0, j, box);
}
}
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 1, 1, sizeX - 1, sizeZ - 1, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 0, sizeX, 0, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 1, 0, sizeZ, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, sizeX, 1, sizeX, sizeZ, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 1, sizeZ, sizeX - 1, sizeZ, -1, box);
//Helipad
fillWithBlocks(world, box, 1, 0, 1, 11, 0, 1, ModBlocks.concrete, Blocks.air, false); //this entire time, the second block was actually for anything not at min/max x's, y's, and z's. useful!
@ -121,13 +120,8 @@ public class MilitaryBaseFeatures {
this.boundingBox.offset(0, -1, 0);
for(int i = 1; i <= sizeX; i++) {
for(int j = 1; j <= sizeZ; j++) {
func_151554_b(world, Blocks.stonebrick, 0, i, -1, j, box);
}
}
func_151554_b(world, Blocks.stonebrick, 0, 0, 0, 2, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 1, 1, sizeX, sizeZ, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 2, 0, 2, 0, box);
//Floor & Foundation
fillWithRandomizedBlocks(world, box, 2, 0, 1, 5, 0, 4, false, rand, RandomLabTiles);

View File

@ -31,11 +31,7 @@ public class RuinFeatures {
}
//System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
for(byte i = 0; i < sizeX + 1; i++) {
for(byte j = 0; j < sizeZ + 1; j++) {
this.func_151554_b(world, Blocks.stonebrick, 0, i, -1, j, box);
}
}
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 0, sizeX, sizeZ, -1, box);
int pillarMetaWE = this.getPillarMeta(4);
int pillarMetaNS = this.getPillarMeta(8);
@ -107,11 +103,7 @@ public class RuinFeatures {
}
//System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
for(byte i = 0; i < sizeX + 1; i++) {
for(byte j = 0; j < sizeZ + 1; j++) {
this.func_151554_b(world, Blocks.stonebrick, 0, i, -1, j, box);
}
}
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 0, sizeX, sizeZ, -1, box);
int pillarMetaWE = this.getPillarMeta(4);
int pillarMetaNS = this.getPillarMeta(8);
@ -174,15 +166,11 @@ public class RuinFeatures {
}
//System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
for(byte i = 0; i < sizeZ + 1; i++) {
this.func_151554_b(world, Blocks.stonebrick, 0, 0, -1, i, box);
this.func_151554_b(world, Blocks.stonebrick, 0, sizeX, -1, i, box);
}
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 0, 0, sizeZ, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, sizeX, 0, sizeX, sizeZ, -1, box);
for(byte i = 1; i < sizeX; i++) {
this.func_151554_b(world, Blocks.stonebrick, 0, i, -1, 0, box);
this.func_151554_b(world, Blocks.stonebrick, 0, i, -1, 4, box);
}
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 1, 0, sizeX, 0, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 1, 4, sizeX, 4, -1, box);
this.fillWithBlocks(world, box, 0, 0, 0, 0, sizeY, 0, ModBlocks.concrete_pillar, Blocks.air, false); //Back Wall
this.fillWithBlocks(world, box, sizeX, 0, 0, sizeX, 1, 0, ModBlocks.concrete_pillar, Blocks.air, false);
@ -235,15 +223,14 @@ public class RuinFeatures {
}
//System.out.println("" + this.boundingBox.minX + ", " + this.boundingBox.minY + ", " + this.boundingBox.minZ);
for(byte i = 0; i < sizeZ + 1; i++) {
this.func_151554_b(world, Blocks.stonebrick, 0, 0, -1, i, box);
this.func_151554_b(world, Blocks.stonebrick, 0, i >= 5 ? sizeX : 5, -1, i, box); //elegant solution
}
for(byte i = 1; i < sizeX; i++) {
this.func_151554_b(world, Blocks.stonebrick, 0, i, -1, sizeZ, box);
this.func_151554_b(world, Blocks.stonebrick, 0, i, -1, i > 4 ? 5 : 0, box); //ternary operators my beloved
}
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 0, 0, sizeZ, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, sizeX, 5, sizeX, sizeZ, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 5, 0, 5, 4, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 1, sizeZ, sizeX - 1, sizeZ, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 1, 0, 4, 0, -1, box);
placeFoundationUnderneath(world, Blocks.stonebrick, 0, 5, 5, sizeX - 1, 5, -1, box);
this.fillWithBlocks(world, box, 0, 0, 0, 0, 1, 0, ModBlocks.concrete_pillar, Blocks.air, false); //Back Wall Pt. 1
this.fillWithBlocks(world, box, 5, 0, 0, 5, sizeY, 0, ModBlocks.concrete_pillar, Blocks.air, false);