From 81dea5a6fde1e853424c4e7c43d73f64c8e218c1 Mon Sep 17 00:00:00 2001 From: Adrian Date: Sun, 14 Jun 2015 14:58:09 +0200 Subject: [PATCH] add center selection to pyramid code --- .../assets/buildcraft/lang/en_US.lang | 10 ++ .../items/fillerParameters/center_0.png | Bin 0 -> 387 bytes .../items/fillerParameters/center_1.png | Bin 0 -> 384 bytes .../items/fillerParameters/center_2.png | Bin 0 -> 387 bytes .../items/fillerParameters/center_3.png | Bin 0 -> 384 bytes .../items/fillerParameters/center_4.png | Bin 0 -> 385 bytes .../items/fillerParameters/center_5.png | Bin 0 -> 383 bytes .../items/fillerParameters/center_6.png | Bin 0 -> 384 bytes .../items/fillerParameters/center_7.png | Bin 0 -> 383 bytes .../items/fillerParameters/center_8.png | Bin 0 -> 385 bytes common/buildcraft/BuildCraftCore.java | 5 +- .../patterns/PatternParameterCenter.java | 79 ++++++++++++ .../builders/patterns/PatternPyramid.java | 57 +++++++-- .../core/builders/patterns/PatternStairs.java | 112 ++---------------- 14 files changed, 144 insertions(+), 119 deletions(-) create mode 100644 buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_0.png create mode 100644 buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_1.png create mode 100644 buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_2.png create mode 100644 buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_3.png create mode 100644 buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_4.png create mode 100644 buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_5.png create mode 100644 buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_6.png create mode 100644 buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_7.png create mode 100644 buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_8.png create mode 100644 common/buildcraft/core/builders/patterns/PatternParameterCenter.java diff --git a/buildcraft_resources/assets/buildcraft/lang/en_US.lang b/buildcraft_resources/assets/buildcraft/lang/en_US.lang index 883dc05f..13821d4f 100644 --- a/buildcraft_resources/assets/buildcraft/lang/en_US.lang +++ b/buildcraft_resources/assets/buildcraft/lang/en_US.lang @@ -147,6 +147,16 @@ direction.south=South direction.up=Top direction.down=Bottom +direction.center.0=North-West +direction.center.1=North +direction.center.2=North-East +direction.center.3=West +direction.center.4=Center +direction.center.5=East +direction.center.6=South-West +direction.center.7=South +direction.center.8=South-East + fillerpattern.clear=Clear fillerpattern.fill=Fill fillerpattern.flatten=Flatten diff --git a/buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_0.png b/buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_0.png new file mode 100644 index 0000000000000000000000000000000000000000..247c55c23046f98536d1c457135133e0376c88ad GIT binary patch literal 387 zcmV-}0et?6P)f1H?>qYC_H}m8_^5Z?y!X5PGKf1H?>qYC_H}m8_^5Z?y!X5PGKq6dK~~kTm>4#e=%hM0000f1H?>qYC_H}m8_^5Z?y!X5PGK}b|%vZFanTL(ny>ggLm1q?xi hk+BKbKc<*o2LL{~1sd0hoF4!H002ovPDHLkV1kWBq>%ss literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_3.png b/buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_3.png new file mode 100644 index 0000000000000000000000000000000000000000..86095bf0b2951919ac3ae4dd4cc2c7b230cd8391 GIT binary patch literal 384 zcmV-`0e}99P)f1H?>qYC_H}m8_^5Z?y!X5PGKMgfQjgB&xO04ozr0IG#s3B*-K7^(*1^Rc7ZqREctFl`+WsjH`N02MF<5k|%) eVE>q6dK~~YECm`4U_z1r0000f1H?>qYC_H}m8_^5Z?y!X5PGKExNVUS}+6JTY62|%@QD}lJm2t(CCd_HzGTQu3x9Hy-UB6aoj4WI&sAi~Jl f1neJEOs@j~WH|+N?XtKv00000NkvXXu0mjfMq{LT literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_5.png b/buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_5.png new file mode 100644 index 0000000000000000000000000000000000000000..88d9981086515f31f065a39e7ebe3859f5518b22 GIT binary patch literal 383 zcmV-_0f7FAP)f1H?>qYC_H}m8_^5Z?y!X5PGK}a-VvZFanTL(ny>ggLm1q?xik+BKb dKc<*o2LLms1saiUe(?YR002ovPDHLkV1iFcq)h+- literal 0 HcmV?d00001 diff --git a/buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_6.png b/buildcraft_resources/assets/buildcraftcore/textures/items/fillerParameters/center_6.png new file mode 100644 index 0000000000000000000000000000000000000000..593bac419c02bf1d774bb9d7a49700f76a37d02c GIT binary patch literal 384 zcmV-`0e}99P)f1H?>qYC_H}m8_^5Z?y!X5PGKf1H?>qYC_H}m8_^5Z?y!X5PGKf1H?>qYC_H}m8_^5Z?y!X5PGK= 1 && parameters[0] != null && !(((PatternParameterYDir) parameters[0]).up)) { stepY = -1; } else { stepY = 1; } + int center = 4; + if (parameters.length >= 2 && parameters[1] != null) { + center = ((PatternParameterCenter) parameters[1]).getDirection(); + } + + modifiers[0] = (MODIFIERS[center] >> 12) & 1; + modifiers[1] = (MODIFIERS[center] >> 8) & 1; + modifiers[2] = (MODIFIERS[center] >> 4) & 1; + modifiers[3] = (MODIFIERS[center]) & 1; + if (stepY == 1) { height = yMin; } else { height = yMax; } - while (step <= xSize / 2 && step <= zSize / 2 && height >= yMin && height <= yMax) { - for (int x = xMin + step; x <= xMax - step; ++x) { - for (int z = zMin + step; z <= zMax - step; ++z) { - bpt.contents [x - xMin][height - yMin][z - zMin] = new SchematicMask(true); + int x1 = xMin; + int x2 = xMax; + int z1 = zMin; + int z2 = zMax; + + while (height >= yMin && height <= yMax) { + for (int x = x1; x <= x2; ++x) { + for (int z = z1; z <= z2; ++z) { + bpt.contents[x - xMin][height - yMin][z - zMin] = new SchematicMask(true); } } - step++; + x1 += modifiers[0]; + x2 -= modifiers[1]; + z1 += modifiers[2]; + z2 -= modifiers[3]; height += stepY; + + if (x1 > x2 || z1 > z2) { + break; + } } return bpt; diff --git a/common/buildcraft/core/builders/patterns/PatternStairs.java b/common/buildcraft/core/builders/patterns/PatternStairs.java index 7c8c708f..985d7640 100644 --- a/common/buildcraft/core/builders/patterns/PatternStairs.java +++ b/common/buildcraft/core/builders/patterns/PatternStairs.java @@ -16,12 +16,6 @@ import buildcraft.core.blueprints.Template; public class PatternStairs extends FillerPattern { - private int param2 = 0; - - // TODO: These parameters need to be settable from the filler - private int param3 = 0; - private int param4 = 0; - public PatternStairs() { super("stairs"); } @@ -56,10 +50,7 @@ public class PatternStairs extends FillerPattern { Template template = new Template (box.sizeX(), box.sizeY(), box.sizeZ()); - int height; - int heightStep; - int dimX = 0; - int dimZ = 0; + int height, heightStep; if (parameters.length >= 1 && parameters[0] != null && !(((PatternParameterYDir) parameters[0]).up)) { height = Math.max(yMin, yMax - Math.max(xMax, zMax)); @@ -69,19 +60,13 @@ public class PatternStairs extends FillerPattern { heightStep = -1; } + int param2 = 0; if (parameters.length >= 2 && parameters[1] != null) { param2 = ((PatternParameterXZDir) parameters[1]).getDirection(); - } else { - param2 = 0; } - int kind = 0; - int[] steps = new int[] {0, 0, 0, 0}; - int x = 0, z = 0; - int stepDiagX = 0, stepDiagZ = 0; - if (param2 == 0) { steps[0] = 1; } else if (param2 == 1) { @@ -90,38 +75,6 @@ public class PatternStairs extends FillerPattern { steps[2] = 1; } else if (param2 == 3) { steps[3] = 1; - } else { - kind = 1; - - if (param3 == 0) { - x = xMin; - } else if (param3 == 1) { - x = xMax; - } else if (param3 == 2) { - // no change - } - - if (param4 == 0) { - z = zMin; - } else if (param4 == 1) { - z = zMax; - } else if (param4 == 2) { - // no change - } - - if (heightStep == 1) { - stepDiagX = -1; - dimX = sizeX - 1; - - stepDiagZ = -1; - dimZ = sizeZ - 1; - } else { - stepDiagX = 1; - dimX = 0; - - stepDiagZ = 1; - dimZ = 0; - } } int x1 = xMin, x2 = xMax, z1 = zMin, z2 = zMax; @@ -146,62 +99,15 @@ public class PatternStairs extends FillerPattern { z1 = z2; } - if (kind == 0) { - 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); + 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); - x2 += steps[0]; - x1 -= steps[1]; - z2 += steps[2]; - z1 -= steps[3]; + x2 += steps[0]; + x1 -= steps[1]; + z2 += steps[2]; + z1 -= steps[3]; - height += heightStep; - } - } else if (kind == 1) { - while (dimX >= 0 && dimX < sizeX && dimZ >= 0 && dimZ < sizeZ && height >= yMin && height <= yMax) { - - if (heightStep == 1) { - if (param3 == 1) { - x1 = x - sizeX + 1; - x2 = x1 + dimX; - } else { - x2 = x + sizeX - 1; - x1 = x2 - dimX; - } - - if (param4 == 1) { - z1 = z - sizeZ + 1; - z2 = z1 + dimZ; - } else { - z2 = z + sizeZ - 1; - z1 = z2 - dimZ; - } - } else if (heightStep == -1) { - if (param3 == 0) { - x1 = x; - x2 = x1 + dimX; - } else { - x2 = x; - x1 = x2 - dimX; - } - - if (param3 == 1) { - z1 = z; - z2 = z1 + dimZ; - } else { - z2 = z; - z1 = z2 - dimZ; - } - - } - - fill(x1, height, z1, x2, height, z2, template); - - dimX += stepDiagX; - dimZ += stepDiagZ; - - height += heightStep; - } + height += heightStep; } return template;