Placement flags

This commit is contained in:
Daniel Mills 2020-01-08 04:01:05 -05:00
parent 0d55247dd9
commit c620a9388f
6 changed files with 64 additions and 3 deletions

View File

@ -111,6 +111,11 @@ public class Iris extends JavaPlugin implements Listener
private static File internalResource(String resource) 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); return new File(System.getProperty("java.io.tmpdir") + "/Iris/" + resource);
} }
@ -281,13 +286,14 @@ public class Iris extends JavaPlugin implements Listener
if(internal.exists()) if(internal.exists())
{ {
L.v("Loading Resource: " + "Iris/" + string); L.v("Loading Resource: " + internal.getAbsolutePath());
L.flush();
return new FileInputStream(internal); return new FileInputStream(internal);
} }
else else
{ {
L.f("Cannot find Resource: " + string); L.f("Cannot find Resource: " + internal.getAbsolutePath());
return null; return null;
} }
} }

View File

@ -13,6 +13,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.util.BlockVector; import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.util.Catalyst12; import ninja.bytecode.iris.util.Catalyst12;
@ -32,12 +33,14 @@ public class Schematic
private final GMap<BlockVector, MB> s; private final GMap<BlockVector, MB> s;
private BlockVector mount; private BlockVector mount;
private int mountHeight; private int mountHeight;
private BlockVector shift;
public Schematic(int w, int h, int d) public Schematic(int w, int h, int d)
{ {
this.w = w; this.w = w;
this.h = h; this.h = h;
this.d = d; this.d = d;
shift = new BlockVector();
s = new GMap<>(); s = new GMap<>();
centeredHeight = false; centeredHeight = false;
} }
@ -209,7 +212,9 @@ public class Schematic
{ {
start.subtract(0, start.getBlockY() + mountHeight - highestY, 0); start.subtract(0, start.getBlockY() + mountHeight - highestY, 0);
} }
start.add(shift);
for(BlockVector i : getSchematic().k()) for(BlockVector i : getSchematic().k())
{ {
MB b = getSchematic().get(i); MB b = getSchematic().get(i);
@ -257,4 +262,23 @@ public class Schematic
{ {
return name; 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);
}
}
} }

View File

@ -5,6 +5,7 @@ import java.io.IOException;
import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.Iris;
import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.io.IO;
import ninja.bytecode.shuriken.logging.L; import ninja.bytecode.shuriken.logging.L;
public class SchematicGroup public class SchematicGroup
@ -77,6 +78,19 @@ public class SchematicGroup
for(File i : folder.listFiles()) 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")) if(i.getName().endsWith(".ish"))
{ {
try try
@ -108,6 +122,11 @@ public class SchematicGroup
L.v("# Processing " + i.getName()); L.v("# Processing " + i.getName());
L.flush(); L.flush();
i.computeMountShift(); i.computeMountShift();
for(String j : flags)
{
i.computeFlag(j);
}
} }
} }
} }

View File

@ -13,6 +13,7 @@ import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.execution.J; import ninja.bytecode.shuriken.execution.J;
import ninja.bytecode.shuriken.json.JSONArray; import ninja.bytecode.shuriken.json.JSONArray;
import ninja.bytecode.shuriken.json.JSONObject; import ninja.bytecode.shuriken.json.JSONObject;
import ninja.bytecode.shuriken.logging.L;
import ninja.bytecode.shuriken.math.CNG; import ninja.bytecode.shuriken.math.CNG;
import ninja.bytecode.shuriken.math.M; import ninja.bytecode.shuriken.math.M;
import ninja.bytecode.shuriken.math.RNG; import ninja.bytecode.shuriken.math.RNG;
@ -103,6 +104,7 @@ public class IrisBiome
for(String i : schematicGroups.k()) for(String i : schematicGroups.k())
{ {
L.v("Loading Object Group: " + i);
Iris.loadSchematicGroup(i); Iris.loadSchematicGroup(i);
} }
}); });

View File

@ -4,5 +4,12 @@
"scatter":[ "scatter":[
"LONG_GRASS:1=0.23", "LONG_GRASS:1=0.23",
"LONG_GRASS:2=0.13" "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"
] ]
} }

View File

@ -4,5 +4,8 @@
"scatter":[ "scatter":[
"LONG_GRASS:1=0.58", "LONG_GRASS:1=0.58",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"
],
"objects": [
"colossal/jungle/massive=0.001"
] ]
} }