finished migration of filler to new templates, close #1492

This commit is contained in:
SpaceToad 2014-03-15 12:53:59 +01:00
parent 60ecaec53a
commit 19f44edebf
3 changed files with 69 additions and 117 deletions

View file

@ -12,6 +12,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.core.Box;
import buildcraft.core.blueprints.BptBuilderTemplate;
import buildcraft.core.blueprints.Template;
public class PatternCylinder extends FillerPattern {
@ -19,16 +20,19 @@ public class PatternCylinder extends FillerPattern {
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;
int yMax = (int) box.pMax().y;
int zMax = (int) box.pMax().z;
@Override
public BptBuilderTemplate getBlueprint(Box box, World world,
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 zFix = (zMax - zMin) % 2;
@ -42,8 +46,7 @@ public class PatternCylinder extends FillerPattern {
int zRadius = (zMax - zMin) / 2;
if (xRadius == 0 || zRadius == 0) {
return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace,
tile.getWorldObj());
fill(xMin, yMin, zMin, xMax, yMax, zMax, result);
}
int dx = xRadius, dz = 0;
@ -56,10 +59,9 @@ public class PatternCylinder extends FillerPattern {
int stoppingZ = 0;
while (stoppingX >= stoppingZ) {
if (!fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
yMax, stackToPlace, tile.getWorldObj())) {
return false;
}
fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
yMax, result);
++dz;
stoppingZ += twoASquare;
ellipseError += zChange;
@ -81,10 +83,9 @@ public class PatternCylinder extends FillerPattern {
stoppingZ = twoASquare * zRadius;
while (stoppingX <= stoppingZ) {
if (!fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
yMax, stackToPlace, tile.getWorldObj())) {
return false;
}
fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
yMax, result);
++dx;
stoppingX += twoBSquare;
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,
int xFix, int zFix, int yMin, int yMax, ItemStack stackToPlace,
World world) {
int xFix, int zFix, int yMin, int yMax, Template template) {
int x, z;
x = xCenter + dx + xFix;
z = zCenter + dz + zFix;
if (fill(x, yMin, z, x, yMax, z, stackToPlace, world)) {
return false;
}
fill(x, yMin, z, x, yMax, z, template);
x = xCenter - dx;
z = zCenter + dz + zFix;
if (fill(x, yMin, z, x, yMax, z, stackToPlace, world)) {
return false;
}
fill(x, yMin, z, x, yMax, z, template);
x = xCenter - dx;
z = zCenter - dz;
if (fill(x, yMin, z, x, yMax, z, stackToPlace, world)) {
return false;
}
fill(x, yMin, z, x, yMax, z, template);
x = xCenter + dx + xFix;
z = zCenter - dz;
if (fill(x, yMin, z, x, yMax, z, stackToPlace, world)) {
return false;
}
fill(x, yMin, z, x, yMax, z, template);
return true;
}*/
@Override
public BptBuilderTemplate getBlueprint(Box box, World world,
ForgeDirection orientation) {
return null;
}
}

View file

@ -22,47 +22,8 @@ public class PatternPyramid extends FillerPattern {
super("pyramid");
}
/*@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;
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;
}*/
// TODO: These parameters need to be settable from the filler
boolean param1 = true;
@Override
public BptBuilderTemplate getBlueprint (Box box, World world, ForgeDirection orientation) {
@ -84,11 +45,11 @@ public class PatternPyramid extends FillerPattern {
int stepY = 1;
//if (tile.yCoord <= yMin) {
// stepY = 1;
//} else {
// stepY = -1;
//}
if (param1) {
stepY = 1;
} else {
stepY = -1;
}
if (stepY == 1) {
height = yMin;

View file

@ -12,6 +12,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.core.Box;
import buildcraft.core.blueprints.BptBuilderTemplate;
import buildcraft.core.blueprints.Template;
public class PatternStairs extends FillerPattern {
@ -20,31 +21,34 @@ public class PatternStairs extends FillerPattern {
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
public BptBuilderTemplate getBlueprint(Box box, World world,
ForgeDirection orientation) {
return null;
}
int xMin = 0;
int yMin = 0;
int zMin = 0;
/*@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;
int yMax = (int) box.pMax().y;
int zMax = (int) box.pMax().z;
int xMax = box.sizeX() - 1;
int yMax = box.sizeY() - 1;
int zMax = box.sizeZ() - 1;
int sizeX = xMax - xMin + 1;
int sizeZ = zMax - zMin + 1;
Template template = new Template (box.sizeX(), box.sizeY(), box.sizeZ());
int height;
int heightStep;
int dimX = 0;
int dimZ = 0;
if (tile.yCoord <= yMin) {
if (param1) {
height = yMin;
heightStep = 1;
} else {
@ -59,27 +63,31 @@ public class PatternStairs extends FillerPattern {
int x = 0, z = 0;
int stepDiagX = 0, stepDiagZ = 0;
if (tile.xCoord == xMin - 1) {
if (param2 == 0) {
steps[0] = 1;
} else if (tile.xCoord == xMax + 1) {
} else if (param2 == 1) {
steps[1] = 1;
} else if (tile.zCoord == zMin - 1) {
} else if (param2 == 2) {
steps[2] = 1;
} else if (tile.zCoord == zMax + 1) {
} else if (param2 == 3) {
steps[3] = 1;
} else {
kind = 1;
if (tile.xCoord <= xMin) {
if (param3 == 0) {
x = xMin;
} else if (tile.xCoord >= xMax) {
} else if (param3 == 1) {
x = xMax;
} else if (param3 == 2) {
// no change
}
if (tile.zCoord <= zMin) {
if (param4 == 0) {
z = zMin;
} else if (tile.zCoord >= zMax) {
} else if (param4 == 1) {
z = zMax;
} else if (param4 == 2) {
// no change
}
if (heightStep == 1) {
@ -129,9 +137,7 @@ public class PatternStairs extends FillerPattern {
if (kind == 0) {
while (x2 - x1 + 1 > 0 && z2 - z1 + 1 > 0 && x2 - x1 < sizeX && z2 - z1 < sizeZ && height >= yMin && height <= yMax) {
if (fill(x1, height, z1, x2, height, z2, stackToPlace, tile.getWorldObj()))
return false;
fill(x1, height, z1, x2, height, z2, template);
if (heightStep == 1) {
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) {
if (heightStep == 1) {
if (tile.xCoord >= xMax) {
if (param3 == 1) {
x1 = x - sizeX + 1;
x2 = x1 + dimX;
} else {
@ -159,7 +165,7 @@ public class PatternStairs extends FillerPattern {
x1 = x2 - dimX;
}
if (tile.zCoord >= zMax) {
if (param4 == 1) {
z1 = z - sizeZ + 1;
z2 = z1 + dimZ;
} else {
@ -167,7 +173,7 @@ public class PatternStairs extends FillerPattern {
z1 = z2 - dimZ;
}
} else if (heightStep == -1) {
if (tile.xCoord <= xMin) {
if (param3 == 0) {
x1 = x;
x2 = x1 + dimX;
} else {
@ -175,7 +181,7 @@ public class PatternStairs extends FillerPattern {
x1 = x2 - dimX;
}
if (tile.zCoord <= zMin) {
if (param3 == 1) {
z1 = z;
z2 = z1 + dimZ;
} else {
@ -185,8 +191,7 @@ public class PatternStairs extends FillerPattern {
}
if (fill(x1, height, z1, x2, height, z2, stackToPlace, tile.getWorldObj()))
return false;
fill(x1, height, z1, x2, height, z2, template);
dimX += stepDiagX;
dimZ += stepDiagZ;
@ -195,6 +200,6 @@ public class PatternStairs extends FillerPattern {
}
}
return true;
}*/
return new BptBuilderTemplate(template, world, box.xMin, box.yMin, box.zMin);
}
}