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)
{
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;
}
}

View File

@ -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<BlockVector, MB> 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;
}
@ -210,6 +213,8 @@ 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);
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -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);
}
});

View File

@ -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"
]
}

View File

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