mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Schematic Placement
This commit is contained in:
parent
9940e61fec
commit
0d55247dd9
@ -28,8 +28,10 @@ public class Schematic
|
||||
private int w;
|
||||
private int h;
|
||||
private int d;
|
||||
private String name = "?";
|
||||
private final GMap<BlockVector, MB> s;
|
||||
private BlockVector mount;
|
||||
private int mountHeight;
|
||||
|
||||
public Schematic(int w, int h, int d)
|
||||
{
|
||||
@ -52,7 +54,6 @@ public class Schematic
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GList<BlockVector> fmount = new GList<>();
|
||||
|
||||
for(BlockVector i : s.k())
|
||||
@ -76,7 +77,9 @@ public class Schematic
|
||||
c++;
|
||||
}
|
||||
|
||||
mount = new BlockVector(avg(avx), avg(avy), avg(avz));
|
||||
mountHeight = avg(avy);
|
||||
mount = new BlockVector(avg(avx), 0, avg(avz));
|
||||
L.i(" Corrected Mount Point: 0,0,0 -> " + mount.getBlockX() + "," + mount.getBlockY() + "," + mount.getBlockZ());
|
||||
}
|
||||
|
||||
private int avg(double[] v)
|
||||
@ -85,7 +88,7 @@ public class Schematic
|
||||
|
||||
for(int i = 0; i < v.length; i++)
|
||||
{
|
||||
g+=v[i];
|
||||
g += v[i];
|
||||
}
|
||||
|
||||
return (int) Math.round(g / (double) v.length);
|
||||
@ -199,7 +202,13 @@ public class Schematic
|
||||
|
||||
public void place(World source, int wx, int wy, int wz)
|
||||
{
|
||||
Location start = new Location(source, wx, wy, wz).clone().add(sh(w), sh(h) + 1, sh(d));
|
||||
Location start = new Location(source, wx, wy, wz).clone().add(sh(w), sh(h) + 1, sh(d)).subtract(mount);
|
||||
int highestY = source.getHighestBlockYAt(start);
|
||||
|
||||
if(start.getBlockY() + mountHeight > highestY)
|
||||
{
|
||||
start.subtract(0, start.getBlockY() + mountHeight - highestY, 0);
|
||||
}
|
||||
|
||||
for(BlockVector i : getSchematic().k())
|
||||
{
|
||||
@ -236,10 +245,16 @@ public class Schematic
|
||||
public static Schematic load(File f) throws IOException
|
||||
{
|
||||
Schematic s = new Schematic(1, 1, 1);
|
||||
s.name = f.getName().replaceAll("\\Q.ish\\E", "");
|
||||
FileInputStream fin = new FileInputStream(f);
|
||||
s.read(fin);
|
||||
|
||||
L.i("Loaded Schematic: " + f.getPath() + " Size: " + s.getSchematic().size());
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -102,5 +102,12 @@ public class SchematicGroup
|
||||
public void processVariants()
|
||||
{
|
||||
L.v("Processing " + name + " Objects");
|
||||
|
||||
for(Schematic i : getSchematics())
|
||||
{
|
||||
L.v("# Processing " + i.getName());
|
||||
L.flush();
|
||||
i.computeMountShift();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user