diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 65f97543..74d9f95c 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -189,10 +189,15 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil String name = LitematicaHelper.getName(i); try { LitematicaSchematic schematic1 = new LitematicaSchematic(CompressedStreamTools.readCompressed(Files.newInputStream(LitematicaHelper.getSchematicFile(i).toPath())),false); - LitematicaSchematic schematic2 = LitematicaHelper.blackMagicFuckery(schematic1, i); - Vec3i correctedOrigin = LitematicaHelper.getCorrectedOrigin(schematic2, i); + try { + LitematicaSchematic schematic2 = LitematicaHelper.blackMagicFuckery(schematic1, i); + Vec3i correctedOrigin = LitematicaHelper.getCorrectedOrigin(schematic2, i); + //Vec3i correctedOrigin = new Vec3i(0,4,0); - build(name, schematic2, correctedOrigin); + build(name, schematic2, correctedOrigin); + } catch (IndexOutOfBoundsException e) { + logDirect("BlackMagicFuckery summoned a Balrog. This foe is beyond any of you. "); + } } catch (IOException e) { logDirect("Schematic File could not be loaded"); } diff --git a/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java b/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java index 40ff37e7..fb2f36eb 100644 --- a/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java +++ b/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java @@ -62,7 +62,7 @@ public final class LitematicaSchematic extends StaticSchematic { } private int getMinOfSchematic(String s) { - int n = 0; + int n = Integer.MAX_VALUE; for (String subReg : getRegions(nbt)) { n = Math.min(n, getMinOfSubregion(nbt, subReg, s)); } diff --git a/src/main/java/baritone/utils/schematic/litematica/LitematicaHelper.java b/src/main/java/baritone/utils/schematic/litematica/LitematicaHelper.java index 14b984c4..ea9b711b 100644 --- a/src/main/java/baritone/utils/schematic/litematica/LitematicaHelper.java +++ b/src/main/java/baritone/utils/schematic/litematica/LitematicaHelper.java @@ -59,9 +59,14 @@ public final class LitematicaHelper { return DataManager.getSchematicPlacementManager().getAllSchematicsPlacements().get(i).getMirror(); } public static Vec3i getCorrectedOrigin(LitematicaSchematic schematic, int i) { - int x = LitematicaHelper.getOrigin(i).getX() + schematic.getMinimumCorner().getX(); - int y = LitematicaHelper.getOrigin(i).getY() + schematic.getMinimumCorner().getY(); - int z = LitematicaHelper.getOrigin(i).getZ() + schematic.getMinimumCorner().getZ(); + int x = LitematicaHelper.getOrigin(i).getX(); + int y = LitematicaHelper.getOrigin(i).getY(); + int z = LitematicaHelper.getOrigin(i).getZ(); + int mx = schematic.getMinimumCorner().getX(); + int my = schematic.getMinimumCorner().getY(); + int mz = schematic.getMinimumCorner().getZ(); + int sx = (schematic.getX() - 1) * -1; + int sz = (schematic.getZ() - 1) * -1; Vec3i correctedOrigin; Mirror mirror = LitematicaHelper.getMirror(i); Rotation rotation = LitematicaHelper.getRotation(i); @@ -72,32 +77,32 @@ public final class LitematicaHelper { case LEFT_RIGHT: switch ((mirror.ordinal()*2+rotation.ordinal())%4) { case 1: - correctedOrigin = new Vec3i(x - schematic.getX()+1, y, z - schematic.getZ()+1); + correctedOrigin = new Vec3i(x + (sz - mz), y + my, z + (sx - mx)); break; case 2: - correctedOrigin = new Vec3i(x, y, z - schematic.getZ()+1); + correctedOrigin = new Vec3i(x + mx, y + my, z + (sz - mz)); break; case 3: - correctedOrigin = new Vec3i(x, y, z); + correctedOrigin = new Vec3i(x + mz, y + my, z + mx); break; default: - correctedOrigin = new Vec3i(x - schematic.getX()+1, y, z); + correctedOrigin = new Vec3i(x + (sx - mx), y + my, z + mz); break; } break; default: switch (rotation) { case CLOCKWISE_90: - correctedOrigin = new Vec3i(x - schematic.getX()+1, y, z); + correctedOrigin = new Vec3i(x + (sz - mz), y + my, z + mz); break; case CLOCKWISE_180: - correctedOrigin = new Vec3i(x - schematic.getX()+1, y, z - schematic.getZ()+1); + correctedOrigin = new Vec3i(x + (sx - mx), y + my, z + (sz - mz)); break; case COUNTERCLOCKWISE_90: - correctedOrigin = new Vec3i(x, y, z - schematic.getZ()+1); + correctedOrigin = new Vec3i(x + mz, y + my, z + (sx - mx)); break; default: - correctedOrigin = new Vec3i(x, y, z); + correctedOrigin = new Vec3i(x + mx, y + my, z + mz); break; } } @@ -122,18 +127,23 @@ public final class LitematicaHelper { for (int zCounter=0; zCounter