Supercarves

This commit is contained in:
Daniel Mills
2020-09-03 03:59:03 -04:00
parent 3663b9f957
commit 607a7be337
13 changed files with 274 additions and 99 deletions

View File

@@ -16,6 +16,8 @@ public class AtomicMulticache
private int hit = 0;
private int miss = 0;
private final KMap<Long, Double> height;
private final KMap<Long, Integer> carvedHeight;
private final KMap<Long, Integer> carvedHeightIgnoreWater;
private final KMap<Long, IrisBiome> biome;
private final KMap<Long, IrisBiome> rawBiome;
private final KMap<Long, IrisRegion> region;
@@ -25,6 +27,8 @@ public class AtomicMulticache
x = new AtomicInteger(0);
z = new AtomicInteger(0);
height = new KMap<Long, Double>();
carvedHeight = new KMap<Long, Integer>();
carvedHeightIgnoreWater = new KMap<Long, Integer>();
biome = new KMap<Long, IrisBiome>();
rawBiome = new KMap<Long, IrisBiome>();
region = new KMap<Long, IrisRegion>();
@@ -52,6 +56,16 @@ public class AtomicMulticache
height.clear();
}
if(carvedHeight.size() > getLimit())
{
carvedHeight.clear();
}
if(carvedHeightIgnoreWater.size() > getLimit())
{
carvedHeightIgnoreWater.clear();
}
if(biome.size() > getLimit())
{
biome.clear();
@@ -99,6 +113,56 @@ public class AtomicMulticache
return r;
}
public int getCarvedHeight(int x, int z, Supplier<Integer> g)
{
if(broken)
{
return -57841;
}
long pos = pos(x, z);
Integer r = carvedHeight.get(pos);
if(r == null)
{
miss++;
r = g.get();
carvedHeight.put(pos, r);
}
else
{
hit++;
}
return r;
}
public int getCarvedHeightIgnoreWater(int x, int z, Supplier<Integer> g)
{
if(broken)
{
return -57841;
}
long pos = pos(x, z);
Integer r = carvedHeightIgnoreWater.get(pos);
if(r == null)
{
miss++;
r = g.get();
carvedHeightIgnoreWater.put(pos, r);
}
else
{
hit++;
}
return r;
}
public IrisRegion getRegion(int x, int z, Supplier<IrisRegion> g)
{
long pos = pos(x, z);

View File

@@ -370,6 +370,11 @@ public class AtomicSliver
BlockData b = block.get(i);
if(b != null)
{
if(b.getMaterial().equals(Material.AIR))
{
continue;
}
currentData.setBlock(x, i, z, b);
}
}