added protection against filler errors and fixed array out of bounds for cylinder, fix #1604
This commit is contained in:
parent
c5a912a222
commit
aa6d085e8b
2 changed files with 42 additions and 27 deletions
|
@ -20,6 +20,7 @@ import buildcraft.api.blueprints.SchematicRegistry;
|
|||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.blueprints.Blueprint;
|
||||
import buildcraft.core.blueprints.BlueprintBase;
|
||||
import buildcraft.core.blueprints.BptBuilderTemplate;
|
||||
import buildcraft.core.blueprints.Template;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
@ -68,11 +69,13 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
for (int y = yMin; y <= yMax; ++y) {
|
||||
for (int x = xMin; x <= xMax; ++x) {
|
||||
for (int z = zMin; z <= zMax; ++z) {
|
||||
if (isValid(x, y, z, template)) {
|
||||
template.contents[x][y][z] = new SchematicMask(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an empty in a given area
|
||||
|
@ -83,11 +86,13 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
for (int y = yMax; y >= yMin; y--) {
|
||||
for (int x = xMin; x <= xMax; ++x) {
|
||||
for (int z = zMin; z <= zMax; ++z) {
|
||||
if (isValid(x, y, z, template)) {
|
||||
template.contents[x][y][z] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a flatten in a given area
|
||||
|
@ -98,11 +103,13 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
for (int x = xMin; x <= xMax; ++x) {
|
||||
for (int z = zMin; z <= zMax; ++z) {
|
||||
for (int y = yMax; y >= yMin; --y) {
|
||||
if (isValid(x, y, z, template)) {
|
||||
template.contents [x][y][z] = new SchematicMask(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract Template getTemplate (Box box, World world);
|
||||
|
||||
|
@ -129,4 +136,8 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
public BptBuilderTemplate getTemplateBuilder (Box box, World world) {
|
||||
return new BptBuilderTemplate(getTemplate(box, world), world, box.xMin, box.yMin, box.zMin);
|
||||
}
|
||||
|
||||
private static boolean isValid (int x, int y, int z, BlueprintBase bpt) {
|
||||
return x >= 0 && y >= 0 && z >= 0 && x < bpt.sizeX && y < bpt.sizeY && z < bpt.sizeZ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public class PatternCylinder extends FillerPattern {
|
|||
int stoppingX = twoBSquare * xRadius;
|
||||
int stoppingZ = 0;
|
||||
|
||||
if (twoASquare > 0) {
|
||||
while (stoppingX >= stoppingZ) {
|
||||
fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
|
||||
yMax, result);
|
||||
|
@ -70,6 +71,7 @@ public class PatternCylinder extends FillerPattern {
|
|||
xChange += twoBSquare;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dx = 0;
|
||||
dz = zRadius;
|
||||
|
@ -79,6 +81,7 @@ public class PatternCylinder extends FillerPattern {
|
|||
stoppingX = 0;
|
||||
stoppingZ = twoASquare * zRadius;
|
||||
|
||||
if (twoBSquare > 0) {
|
||||
while (stoppingX <= stoppingZ) {
|
||||
fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
|
||||
yMax, result);
|
||||
|
@ -94,6 +97,7 @@ public class PatternCylinder extends FillerPattern {
|
|||
zChange += twoASquare;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue