finished migration of filler to new templates, close #1492
This commit is contained in:
parent
60ecaec53a
commit
19f44edebf
3 changed files with 69 additions and 117 deletions
|
@ -12,6 +12,7 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import buildcraft.core.Box;
|
import buildcraft.core.Box;
|
||||||
import buildcraft.core.blueprints.BptBuilderTemplate;
|
import buildcraft.core.blueprints.BptBuilderTemplate;
|
||||||
|
import buildcraft.core.blueprints.Template;
|
||||||
|
|
||||||
public class PatternCylinder extends FillerPattern {
|
public class PatternCylinder extends FillerPattern {
|
||||||
|
|
||||||
|
@ -19,16 +20,19 @@ public class PatternCylinder extends FillerPattern {
|
||||||
super("cylinder");
|
super("cylinder");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
|
||||||
public boolean iteratePattern(TileEntity tile, IBox box,
|
|
||||||
ItemStack stackToPlace) {
|
|
||||||
int xMin = (int) box.pMin().x;
|
|
||||||
int yMin = (int) box.pMin().y;
|
|
||||||
int zMin = (int) box.pMin().z;
|
|
||||||
|
|
||||||
int xMax = (int) box.pMax().x;
|
@Override
|
||||||
int yMax = (int) box.pMax().y;
|
public BptBuilderTemplate getBlueprint(Box box, World world,
|
||||||
int zMax = (int) box.pMax().z;
|
ForgeDirection orientation) {
|
||||||
|
Template result = new Template (box.sizeX(), box.sizeY(), box.sizeZ());
|
||||||
|
|
||||||
|
int xMin = 0;
|
||||||
|
int yMin = 0;
|
||||||
|
int zMin = 0;
|
||||||
|
|
||||||
|
int xMax = box.sizeX() - 1;
|
||||||
|
int yMax = box.sizeY() - 1;
|
||||||
|
int zMax = box.sizeZ() - 1;
|
||||||
|
|
||||||
int xFix = (xMax - xMin) % 2;
|
int xFix = (xMax - xMin) % 2;
|
||||||
int zFix = (zMax - zMin) % 2;
|
int zFix = (zMax - zMin) % 2;
|
||||||
|
@ -42,8 +46,7 @@ public class PatternCylinder extends FillerPattern {
|
||||||
int zRadius = (zMax - zMin) / 2;
|
int zRadius = (zMax - zMin) / 2;
|
||||||
|
|
||||||
if (xRadius == 0 || zRadius == 0) {
|
if (xRadius == 0 || zRadius == 0) {
|
||||||
return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace,
|
fill(xMin, yMin, zMin, xMax, yMax, zMax, result);
|
||||||
tile.getWorldObj());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int dx = xRadius, dz = 0;
|
int dx = xRadius, dz = 0;
|
||||||
|
@ -56,10 +59,9 @@ public class PatternCylinder extends FillerPattern {
|
||||||
int stoppingZ = 0;
|
int stoppingZ = 0;
|
||||||
|
|
||||||
while (stoppingX >= stoppingZ) {
|
while (stoppingX >= stoppingZ) {
|
||||||
if (!fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
|
fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
|
||||||
yMax, stackToPlace, tile.getWorldObj())) {
|
yMax, result);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
++dz;
|
++dz;
|
||||||
stoppingZ += twoASquare;
|
stoppingZ += twoASquare;
|
||||||
ellipseError += zChange;
|
ellipseError += zChange;
|
||||||
|
@ -81,10 +83,9 @@ public class PatternCylinder extends FillerPattern {
|
||||||
stoppingZ = twoASquare * zRadius;
|
stoppingZ = twoASquare * zRadius;
|
||||||
|
|
||||||
while (stoppingX <= stoppingZ) {
|
while (stoppingX <= stoppingZ) {
|
||||||
if (!fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
|
fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
|
||||||
yMax, stackToPlace, tile.getWorldObj())) {
|
yMax, result);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
++dx;
|
++dx;
|
||||||
stoppingX += twoBSquare;
|
stoppingX += twoBSquare;
|
||||||
ellipseError += xChange;
|
ellipseError += xChange;
|
||||||
|
@ -97,45 +98,30 @@ public class PatternCylinder extends FillerPattern {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return new BptBuilderTemplate(result, world, box.xMin, box.yMin, box.zMin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean fillFourColumns(int xCenter, int zCenter, int dx, int dz,
|
private boolean fillFourColumns(int xCenter, int zCenter, int dx, int dz,
|
||||||
int xFix, int zFix, int yMin, int yMax, ItemStack stackToPlace,
|
int xFix, int zFix, int yMin, int yMax, Template template) {
|
||||||
World world) {
|
|
||||||
int x, z;
|
int x, z;
|
||||||
|
|
||||||
x = xCenter + dx + xFix;
|
x = xCenter + dx + xFix;
|
||||||
z = zCenter + dz + zFix;
|
z = zCenter + dz + zFix;
|
||||||
if (fill(x, yMin, z, x, yMax, z, stackToPlace, world)) {
|
fill(x, yMin, z, x, yMax, z, template);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = xCenter - dx;
|
x = xCenter - dx;
|
||||||
z = zCenter + dz + zFix;
|
z = zCenter + dz + zFix;
|
||||||
if (fill(x, yMin, z, x, yMax, z, stackToPlace, world)) {
|
fill(x, yMin, z, x, yMax, z, template);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = xCenter - dx;
|
x = xCenter - dx;
|
||||||
z = zCenter - dz;
|
z = zCenter - dz;
|
||||||
if (fill(x, yMin, z, x, yMax, z, stackToPlace, world)) {
|
fill(x, yMin, z, x, yMax, z, template);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = xCenter + dx + xFix;
|
x = xCenter + dx + xFix;
|
||||||
z = zCenter - dz;
|
z = zCenter - dz;
|
||||||
if (fill(x, yMin, z, x, yMax, z, stackToPlace, world)) {
|
fill(x, yMin, z, x, yMax, z, template);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BptBuilderTemplate getBlueprint(Box box, World world,
|
|
||||||
ForgeDirection orientation) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,47 +22,8 @@ public class PatternPyramid extends FillerPattern {
|
||||||
super("pyramid");
|
super("pyramid");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
// TODO: These parameters need to be settable from the filler
|
||||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
|
boolean param1 = true;
|
||||||
int xMin = (int) box.pMin().x;
|
|
||||||
int yMin = (int) box.pMin().y;
|
|
||||||
int zMin = (int) box.pMin().z;
|
|
||||||
|
|
||||||
int xMax = (int) box.pMax().x;
|
|
||||||
int yMax = (int) box.pMax().y;
|
|
||||||
int zMax = (int) box.pMax().z;
|
|
||||||
|
|
||||||
int xSize = xMax - xMin + 1;
|
|
||||||
int zSize = zMax - zMin + 1;
|
|
||||||
|
|
||||||
int step = 0;
|
|
||||||
int height;
|
|
||||||
|
|
||||||
int stepY;
|
|
||||||
|
|
||||||
if (tile.yCoord <= yMin) {
|
|
||||||
stepY = 1;
|
|
||||||
} else {
|
|
||||||
stepY = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stepY == 1) {
|
|
||||||
height = yMin;
|
|
||||||
} else {
|
|
||||||
height = yMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (step <= xSize / 2 && step <= zSize / 2 && height >= yMin && height <= yMax) {
|
|
||||||
if (fill(xMin + step, height, zMin + step, xMax - step, height, zMax - step, stackToPlace, tile.getWorldObj())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
step++;
|
|
||||||
height += stepY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BptBuilderTemplate getBlueprint (Box box, World world, ForgeDirection orientation) {
|
public BptBuilderTemplate getBlueprint (Box box, World world, ForgeDirection orientation) {
|
||||||
|
@ -84,11 +45,11 @@ public class PatternPyramid extends FillerPattern {
|
||||||
|
|
||||||
int stepY = 1;
|
int stepY = 1;
|
||||||
|
|
||||||
//if (tile.yCoord <= yMin) {
|
if (param1) {
|
||||||
// stepY = 1;
|
stepY = 1;
|
||||||
//} else {
|
} else {
|
||||||
// stepY = -1;
|
stepY = -1;
|
||||||
//}
|
}
|
||||||
|
|
||||||
if (stepY == 1) {
|
if (stepY == 1) {
|
||||||
height = yMin;
|
height = yMin;
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import buildcraft.core.Box;
|
import buildcraft.core.Box;
|
||||||
import buildcraft.core.blueprints.BptBuilderTemplate;
|
import buildcraft.core.blueprints.BptBuilderTemplate;
|
||||||
|
import buildcraft.core.blueprints.Template;
|
||||||
|
|
||||||
|
|
||||||
public class PatternStairs extends FillerPattern {
|
public class PatternStairs extends FillerPattern {
|
||||||
|
@ -20,31 +21,34 @@ public class PatternStairs extends FillerPattern {
|
||||||
super("stairs");
|
super("stairs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: These parameters need to be settable from the filler
|
||||||
|
boolean param1 = true;
|
||||||
|
int param2 = 0;
|
||||||
|
int param3 = 0;
|
||||||
|
int param4 = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BptBuilderTemplate getBlueprint(Box box, World world,
|
public BptBuilderTemplate getBlueprint(Box box, World world,
|
||||||
ForgeDirection orientation) {
|
ForgeDirection orientation) {
|
||||||
return null;
|
int xMin = 0;
|
||||||
}
|
int yMin = 0;
|
||||||
|
int zMin = 0;
|
||||||
|
|
||||||
/*@Override
|
int xMax = box.sizeX() - 1;
|
||||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace) {
|
int yMax = box.sizeY() - 1;
|
||||||
int xMin = (int) box.pMin().x;
|
int zMax = box.sizeZ() - 1;
|
||||||
int yMin = (int) box.pMin().y;
|
|
||||||
int zMin = (int) box.pMin().z;
|
|
||||||
|
|
||||||
int xMax = (int) box.pMax().x;
|
|
||||||
int yMax = (int) box.pMax().y;
|
|
||||||
int zMax = (int) box.pMax().z;
|
|
||||||
|
|
||||||
int sizeX = xMax - xMin + 1;
|
int sizeX = xMax - xMin + 1;
|
||||||
int sizeZ = zMax - zMin + 1;
|
int sizeZ = zMax - zMin + 1;
|
||||||
|
|
||||||
|
Template template = new Template (box.sizeX(), box.sizeY(), box.sizeZ());
|
||||||
|
|
||||||
int height;
|
int height;
|
||||||
int heightStep;
|
int heightStep;
|
||||||
int dimX = 0;
|
int dimX = 0;
|
||||||
int dimZ = 0;
|
int dimZ = 0;
|
||||||
|
|
||||||
if (tile.yCoord <= yMin) {
|
if (param1) {
|
||||||
height = yMin;
|
height = yMin;
|
||||||
heightStep = 1;
|
heightStep = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,27 +63,31 @@ public class PatternStairs extends FillerPattern {
|
||||||
int x = 0, z = 0;
|
int x = 0, z = 0;
|
||||||
int stepDiagX = 0, stepDiagZ = 0;
|
int stepDiagX = 0, stepDiagZ = 0;
|
||||||
|
|
||||||
if (tile.xCoord == xMin - 1) {
|
if (param2 == 0) {
|
||||||
steps[0] = 1;
|
steps[0] = 1;
|
||||||
} else if (tile.xCoord == xMax + 1) {
|
} else if (param2 == 1) {
|
||||||
steps[1] = 1;
|
steps[1] = 1;
|
||||||
} else if (tile.zCoord == zMin - 1) {
|
} else if (param2 == 2) {
|
||||||
steps[2] = 1;
|
steps[2] = 1;
|
||||||
} else if (tile.zCoord == zMax + 1) {
|
} else if (param2 == 3) {
|
||||||
steps[3] = 1;
|
steps[3] = 1;
|
||||||
} else {
|
} else {
|
||||||
kind = 1;
|
kind = 1;
|
||||||
|
|
||||||
if (tile.xCoord <= xMin) {
|
if (param3 == 0) {
|
||||||
x = xMin;
|
x = xMin;
|
||||||
} else if (tile.xCoord >= xMax) {
|
} else if (param3 == 1) {
|
||||||
x = xMax;
|
x = xMax;
|
||||||
|
} else if (param3 == 2) {
|
||||||
|
// no change
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tile.zCoord <= zMin) {
|
if (param4 == 0) {
|
||||||
z = zMin;
|
z = zMin;
|
||||||
} else if (tile.zCoord >= zMax) {
|
} else if (param4 == 1) {
|
||||||
z = zMax;
|
z = zMax;
|
||||||
|
} else if (param4 == 2) {
|
||||||
|
// no change
|
||||||
}
|
}
|
||||||
|
|
||||||
if (heightStep == 1) {
|
if (heightStep == 1) {
|
||||||
|
@ -129,9 +137,7 @@ public class PatternStairs extends FillerPattern {
|
||||||
|
|
||||||
if (kind == 0) {
|
if (kind == 0) {
|
||||||
while (x2 - x1 + 1 > 0 && z2 - z1 + 1 > 0 && x2 - x1 < sizeX && z2 - z1 < sizeZ && height >= yMin && height <= yMax) {
|
while (x2 - x1 + 1 > 0 && z2 - z1 + 1 > 0 && x2 - x1 < sizeX && z2 - z1 < sizeZ && height >= yMin && height <= yMax) {
|
||||||
|
fill(x1, height, z1, x2, height, z2, template);
|
||||||
if (fill(x1, height, z1, x2, height, z2, stackToPlace, tile.getWorldObj()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (heightStep == 1) {
|
if (heightStep == 1) {
|
||||||
x1 += steps[0];
|
x1 += steps[0];
|
||||||
|
@ -151,7 +157,7 @@ public class PatternStairs extends FillerPattern {
|
||||||
while (dimX >= 0 && dimX < sizeX && dimZ >= 0 && dimZ < sizeZ && height >= yMin && height <= yMax) {
|
while (dimX >= 0 && dimX < sizeX && dimZ >= 0 && dimZ < sizeZ && height >= yMin && height <= yMax) {
|
||||||
|
|
||||||
if (heightStep == 1) {
|
if (heightStep == 1) {
|
||||||
if (tile.xCoord >= xMax) {
|
if (param3 == 1) {
|
||||||
x1 = x - sizeX + 1;
|
x1 = x - sizeX + 1;
|
||||||
x2 = x1 + dimX;
|
x2 = x1 + dimX;
|
||||||
} else {
|
} else {
|
||||||
|
@ -159,7 +165,7 @@ public class PatternStairs extends FillerPattern {
|
||||||
x1 = x2 - dimX;
|
x1 = x2 - dimX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tile.zCoord >= zMax) {
|
if (param4 == 1) {
|
||||||
z1 = z - sizeZ + 1;
|
z1 = z - sizeZ + 1;
|
||||||
z2 = z1 + dimZ;
|
z2 = z1 + dimZ;
|
||||||
} else {
|
} else {
|
||||||
|
@ -167,7 +173,7 @@ public class PatternStairs extends FillerPattern {
|
||||||
z1 = z2 - dimZ;
|
z1 = z2 - dimZ;
|
||||||
}
|
}
|
||||||
} else if (heightStep == -1) {
|
} else if (heightStep == -1) {
|
||||||
if (tile.xCoord <= xMin) {
|
if (param3 == 0) {
|
||||||
x1 = x;
|
x1 = x;
|
||||||
x2 = x1 + dimX;
|
x2 = x1 + dimX;
|
||||||
} else {
|
} else {
|
||||||
|
@ -175,7 +181,7 @@ public class PatternStairs extends FillerPattern {
|
||||||
x1 = x2 - dimX;
|
x1 = x2 - dimX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tile.zCoord <= zMin) {
|
if (param3 == 1) {
|
||||||
z1 = z;
|
z1 = z;
|
||||||
z2 = z1 + dimZ;
|
z2 = z1 + dimZ;
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,8 +191,7 @@ public class PatternStairs extends FillerPattern {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fill(x1, height, z1, x2, height, z2, stackToPlace, tile.getWorldObj()))
|
fill(x1, height, z1, x2, height, z2, template);
|
||||||
return false;
|
|
||||||
|
|
||||||
dimX += stepDiagX;
|
dimX += stepDiagX;
|
||||||
dimZ += stepDiagZ;
|
dimZ += stepDiagZ;
|
||||||
|
@ -195,6 +200,6 @@ public class PatternStairs extends FillerPattern {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return new BptBuilderTemplate(template, world, box.xMin, box.yMin, box.zMin);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue