More SPEED

This commit is contained in:
Daniel Mills
2020-09-11 11:06:32 -04:00
parent be6739ecb8
commit 1618d54b70
18 changed files with 199 additions and 122 deletions
@@ -40,9 +40,11 @@ public class CommandIrisMetrics extends MortarCommand
sender.sendMessage("Thread Count: " + C.BOLD + "" + C.WHITE + g.getThreads()); sender.sendMessage("Thread Count: " + C.BOLD + "" + C.WHITE + g.getThreads());
sender.sendMessage("Total : " + C.BOLD + "" + C.WHITE + Form.duration(m.getTotal().getAverage(), 2)); sender.sendMessage("Total : " + C.BOLD + "" + C.WHITE + Form.duration(m.getTotal().getAverage(), 2));
sender.sendMessage(" Terrain : " + C.BOLD + "" + C.WHITE + Form.duration(m.getTerrain().getAverage(), 2)); sender.sendMessage(" Terrain : " + C.BOLD + "" + C.WHITE + Form.duration(m.getTerrain().getAverage(), 2));
sender.sendMessage(" Deposits : " + C.BOLD + "" + C.WHITE + Form.duration(m.getDeposits().getAverage(), 2));
sender.sendMessage(" Parallax: " + C.BOLD + "" + C.WHITE + Form.duration(m.getParallax().getAverage(), 2)); sender.sendMessage(" Parallax: " + C.BOLD + "" + C.WHITE + Form.duration(m.getParallax().getAverage(), 2));
sender.sendMessage(" Post : " + C.BOLD + "" + C.WHITE + Form.duration(m.getPost().getAverage(), 2)); sender.sendMessage(" Post : " + C.BOLD + "" + C.WHITE + Form.duration(m.getPost().getAverage(), 2));
sender.sendMessage("Updates : " + C.BOLD + "" + C.WHITE + Form.duration(m.getUpdate().getAverage(), 2)); sender.sendMessage("Lighting : " + C.BOLD + "" + C.WHITE + Form.duration(m.getUpdate().getAverage(), 2));
sender.sendMessage("Spawns : " + C.BOLD + "" + C.WHITE + Form.duration(m.getSpawns().getAverage(), 2));
return true; return true;
} }
@@ -81,7 +81,10 @@ public abstract class DimensionalTerrainProvider extends ContextualTerrainProvid
public void onInit(RNG masterRandom) public void onInit(RNG masterRandom)
{ {
if(getDimension().hasSky())
{
getDimension().getSky().setSkyDimension(true);
}
} }
public IrisDimension getDimension() public IrisDimension getDimension()
@@ -40,7 +40,7 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class IrisTerrainProvider extends PostBlockTerrainProvider implements IrisContext public class IrisTerrainProvider extends SkyTerrainProvider implements IrisContext
{ {
private IrisBiome hb = null; private IrisBiome hb = null;
private IrisRegion hr = null; private IrisRegion hr = null;
@@ -112,7 +112,7 @@ public abstract class ParallaxTerrainProvider extends TopographicTerrainProvider
@Override @Override
public BlockData get(int x, int y, int z) public BlockData get(int x, int y, int z)
{ {
BlockData b = sampleSliver(x, z).getBlock().get(y); BlockData b = sampleSliver(x, z).getBlock()[y];
return b == null ? AIR : b; return b == null ? AIR : b;
} }
@@ -72,7 +72,6 @@ public abstract class ParallelTerrainProvider extends DimensionalTerrainProvider
String key = "c" + x + "," + z; String key = "c" + x + "," + z;
BiomeMap biomeMap = new BiomeMap(); BiomeMap biomeMap = new BiomeMap();
int ii, jj; int ii, jj;
onPreGenerate(random, x, z, terrain, height, biomeMap, map); onPreGenerate(random, x, z, terrain, height, biomeMap, map);
for(ii = 0; ii < 16; ii++) for(ii = 0; ii < 16; ii++)
@@ -102,8 +101,7 @@ public abstract class ParallelTerrainProvider extends DimensionalTerrainProvider
} }
accelerant.waitFor(key); accelerant.waitFor(key);
map.write(terrain, terrain, height, true);
map.write(terrain, terrain, height);
getMetrics().getTerrain().put(p.getMilliseconds()); getMetrics().getTerrain().put(p.getMilliseconds());
p = PrecisionStopwatch.start(); p = PrecisionStopwatch.start();
onPostGenerate(random, x, z, terrain, height, biomeMap, map); onPostGenerate(random, x, z, terrain, height, biomeMap, map);
@@ -24,8 +24,6 @@ public abstract class PostBlockTerrainProvider extends ParallaxTerrainProvider i
private String postKey; private String postKey;
private IrisLock postLock; private IrisLock postLock;
private PostMasterPatcher patcher; private PostMasterPatcher patcher;
private int minPhase;
private int maxPhase;
public PostBlockTerrainProvider(TerrainTarget t, String dimensionName, int threads) public PostBlockTerrainProvider(TerrainTarget t, String dimensionName, int threads)
{ {
@@ -50,23 +48,21 @@ public abstract class PostBlockTerrainProvider extends ParallaxTerrainProvider i
return; return;
} }
int rx, i, j; int rx, i;
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
KList<Runnable> q = new KList<>(); KList<Runnable> q = new KList<>();
for(i = 0; i < 16; i++) for(i = 0; i < 16; i++)
{ {
rx = (x << 4) + i; rx = (x << 4) + i;
for(j = 0; j < 16; j++)
{
int rxx = rx; int rxx = rx;
int rzz = (z << 4) + j;
getAccelerant().queue("post", () -> getAccelerant().queue("post", () ->
{ {
patcher.onPost(rxx, rzz, x, z, terrain, q); for(int j = 0; j < 16; j++)
}); {
patcher.onPost(rxx, (z << 4) + j, x, z, terrain, q);
} }
});
} }
getAccelerant().waitFor("post"); getAccelerant().waitFor("post");
@@ -0,0 +1,19 @@
package com.volmit.iris.gen;
import com.volmit.iris.gen.scaffold.TerrainChunk;
import com.volmit.iris.gen.scaffold.TerrainTarget;
import com.volmit.iris.util.RNG;
public abstract class SkyTerrainProvider extends PostBlockTerrainProvider
{
public SkyTerrainProvider(TerrainTarget t, String dimensionName, int threads)
{
super(t, dimensionName, threads);
}
@Override
protected void onGenerate(RNG random, int x, int z, TerrainChunk terrain)
{
super.onGenerate(random, x, z, terrain);
}
}
@@ -20,6 +20,7 @@ import com.volmit.iris.object.InferredType;
import com.volmit.iris.object.IrisBiome; import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisBiomeDecorator; import com.volmit.iris.object.IrisBiomeDecorator;
import com.volmit.iris.object.IrisBiomeGeneratorLink; import com.volmit.iris.object.IrisBiomeGeneratorLink;
import com.volmit.iris.object.IrisDepositGenerator;
import com.volmit.iris.object.IrisDimension; import com.volmit.iris.object.IrisDimension;
import com.volmit.iris.object.IrisGenerator; import com.volmit.iris.object.IrisGenerator;
import com.volmit.iris.object.IrisRegion; import com.volmit.iris.object.IrisRegion;
@@ -33,6 +34,7 @@ import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.KMap; import com.volmit.iris.util.KMap;
import com.volmit.iris.util.M; import com.volmit.iris.util.M;
import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
import lombok.Data; import lombok.Data;
@@ -286,12 +288,6 @@ public abstract class TopographicTerrainProvider extends ParallelTerrainProvider
// Carve out biomes // Carve out biomes
KList<CaveResult> caveResults = glCave.genCaves(rx, rz, x, z, sliver); KList<CaveResult> caveResults = glCave.genCaves(rx, rz, x, z, sliver);
KList<CaveResult> caveResults1 = glCave.genCaves(rx, rz, x, z, null);
if(caveResults.size() != caveResults1.size())
{
Iris.warn("REAL: " + caveResults.size() + " Guess: " + caveResults1.size());
}
IrisBiome caveBiome = glBiome.generateData(InferredType.CAVE, wx, wz, rx, rz, region); IrisBiome caveBiome = glBiome.generateData(InferredType.CAVE, wx, wz, rx, rz, region);
@@ -300,11 +296,16 @@ public abstract class TopographicTerrainProvider extends ParallelTerrainProvider
{ {
for(CaveResult i : caveResults) for(CaveResult i : caveResults)
{ {
if(i.getFloor() < 0 || i.getFloor() > 255 || i.getCeiling() > 255 || i.getCeiling() < 0)
{
continue;
}
if(Iris.biome3d) if(Iris.biome3d)
{ {
for(int j = i.getFloor(); j <= i.getCeiling(); j++) for(int j = i.getFloor(); j <= i.getCeiling(); j++)
{ {
sliver.set(j, caveBiome);
sliver.set(j, caveBiome.getGroundBiome(getMasterRandom(), rz, j, rx)); sliver.set(j, caveBiome.getGroundBiome(getMasterRandom(), rz, j, rx));
} }
} }
@@ -537,7 +538,41 @@ public abstract class TopographicTerrainProvider extends ParallelTerrainProvider
protected void onPreParallaxPostGenerate(RNG random, int x, int z, TerrainChunk terrain, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map) protected void onPreParallaxPostGenerate(RNG random, int x, int z, TerrainChunk terrain, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map)
{ {
if(!getDimension().isVanillaCaves())
{
generateDeposits(random.nextParallelRNG(x).nextParallelRNG(z), terrain, x, z);
}
}
public void generateDeposits(RNG rx, TerrainChunk terrain, int x, int z)
{
PrecisionStopwatch p = PrecisionStopwatch.start();
RNG ro = rx.nextParallelRNG((x * x * x) - z);
IrisRegion region = sampleRegion((x * 16) + 7, (z * 16) + 7);
IrisBiome biome = sampleTrueBiome((x * 16) + 7, (z * 16) + 7);
for(IrisDepositGenerator k : getDimension().getDeposits())
{
k.generate(terrain, ro, this, x, z, false);
}
for(IrisDepositGenerator k : region.getDeposits())
{
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
{
k.generate(terrain, ro, this, x, z, false);
}
}
for(IrisDepositGenerator k : biome.getDeposits())
{
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
{
k.generate(terrain, ro, this, x, z, false);
}
}
p.end();
getMetrics().getDeposits().put(p.getMilliseconds());
} }
protected void onPostParallaxPostGenerate(RNG random, int x, int z, TerrainChunk terrain, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map) protected void onPostParallaxPostGenerate(RNG random, int x, int z, TerrainChunk terrain, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map)
@@ -11,13 +11,10 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData; import org.bukkit.generator.ChunkGenerator.ChunkData;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.util.B; import com.volmit.iris.util.B;
import com.volmit.iris.util.HeightMap; import com.volmit.iris.util.HeightMap;
import com.volmit.iris.util.IrisLock; import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.KMap;
import com.volmit.iris.util.KSet;
import com.volmit.iris.util.M; import com.volmit.iris.util.M;
import lombok.Data; import lombok.Data;
@@ -27,28 +24,26 @@ public class AtomicSliver
{ {
public static final BlockData AIR = B.getBlockData("AIR"); public static final BlockData AIR = B.getBlockData("AIR");
public static boolean forgetful = false; public static boolean forgetful = false;
private transient KMap<Integer, IrisBiome> truebiome; private transient Biome[] biome;
private transient KMap<Integer, Biome> biome;
private transient Biome onlyBiome; private transient Biome onlyBiome;
private transient IrisLock lock = new IrisLock("Sliver"); private transient IrisLock lock = new IrisLock("Sliver");
private transient int highestBiome = 0; private transient short highestBiome = 0;
private transient long last = M.ms(); private transient long last = M.ms();
private transient final int x; private transient final byte x;
private transient final int z; private transient final byte z;
private transient boolean modified = false; private transient boolean modified = false;
private KMap<Integer, BlockData> block; private BlockData[] block;
private KSet<Integer> blockUpdates; private KList<Byte> blockUpdates;
private int highestBlock = 0; private int highestBlock = 0;
public AtomicSliver(int x, int z) public AtomicSliver(int x, int z)
{ {
onlyBiome = null; onlyBiome = null;
this.x = x; this.x = (byte) x;
this.z = z; this.z = (byte) z;
blockUpdates = new KSet<>(); blockUpdates = new KList<>(4);
this.block = new KMap<>(); this.block = new BlockData[256];
this.biome = new KMap<>(); this.biome = new Biome[256];
this.truebiome = new KMap<>();
} }
public Material getType(int h) public Material getType(int h)
@@ -56,29 +51,29 @@ public class AtomicSliver
return get(h).getMaterial(); return get(h).getMaterial();
} }
public KSet<Integer> getUpdatables() public KList<Byte> getUpdatables()
{ {
return blockUpdates; return blockUpdates;
} }
public void update(int y) public void update(byte y)
{ {
if(forgetful) if(forgetful)
{ {
return; return;
} }
blockUpdates.add(y); blockUpdates.addIfMissing((byte) (y + Byte.MIN_VALUE));
} }
public void dontUpdate(int y) public void dontUpdate(byte y)
{ {
if(forgetful) if(forgetful)
{ {
return; return;
} }
blockUpdates.remove(y); blockUpdates.remove(Byte.valueOf((byte) (y + Byte.MIN_VALUE)));
} }
public BlockData get(int h) public BlockData get(int h)
@@ -87,7 +82,7 @@ public class AtomicSliver
{ {
return null; return null;
} }
BlockData b = block.get(h); BlockData b = block[h];
last = M.ms(); last = M.ms();
if(b == null) if(b == null)
@@ -104,7 +99,7 @@ public class AtomicSliver
{ {
return null; return null;
} }
BlockData b = block.get(h); BlockData b = block[h];
last = M.ms(); last = M.ms();
if(b.getMaterial().equals(Material.AIR)) if(b.getMaterial().equals(Material.AIR))
@@ -144,16 +139,16 @@ public class AtomicSliver
lock.lock(); lock.lock();
modified = true; modified = true;
block.put(h, d); block[h] = d;
if(B.isUpdatable(d)) if(B.isUpdatable(d))
{ {
update(h); update((byte) h);
} }
else else
{ {
dontUpdate(h); dontUpdate((byte) h);
} }
lock.unlock(); lock.unlock();
@@ -164,30 +159,13 @@ public class AtomicSliver
return getType(h).isSolid(); return getType(h).isSolid();
} }
public Biome getBiome(int h)
{
if(!Iris.biome3d)
{
return onlyBiome != null ? onlyBiome : Biome.THE_VOID;
}
last = M.ms();
return biome.containsKey(h) ? biome.get(h) : Biome.THE_VOID;
}
public IrisBiome getTrueBiome(int h)
{
last = M.ms();
return truebiome.get(h);
}
public void set(int h, Biome d) public void set(int h, Biome d)
{ {
lock.lock(); lock.lock();
if(Iris.biome3d) if(Iris.biome3d)
{ {
biome.put(h, d); biome[h] = d;
} }
else else
@@ -196,19 +174,11 @@ public class AtomicSliver
} }
modified = true; modified = true;
highestBiome = h > highestBiome ? h : highestBiome; highestBiome = (short) (h > highestBiome ? h : highestBiome);
lock.unlock(); lock.unlock();
} }
public void set(int h, IrisBiome d) public void write(ChunkData d, boolean skipNull)
{
lock.lock();
modified = true;
truebiome.put(h, d);
lock.unlock();
}
public void write(ChunkData d)
{ {
if(forgetful) if(forgetful)
{ {
@@ -219,14 +189,17 @@ public class AtomicSliver
for(int i = 0; i <= highestBlock; i++) for(int i = 0; i <= highestBlock; i++)
{ {
if(block.get(i) == null) if(block[i] == null)
{
if(!skipNull)
{ {
d.setBlock(x, i, z, AIR); d.setBlock(x, i, z, AIR);
} }
}
else else
{ {
d.setBlock(x, i, z, block.get(i)); d.setBlock(x, i, z, block[i]);
} }
} }
lock.unlock(); lock.unlock();
@@ -246,9 +219,9 @@ public class AtomicSliver
for(int i = 0; i <= highestBiome; i++) for(int i = 0; i <= highestBiome; i++)
{ {
if(biome.get(i) != null) if(biome[i] != null)
{ {
d.setBiome(x, i, z, biome.get(i)); d.setBiome(x, i, z, biome[i]);
} }
} }
@@ -265,7 +238,7 @@ public class AtomicSliver
public void read(DataInputStream din) throws IOException public void read(DataInputStream din) throws IOException
{ {
lock.lock(); lock.lock();
this.block = new KMap<Integer, BlockData>(); this.block = new BlockData[256];
getUpdatables().clear(); getUpdatables().clear();
// Block Palette // Block Palette
@@ -283,13 +256,13 @@ public class AtomicSliver
// Blocks // Blocks
for(int i = 0; i <= h; i++) for(int i = 0; i <= h; i++)
{ {
block.put(i, palette.get(din.readByte() - Byte.MIN_VALUE).clone()); block[i] = palette.get(din.readByte() - Byte.MIN_VALUE).clone();
} }
// Updates // Updates
for(int i = 0; i < u; i++) for(int i = 0; i < u; i++)
{ {
update(din.readByte() - Byte.MIN_VALUE); update(din.readByte());
} }
modified = false; modified = false;
@@ -309,7 +282,7 @@ public class AtomicSliver
for(int i = 0; i <= highestBlock; i++) for(int i = 0; i <= highestBlock; i++)
{ {
BlockData dat = block.get(i); BlockData dat = block[i];
String d = (dat == null ? AIR : dat).getAsString(true); String d = (dat == null ? AIR : dat).getAsString(true);
if(!palette.contains(d)) if(!palette.contains(d))
@@ -330,15 +303,15 @@ public class AtomicSliver
// Blocks // Blocks
for(int i = 0; i <= highestBlock; i++) for(int i = 0; i <= highestBlock; i++)
{ {
BlockData dat = block.get(i); BlockData dat = block[i];
String d = (dat == null ? AIR : dat).getAsString(true); String d = (dat == null ? AIR : dat).getAsString(true);
dos.writeByte(palette.indexOf(d) + Byte.MIN_VALUE); dos.writeByte(palette.indexOf(d) + Byte.MIN_VALUE);
} }
// Updates // Updates
for(Integer i : getUpdatables()) for(Byte i : getUpdatables())
{ {
dos.writeByte(i + Byte.MIN_VALUE); dos.writeByte(i);
} }
lock.unlock(); lock.unlock();
@@ -353,15 +326,15 @@ public class AtomicSliver
lock.lock(); lock.lock();
for(int i = 0; i < 256; i++) for(int i = 0; i < 256; i++)
{ {
if(block.get(i) == null || block.get(i).equals(AIR)) if(block[i] == null || block[i].equals(AIR))
{ {
BlockData b = atomicSliver.block.get(i); BlockData b = atomicSliver.block[i];
if(b == null || b.equals(AIR)) if(b == null || b.equals(AIR))
{ {
continue; continue;
} }
block.put(i, b); block[i] = b;
} }
} }
lock.unlock(); lock.unlock();
@@ -375,9 +348,9 @@ public class AtomicSliver
} }
lock.lock(); lock.lock();
for(int i : block.keySet()) for(int i = 0; i < block.length; i++)
{ {
BlockData b = block.get(i); BlockData b = block[i];
if(b != null) if(b != null)
{ {
if(b.getMaterial().equals(Material.AIR)) if(b.getMaterial().equals(Material.AIR))
@@ -402,7 +375,7 @@ public class AtomicSliver
return M.ms() - last > m; return M.ms() - last > m;
} }
public void inject(KSet<Integer> updatables) public void inject(KList<Byte> updatables)
{ {
if(forgetful) if(forgetful)
{ {
@@ -166,13 +166,13 @@ public class AtomicSliverMap
return slivers[x * 16 + z]; return slivers[x * 16 + z];
} }
public void write(ChunkData data, BiomeGrid grid, HeightMap height) public void write(ChunkData data, BiomeGrid grid, HeightMap height, boolean skipNull)
{ {
for(AtomicSliver i : slivers) for(AtomicSliver i : slivers)
{ {
if(i != null) if(i != null)
{ {
i.write(data); i.write(data, skipNull);
i.write(grid); i.write(grid);
i.write(height); i.write(height);
} }
@@ -86,6 +86,11 @@ public class GenLayerCave extends GenLayer
double distanceTake = 0.0022 * baseWidth; double distanceTake = 0.0022 * baseWidth;
double caveHeightNoise = layer.getVerticalSlope().get(rng, wxx, wzz); double caveHeightNoise = layer.getVerticalSlope().get(rng, wxx, wzz);
if(caveHeightNoise > 259 || caveHeightNoise < -1)
{
return;
}
int ceiling = -256; int ceiling = -256;
int floor = 512; int floor = 512;
@@ -12,7 +12,6 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.IrisTerrainProvider; import com.volmit.iris.gen.IrisTerrainProvider;
import com.volmit.iris.gen.ParallaxTerrainProvider; import com.volmit.iris.gen.ParallaxTerrainProvider;
import com.volmit.iris.gen.atomics.AtomicSliverMap; import com.volmit.iris.gen.atomics.AtomicSliverMap;
@@ -44,23 +43,29 @@ public class GenLayerUpdate extends BlockPopulator
@Override @Override
public void populate(World w, Random r, Chunk c) public void populate(World w, Random r, Chunk c)
{ {
PrecisionStopwatch p = PrecisionStopwatch.start();
AtomicSliverMap map = gen.getParallaxChunk(c.getX(), c.getZ()); AtomicSliverMap map = gen.getParallaxChunk(c.getX(), c.getZ());
RNG rx = rng.nextParallelRNG(c.getX() + r.nextInt()).nextParallelRNG(c.getZ() + r.nextInt()); RNG rx = rng.nextParallelRNG(c.getX() + r.nextInt()).nextParallelRNG(c.getZ() + r.nextInt());
generateDeposits(w, rx, c);
if(gen.getDimension().isVanillaCaves())
{
generateDepositsWithVanillaSaftey(w, rx, c);
}
updateBlocks(w, rx, c, map); updateBlocks(w, rx, c, map);
spawnInitials(c, rx); spawnInitials(c, rx);
p.end();
gen.getMetrics().getUpdate().put(p.getMilliseconds());
} }
public void spawnInitials(Chunk c, RNG rx) public void spawnInitials(Chunk c, RNG rx)
{ {
PrecisionStopwatch p = PrecisionStopwatch.start();
((IrisTerrainProvider) gen).spawnInitials(c, rx); ((IrisTerrainProvider) gen).spawnInitials(c, rx);
p.end();
gen.getMetrics().getSpawns().put(p.getMilliseconds());
} }
public void generateDeposits(World w, RNG rx, Chunk c) public void generateDepositsWithVanillaSaftey(World w, RNG rx, Chunk c)
{ {
PrecisionStopwatch p = PrecisionStopwatch.start();
int x = c.getX(); int x = c.getX();
int z = c.getZ(); int z = c.getZ();
RNG ro = rx.nextParallelRNG((x * x * x) - z); RNG ro = rx.nextParallelRNG((x * x * x) - z);
@@ -70,14 +75,14 @@ public class GenLayerUpdate extends BlockPopulator
for(IrisDepositGenerator k : gen.getDimension().getDeposits()) for(IrisDepositGenerator k : gen.getDimension().getDeposits())
{ {
k.generate(terrain, ro, gen, x, z); k.generate(terrain, ro, gen, x, z, true);
} }
for(IrisDepositGenerator k : region.getDeposits()) for(IrisDepositGenerator k : region.getDeposits())
{ {
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
{ {
k.generate(terrain, ro, gen, x, z); k.generate(terrain, ro, gen, x, z, true);
} }
} }
@@ -85,19 +90,23 @@ public class GenLayerUpdate extends BlockPopulator
{ {
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
{ {
k.generate(terrain, ro, gen, x, z); k.generate(terrain, ro, gen, x, z, true);
} }
} }
p.end();
gen.getMetrics().getDeposits().put(p.getMilliseconds());
} }
private void updateBlocks(World w, RNG rx, Chunk c, AtomicSliverMap map) private void updateBlocks(World w, RNG rx, Chunk c, AtomicSliverMap map)
{ {
PrecisionStopwatch p = PrecisionStopwatch.start();
for(int i = 0; i < 16; i++) for(int i = 0; i < 16; i++)
{ {
for(int j = 0; j < 16; j++) for(int j = 0; j < 16; j++)
{ {
for(int k : map.getSliver(i, j).getUpdatables()) for(byte kv : map.getSliver(i, j).getUpdatables())
{ {
byte k = (byte) (kv - Byte.MIN_VALUE);
if(k > 255 || k < 0) if(k > 255 || k < 0)
{ {
continue; continue;
@@ -107,6 +116,8 @@ public class GenLayerUpdate extends BlockPopulator
} }
} }
} }
p.end();
gen.getMetrics().getUpdate().put(p.getMilliseconds());
} }
public void update(Chunk c, int x, int y, int z, int rx, int rz, RNG rng) public void update(Chunk c, int x, int y, int z, int rx, int rz, RNG rng)
@@ -223,11 +234,10 @@ public class GenLayerUpdate extends BlockPopulator
catch(Throwable e) catch(Throwable e)
{ {
Iris.error("NOT INVENTORY: " + data.getMaterial().name());
}
} }
} }
}
public void scramble(Inventory inventory, RNG rng) public void scramble(Inventory inventory, RNG rng)
{ {
@@ -12,6 +12,8 @@ public class IrisMetrics
private final RollingSequence terrain; private final RollingSequence terrain;
private final RollingSequence post; private final RollingSequence post;
private final RollingSequence update; private final RollingSequence update;
private final RollingSequence deposits;
private final RollingSequence spawns;
private final RollingSequence total; private final RollingSequence total;
private final RollingSequence perSecond; private final RollingSequence perSecond;
public int generators = 0; public int generators = 0;
@@ -20,9 +22,11 @@ public class IrisMetrics
public IrisMetrics(int memory) public IrisMetrics(int memory)
{ {
parallax = new RollingSequence(memory); parallax = new RollingSequence(memory);
spawns = new RollingSequence(memory);
terrain = new RollingSequence(memory); terrain = new RollingSequence(memory);
post = new RollingSequence(memory); post = new RollingSequence(memory);
update = new RollingSequence(memory); update = new RollingSequence(memory);
deposits = new RollingSequence(memory);
total = new RollingSequence(memory); total = new RollingSequence(memory);
perSecond = new RollingSequence(5); perSecond = new RollingSequence(5);
} }
@@ -199,7 +199,7 @@ public class ProjectManager
File packEntry = new File(packs, key); File packEntry = new File(packs, key);
if(packEntry.exists()) if(packEntry.exists() && packEntry.listFiles().length > 0)
{ {
sender.sendMessage("Another pack is using the key " + key + ". IMPORT FAILED!"); sender.sendMessage("Another pack is using the key " + key + ". IMPORT FAILED!");
return; return;
@@ -9,6 +9,7 @@ import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.util.ArrayType; import com.volmit.iris.util.ArrayType;
import com.volmit.iris.util.Desc; import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate; import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.HeightMap;
import com.volmit.iris.util.KList; import com.volmit.iris.util.KList;
import com.volmit.iris.util.MaxNumber; import com.volmit.iris.util.MaxNumber;
import com.volmit.iris.util.MinNumber; import com.volmit.iris.util.MinNumber;
@@ -157,7 +158,12 @@ public class IrisDepositGenerator
}); });
} }
public void generate(ChunkData data, RNG rng, TopographicTerrainProvider g, int cx, int cz) public void generate(ChunkData data, RNG rng, TopographicTerrainProvider g, int cx, int cz, boolean safe)
{
generate(data, rng, g, cx, cz, safe, null);
}
public void generate(ChunkData data, RNG rng, TopographicTerrainProvider g, int cx, int cz, boolean safe, HeightMap he)
{ {
for(int l = 0; l < rng.i(getMinPerChunk(), getMaxPerChunk()); l++) for(int l = 0; l < rng.i(getMinPerChunk(), getMaxPerChunk()); l++)
{ {
@@ -174,7 +180,7 @@ public class IrisDepositGenerator
int x = rng.i(af, bf); int x = rng.i(af, bf);
int z = rng.i(af, bf); int z = rng.i(af, bf);
int height = (int) (Math.round(g.getCarvedWaterHeight((cx << 4) + x, (cz << 4) + z))) - 7; int height = (he != null ? he.getHeight((cx << 4) + x, (cz << 4) + z) : (int) (Math.round(g.getCarvedWaterHeight((cx << 4) + x, (cz << 4) + z)))) - 7;
if(height <= 0) if(height <= 0)
{ {
@@ -207,7 +213,10 @@ public class IrisDepositGenerator
continue; continue;
} }
boolean allow = false; boolean allow = !safe;
if(!allow)
{
BlockData b = data.getBlockData(nx, ny, nz); BlockData b = data.getBlockData(nx, ny, nz);
for(BlockData f : g.getDimension().getRockPalette().getBlockData()) for(BlockData f : g.getDimension().getRockPalette().getBlockData())
{ {
@@ -217,6 +226,7 @@ public class IrisDepositGenerator
break; break;
} }
} }
}
if(allow) if(allow)
{ {
@@ -50,6 +50,10 @@ public class IrisDimension extends IrisRegistrant
@Desc("The human readable name of this dimension") @Desc("The human readable name of this dimension")
private String name = "A Dimension"; private String name = "A Dimension";
@DontObfuscate
@Desc("Create an inverted dimension in the sky (like the nether)")
private IrisDimension sky = null;
@DontObfuscate @DontObfuscate
@Desc("Place text on terrain") @Desc("Place text on terrain")
@ArrayType(min = 1, type = IrisTextPlacement.class) @ArrayType(min = 1, type = IrisTextPlacement.class)
@@ -307,6 +311,7 @@ public class IrisDimension extends IrisRegistrant
@Desc("Define biome mutations for this dimension") @Desc("Define biome mutations for this dimension")
private KList<IrisBiomeMutation> mutations = new KList<>(); private KList<IrisBiomeMutation> mutations = new KList<>();
private transient boolean skyDimension = false;
private final transient AtomicCache<ChunkPosition> parallaxSize = new AtomicCache<>(); private final transient AtomicCache<ChunkPosition> parallaxSize = new AtomicCache<>();
private final transient AtomicCache<KList<IrisPostBlockFilter>> cacheFilters = new AtomicCache<>(); private final transient AtomicCache<KList<IrisPostBlockFilter>> cacheFilters = new AtomicCache<>();
private final transient AtomicCache<CNG> rockLayerGenerator = new AtomicCache<>(); private final transient AtomicCache<CNG> rockLayerGenerator = new AtomicCache<>();
@@ -316,6 +321,11 @@ public class IrisDimension extends IrisRegistrant
private final transient AtomicCache<Double> cosr = new AtomicCache<>(); private final transient AtomicCache<Double> cosr = new AtomicCache<>();
private final transient AtomicCache<Double> rad = new AtomicCache<>(); private final transient AtomicCache<Double> rad = new AtomicCache<>();
public boolean hasSky()
{
return getSky() != null;
}
public static KList<IrisCompatabilityFilter> getDefaultCompatability() public static KList<IrisCompatabilityFilter> getDefaultCompatability()
{ {
KList<IrisCompatabilityFilter> filters = new KList<>(); KList<IrisCompatabilityFilter> filters = new KList<>();
@@ -688,4 +688,15 @@ public class KList<T> extends ArrayList<T> implements List<T>
add(t); add(t);
} }
} }
public void addAllIfMissing(KList<T> t)
{
for(T i : t)
{
if(!contains(i))
{
add(i);
}
}
}
} }
@@ -80,8 +80,9 @@ public class ParallaxChunk implements Writable
public void injectUpdates(AtomicSliver sliver, int x, int z) public void injectUpdates(AtomicSliver sliver, int x, int z)
{ {
for(Integer i : sliver.getUpdatables()) for(Byte b : sliver.getUpdatables())
{ {
byte i = (byte) (b - Byte.MIN_VALUE);
if(i > 255 || i < 0) if(i > 255 || i < 0)
{ {
Iris.warn("Block Update out of bounds: " + i); Iris.warn("Block Update out of bounds: " + i);