mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 15:26:28 +00:00
Schematics
This commit is contained in:
@@ -3,15 +3,18 @@ package ninja.bytecode.iris.generator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
|
||||
import mortar.util.text.C;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.controller.PackController;
|
||||
import ninja.bytecode.iris.generator.genobject.GenObjectDecorator;
|
||||
import ninja.bytecode.iris.generator.genobject.PlacedObject;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerBiome;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerCarving;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerCaverns;
|
||||
@@ -62,6 +65,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
private MB PACKED_ICE = new MB(Material.PACKED_ICE);
|
||||
private MB WATER = new MB(Material.STATIONARY_WATER);
|
||||
private MB BEDROCK = new MB(Material.BEDROCK);
|
||||
private GenObjectDecorator god;
|
||||
private GenLayerLayeredNoise glLNoise;
|
||||
private GenLayerBiome glBiome;
|
||||
private GenLayerCaves glCaves;
|
||||
@@ -350,7 +354,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
|
||||
if(Iris.settings.gen.genObjects)
|
||||
{
|
||||
p.add(new GenObjectDecorator(this));
|
||||
p.add(god = new GenObjectDecorator(this));
|
||||
}
|
||||
|
||||
return p;
|
||||
@@ -408,4 +412,25 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
return disposed;
|
||||
}
|
||||
|
||||
public PlacedObject nearest(Location o, int i)
|
||||
{
|
||||
PlacedObject f = null;
|
||||
double d = Integer.MAX_VALUE;
|
||||
if(god != null)
|
||||
{
|
||||
for(PlacedObject j : god.getHistory())
|
||||
{
|
||||
double dx = Math.abs(NumberConversions.square(j.getX() - o.getX()) + NumberConversions.square(j.getY() - o.getY()) + NumberConversions.square(j.getZ() - o.getZ()));
|
||||
|
||||
if(dx < d)
|
||||
{
|
||||
d = dx;
|
||||
f = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,8 @@ public class GenObject
|
||||
private int w;
|
||||
private int h;
|
||||
private int d;
|
||||
private int failures;
|
||||
private int successes;
|
||||
private String name = "?";
|
||||
private final GMap<SBlockVector, MB> s;
|
||||
private BlockVector mount;
|
||||
@@ -290,14 +292,10 @@ public class GenObject
|
||||
L.w(C.WHITE + "Object " + C.YELLOW + getName() + C.WHITE + " failed to place in " + C.YELLOW + m.toString().toLowerCase() + C.WHITE + " at " + C.YELLOW + F.f(f.getBlockX()) + " " + F.f(f.getBlockY()) + " " + F.f(f.getBlockZ()));
|
||||
}
|
||||
|
||||
failures++;
|
||||
return null;
|
||||
}
|
||||
|
||||
if(b.material.equals(Material.SKULL))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
undo.put(f, placer.get(f));
|
||||
@@ -310,6 +308,7 @@ public class GenObject
|
||||
}
|
||||
}
|
||||
|
||||
successes++;
|
||||
return start;
|
||||
}
|
||||
|
||||
@@ -592,6 +591,26 @@ public class GenObject
|
||||
}
|
||||
}
|
||||
|
||||
public double getSuccess()
|
||||
{
|
||||
return (double) successes / ((double) successes + (double) failures);
|
||||
}
|
||||
|
||||
public int getFailures()
|
||||
{
|
||||
return failures;
|
||||
}
|
||||
|
||||
public int getSuccesses()
|
||||
{
|
||||
return successes;
|
||||
}
|
||||
|
||||
public int getPlaces()
|
||||
{
|
||||
return successes + failures;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
s.clear();
|
||||
|
||||
@@ -32,6 +32,7 @@ import ninja.bytecode.shuriken.math.M;
|
||||
|
||||
public class GenObjectDecorator extends BlockPopulator
|
||||
{
|
||||
private GList<PlacedObject> placeHistory;
|
||||
private GMap<IrisBiome, GList<GenObjectGroup>> orderCache;
|
||||
private GMap<IrisBiome, GMap<GenObjectGroup, Double>> populationCache;
|
||||
private IPlacer placer;
|
||||
@@ -42,6 +43,7 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
public GenObjectDecorator(IrisGenerator generator)
|
||||
{
|
||||
this.g = generator;
|
||||
placeHistory = new GList<>();
|
||||
populationCache = new GMap<>();
|
||||
orderCache = new GMap<>();
|
||||
ex = Executors.newSingleThreadExecutor();
|
||||
@@ -103,6 +105,7 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
{
|
||||
if(g.isDisposed())
|
||||
{
|
||||
placeHistory.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -156,7 +159,11 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
|
||||
if(!t.isSolid() || !biome.isSurface(t))
|
||||
{
|
||||
L.w(C.WHITE + "Object " + C.YELLOW + i.getName() + "/*" + C.WHITE + " failed to place in " + C.YELLOW + t.toString().toLowerCase() + C.WHITE + " at " + C.YELLOW + F.f(b.getX()) + " " + F.f(b.getY()) + " " + F.f(b.getZ()));
|
||||
if(Iris.settings.performance.verbose)
|
||||
{
|
||||
L.w(C.WHITE + "Object " + C.YELLOW + i.getName() + "/*" + C.WHITE + " failed to place in " + C.YELLOW + t.toString().toLowerCase() + C.WHITE + " at " + C.YELLOW + F.f(b.getX()) + " " + F.f(b.getY()) + " " + F.f(b.getZ()));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -178,9 +185,25 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
{
|
||||
Location start = g.place(x, b.getY(), z, placer);
|
||||
|
||||
if(start != null && Iris.settings.performance.verbose)
|
||||
if(start != null)
|
||||
{
|
||||
L.v(C.GRAY + "Placed " + C.DARK_GREEN + i.getName() + C.WHITE + "/" + C.DARK_GREEN + g.getName() + C.GRAY + " at " + C.DARK_GREEN + F.f(start.getBlockX()) + " " + F.f(start.getBlockY()) + " " + F.f(start.getBlockZ()));
|
||||
if(Iris.settings.performance.verbose)
|
||||
{
|
||||
L.v(C.GRAY + "Placed " + C.DARK_GREEN + i.getName() + C.WHITE + "/" + C.DARK_GREEN + g.getName() + C.GRAY + " at " + C.DARK_GREEN + F.f(start.getBlockX()) + " " + F.f(start.getBlockY()) + " " + F.f(start.getBlockZ()));
|
||||
}
|
||||
|
||||
if(Iris.settings.performance.debugMode)
|
||||
{
|
||||
placeHistory.add(new PlacedObject(start.getBlockX(), start.getBlockY(), start.getBlockZ(), i.getName() + ":" + g.getName()));
|
||||
|
||||
if(placeHistory.size() > Iris.settings.performance.placeHistoryLimit)
|
||||
{
|
||||
while(placeHistory.size() > Iris.settings.performance.placeHistoryLimit)
|
||||
{
|
||||
placeHistory.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -214,4 +237,9 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
|
||||
return floor;
|
||||
}
|
||||
|
||||
public GList<PlacedObject> getHistory()
|
||||
{
|
||||
return placeHistory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package ninja.bytecode.iris.generator.genobject;
|
||||
|
||||
public class PlacedObject
|
||||
{
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private String f;
|
||||
|
||||
public PlacedObject(int x, int y, int z, String f)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x)
|
||||
{
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(int y)
|
||||
{
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(int z)
|
||||
{
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public String getF()
|
||||
{
|
||||
return f;
|
||||
}
|
||||
|
||||
public void setF(String f)
|
||||
{
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((f == null) ? 0 : f.hashCode());
|
||||
result = prime * result + x;
|
||||
result = prime * result + y;
|
||||
result = prime * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
return true;
|
||||
if(obj == null)
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
return false;
|
||||
PlacedObject other = (PlacedObject) obj;
|
||||
if(f == null)
|
||||
{
|
||||
if(other.f != null)
|
||||
return false;
|
||||
}
|
||||
else if(!f.equals(other.f))
|
||||
return false;
|
||||
if(x != other.x)
|
||||
return false;
|
||||
if(y != other.y)
|
||||
return false;
|
||||
if(z != other.z)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user