From ed0efec628cba74a39f072a14f99aada5dccbaf0 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Sat, 4 Jan 2020 17:54:34 -0500 Subject: [PATCH] Rotation of schematics --- .../java/ninja/bytecode/iris/Settings.java | 8 ++--- .../bytecode/iris/schematic/Schematic.java | 35 +++++++++++-------- .../ninja/bytecode/iris/util/Catalyst12.java | 5 +++ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/main/java/ninja/bytecode/iris/Settings.java b/src/main/java/ninja/bytecode/iris/Settings.java index 7a39da61e..155cdf528 100644 --- a/src/main/java/ninja/bytecode/iris/Settings.java +++ b/src/main/java/ninja/bytecode/iris/Settings.java @@ -9,10 +9,10 @@ public class Settings public static class PerformanceSettings { - public PerformanceMode performanceMode = PerformanceMode.HALF_CPU; + public PerformanceMode performanceMode = PerformanceMode.UNLIMITED; public int threadCount = 12; - public int threadPriority = Thread.MIN_PRIORITY; - public boolean loadonstart = false; + public int threadPriority = Thread.MAX_PRIORITY; + public boolean loadonstart = true; } public static class GeneratorSettings @@ -26,7 +26,7 @@ public class Settings public double superHeightScale = 0.95; public double baseHeight = 0.165; public int seaLevel = 63; - public double caveDensity = 3; + public double caveDensity = 0; public double biomeScale = 2.46; public boolean flatBedrock = false; public boolean doSchematics = true; diff --git a/src/main/java/ninja/bytecode/iris/schematic/Schematic.java b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java index dbed263a8..c86433108 100644 --- a/src/main/java/ninja/bytecode/iris/schematic/Schematic.java +++ b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java @@ -105,6 +105,7 @@ public class Schematic } din.close(); + center(); } @SuppressWarnings("deprecation") @@ -130,7 +131,6 @@ public class Schematic } dos.close(); - center(); } public BlockVector getOffset() @@ -174,7 +174,7 @@ public class Schematic public void place(World source, int wx, int wy, int wz) { - Location start = new Location(source, wx, wy, wz).clone().subtract(w / 2, centeredHeight ? h / 2 : 0, d / 2); + Location start = new Location(source, wx, wy, wz).clone().subtract(0, centeredHeight ? h / 2 : 0, 0); for(BlockVector i : getSchematic().k()) { @@ -210,41 +210,46 @@ public class Schematic public void center() { - GMap s = getSchematic().copy(); + GMap sf = getSchematic().copy(); + BlockVector max = new BlockVector(-w, -h, -d); + BlockVector min = new BlockVector(w, h, d); clear(); - BlockVector max = new BlockVector(-10000, -10000, -10000); - BlockVector min = new BlockVector(10000, 10000, 10000); - for(BlockVector i : s.k()) - { - if(i.lengthSquared() < min.lengthSquared()) + for(BlockVector i : sf.k()) + { + if(i.getX() <= min.getX() && i.getZ() <= min.getZ() && i.getY() <= min.getY()) { min = i; } - if(i.lengthSquared() > max.lengthSquared()) + if(i.getX() >= max.getX() && i.getZ() >= max.getZ() && i.getY() >= max.getY()) { max = i; } } BlockVector center = min.clone().add(max.clone().multiply(0.5D)).toBlockVector(); + center.setY(0); - for(BlockVector i : s.k()) + for(BlockVector i : sf.k()) { - getSchematic().put(i.clone().subtract(center).toBlockVector(), s.get(i)); + getSchematic().put(i.clone().subtract(center).toBlockVector(), sf.get(i)); } + + x = 0; + y = 0; + z = 0; } public void rotate(Direction from, Direction to) { - center(); - GMap s = getSchematic().copy(); + GMap sf = getSchematic().copy(); clear(); - for(BlockVector i : s.k()) + for(BlockVector i : sf.k()) { - getSchematic().put(VectorMath.rotate(from, to, i).toBlockVector(), s.get(i)); + getSchematic().put(VectorMath.rotate(from, to, i).toBlockVector(), sf.get(i)); } + center(); } } diff --git a/src/main/java/ninja/bytecode/iris/util/Catalyst12.java b/src/main/java/ninja/bytecode/iris/util/Catalyst12.java index 88166f3e1..eeb0bb6f8 100644 --- a/src/main/java/ninja/bytecode/iris/util/Catalyst12.java +++ b/src/main/java/ninja/bytecode/iris/util/Catalyst12.java @@ -29,6 +29,11 @@ public class Catalyst12 @SuppressWarnings("deprecation") public static void setBlock(World wo, int x, int y, int z, MB m) { + if(y > wo.getMaxHeight()) + { + return; + } + net.minecraft.server.v1_12_R1.World w = ((CraftWorld) wo).getHandle(); net.minecraft.server.v1_12_R1.Chunk chunk = w.getChunkAt(x >> 4, z >> 4); int combined = m.material.getId() + (m.data << 12);