From c620a9388fe306ce64279bbf87629d06344131a2 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Wed, 8 Jan 2020 04:01:05 -0500 Subject: [PATCH] Placement flags --- src/main/java/ninja/bytecode/iris/Iris.java | 10 +++++-- .../bytecode/iris/schematic/Schematic.java | 26 ++++++++++++++++++- .../iris/schematic/SchematicGroup.java | 19 ++++++++++++++ .../ninja/bytecode/iris/spec/IrisBiome.java | 2 ++ src/main/resources/pack/biomes/forest.json | 7 +++++ src/main/resources/pack/biomes/jungle.json | 3 +++ 6 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/main/java/ninja/bytecode/iris/Iris.java b/src/main/java/ninja/bytecode/iris/Iris.java index e7b0e8d82..ff3051829 100644 --- a/src/main/java/ninja/bytecode/iris/Iris.java +++ b/src/main/java/ninja/bytecode/iris/Iris.java @@ -111,6 +111,11 @@ public class Iris extends JavaPlugin implements Listener private static File internalResource(String resource) { + if(new File(Iris.instance.getDataFolder(), "pack").exists()) + { + return new File(Iris.instance.getDataFolder(), resource); + } + return new File(System.getProperty("java.io.tmpdir") + "/Iris/" + resource); } @@ -281,13 +286,14 @@ public class Iris extends JavaPlugin implements Listener if(internal.exists()) { - L.v("Loading Resource: " + "Iris/" + string); + L.v("Loading Resource: " + internal.getAbsolutePath()); + L.flush(); return new FileInputStream(internal); } else { - L.f("Cannot find Resource: " + string); + L.f("Cannot find Resource: " + internal.getAbsolutePath()); return null; } } diff --git a/src/main/java/ninja/bytecode/iris/schematic/Schematic.java b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java index d48e53149..470ec109a 100644 --- a/src/main/java/ninja/bytecode/iris/schematic/Schematic.java +++ b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java @@ -13,6 +13,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.util.BlockVector; +import org.bukkit.util.Vector; import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.util.Catalyst12; @@ -32,12 +33,14 @@ public class Schematic private final GMap s; private BlockVector mount; private int mountHeight; + private BlockVector shift; public Schematic(int w, int h, int d) { this.w = w; this.h = h; this.d = d; + shift = new BlockVector(); s = new GMap<>(); centeredHeight = false; } @@ -209,7 +212,9 @@ public class Schematic { start.subtract(0, start.getBlockY() + mountHeight - highestY, 0); } - + + start.add(shift); + for(BlockVector i : getSchematic().k()) { MB b = getSchematic().get(i); @@ -257,4 +262,23 @@ public class Schematic { return name; } + + public void computeFlag(String j) + { + try + { + if(j.startsWith("sink=")) + { + int downshift = Integer.valueOf(j.split("\\Q=\\E")[1]); + shift.subtract(new Vector(0, downshift, 0)); + L.i(" Sank Object: 0,0,0 -> " + shift.getBlockX() + "," + shift.getBlockY() + "," + shift.getBlockZ()); + } + } + + catch(Throwable e) + { + L.f("Failed to compute flag '" + j + "'"); + L.ex(e); + } + } } diff --git a/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java b/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java index ce52343e7..aa625100a 100644 --- a/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java +++ b/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java @@ -5,6 +5,7 @@ import java.io.IOException; import ninja.bytecode.iris.Iris; import ninja.bytecode.shuriken.collections.GList; +import ninja.bytecode.shuriken.io.IO; import ninja.bytecode.shuriken.logging.L; public class SchematicGroup @@ -77,6 +78,19 @@ public class SchematicGroup for(File i : folder.listFiles()) { + if(i.getName().endsWith(".ifl")) + { + try + { + g.flags.add(IO.readAll(i).split("\\Q\n\\E")); + } + + catch(IOException e) + { + L.ex(e); + } + } + if(i.getName().endsWith(".ish")) { try @@ -108,6 +122,11 @@ public class SchematicGroup L.v("# Processing " + i.getName()); L.flush(); i.computeMountShift(); + + for(String j : flags) + { + i.computeFlag(j); + } } } } diff --git a/src/main/java/ninja/bytecode/iris/spec/IrisBiome.java b/src/main/java/ninja/bytecode/iris/spec/IrisBiome.java index 16b95c248..db422bff7 100644 --- a/src/main/java/ninja/bytecode/iris/spec/IrisBiome.java +++ b/src/main/java/ninja/bytecode/iris/spec/IrisBiome.java @@ -13,6 +13,7 @@ import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.execution.J; import ninja.bytecode.shuriken.json.JSONArray; import ninja.bytecode.shuriken.json.JSONObject; +import ninja.bytecode.shuriken.logging.L; import ninja.bytecode.shuriken.math.CNG; import ninja.bytecode.shuriken.math.M; import ninja.bytecode.shuriken.math.RNG; @@ -103,6 +104,7 @@ public class IrisBiome for(String i : schematicGroups.k()) { + L.v("Loading Object Group: " + i); Iris.loadSchematicGroup(i); } }); diff --git a/src/main/resources/pack/biomes/forest.json b/src/main/resources/pack/biomes/forest.json index 2e25b6d10..a94948978 100644 --- a/src/main/resources/pack/biomes/forest.json +++ b/src/main/resources/pack/biomes/forest.json @@ -4,5 +4,12 @@ "scatter":[ "LONG_GRASS:1=0.23", "LONG_GRASS:2=0.13" + ], + "objects": [ + "tree/oak/medium=0.33", + "tree/oak/small=2.2", + "colossal/oak/massive=0.004", + "colossal/oak/superlarge=0.002", + "colossal/oak/supermassive=0.001" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/jungle.json b/src/main/resources/pack/biomes/jungle.json index cf68e89a8..0f2d8a422 100644 --- a/src/main/resources/pack/biomes/jungle.json +++ b/src/main/resources/pack/biomes/jungle.json @@ -4,5 +4,8 @@ "scatter":[ "LONG_GRASS:1=0.58", "LONG_GRASS:2=0.13" + ], + "objects": [ + "colossal/jungle/massive=0.001" ] } \ No newline at end of file