mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Block Updates
This commit is contained in:
parent
ab89d6a22f
commit
7b94d753b8
@ -168,6 +168,7 @@ public class Iris extends MortarPlugin implements BoardProvider
|
||||
lines.add(ChatColor.GREEN + "Parallax Chunks" + ChatColor.GRAY + ": " + Form.f((int) g.getParallaxMap().getLoadedChunks().size()));
|
||||
lines.add(ChatColor.GREEN + "Objects" + ChatColor.GRAY + ": " + Form.f(g.getData().getObjectLoader().count()));
|
||||
lines.add(ChatColor.GREEN + "Memory" + ChatColor.GRAY + ": " + mem);
|
||||
lines.add(ChatColor.GREEN + "Heightmap" + ChatColor.GRAY + ": " + (int) g.getTerrainHeight(x, z));
|
||||
|
||||
if(er != null && b != null)
|
||||
{
|
||||
|
@ -164,14 +164,14 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
|
||||
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map)
|
||||
{
|
||||
if(getSliverCache().size() > 20000)
|
||||
{
|
||||
getSliverCache().clear();
|
||||
}
|
||||
|
||||
super.onPostGenerate(random, x, z, data, grid, height, biomeMap);
|
||||
super.onPostGenerate(random, x, z, data, grid, height, biomeMap, map);
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
|
||||
if(getDimension().isPlaceObjects())
|
||||
@ -185,7 +185,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
|
||||
p.end();
|
||||
getMetrics().getParallax().put(p.getMilliseconds());
|
||||
super.onPostParallaxPostGenerate(random, x, z, data, grid, height, biomeMap);
|
||||
super.onPostParallaxPostGenerate(random, x, z, data, grid, height, biomeMap, map);
|
||||
getParallaxMap().clean(ticks);
|
||||
getData().getObjectLoader().clean();
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public abstract class ParallelChunkGenerator extends DimensionChunkGenerator
|
||||
|
||||
protected abstract int onSampleColumnHeight(int cx, int cz, int wx, int wz, int x, int z);
|
||||
|
||||
protected abstract void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap);
|
||||
protected abstract void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map);
|
||||
|
||||
protected int sampleHeight(int x, int z)
|
||||
{
|
||||
@ -96,7 +96,7 @@ public abstract class ParallelChunkGenerator extends DimensionChunkGenerator
|
||||
map.write(data, grid, height);
|
||||
getMetrics().getTerrain().put(p.getMilliseconds());
|
||||
p = PrecisionStopwatch.start();
|
||||
onPostGenerate(random, x, z, data, grid, height, biomeMap);
|
||||
onPostGenerate(random, x, z, data, grid, height, biomeMap, map);
|
||||
}
|
||||
|
||||
protected void onClose()
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.atomics.AtomicSliver;
|
||||
import com.volmit.iris.gen.atomics.AtomicSliverMap;
|
||||
import com.volmit.iris.gen.layer.GenLayerBiome;
|
||||
import com.volmit.iris.gen.layer.GenLayerCarve;
|
||||
import com.volmit.iris.gen.layer.GenLayerCave;
|
||||
@ -88,7 +89,6 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
try
|
||||
{
|
||||
|
||||
int highestPlaced = 0;
|
||||
BlockData block;
|
||||
int fluidHeight = getDimension().getFluidHeight();
|
||||
double ox = getModifiedX(rx, rz);
|
||||
@ -198,7 +198,6 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
// Set block and update heightmaps
|
||||
sliver.set(k, block);
|
||||
highestPlaced = Math.max(highestPlaced, k);
|
||||
|
||||
// Decorate underwater surface
|
||||
if(!cavernSurface && (k == height && B.isSolid(block.getMaterial()) && k < fluidHeight))
|
||||
@ -479,17 +478,17 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
|
||||
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map)
|
||||
{
|
||||
onPreParallaxPostGenerate(random, x, z, data, grid, height, biomeMap);
|
||||
onPreParallaxPostGenerate(random, x, z, data, grid, height, biomeMap, map);
|
||||
}
|
||||
|
||||
protected void onPreParallaxPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
|
||||
protected void onPreParallaxPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected void onPostParallaxPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
|
||||
protected void onPostParallaxPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap, AtomicSliverMap map)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import com.volmit.iris.util.HeightMap;
|
||||
import com.volmit.iris.util.IrisLock;
|
||||
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 lombok.Data;
|
||||
@ -27,6 +28,7 @@ public class AtomicSliver
|
||||
private KMap<Integer, BlockData> block;
|
||||
private KMap<Integer, IrisBiome> truebiome;
|
||||
private KMap<Integer, Biome> biome;
|
||||
private KSet<Integer> update;
|
||||
private IrisLock lock = new IrisLock("Sliver");
|
||||
private int highestBlock = 0;
|
||||
private int highestBiome = 0;
|
||||
@ -40,6 +42,7 @@ public class AtomicSliver
|
||||
lock.setDisabled(true);
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
update = new KSet<>();
|
||||
this.block = new KMap<>();
|
||||
this.biome = new KMap<>();
|
||||
this.truebiome = new KMap<>();
|
||||
@ -50,6 +53,21 @@ public class AtomicSliver
|
||||
return get(h).getMaterial();
|
||||
}
|
||||
|
||||
public KSet<Integer> getUpdatables()
|
||||
{
|
||||
return update;
|
||||
}
|
||||
|
||||
public void update(int y)
|
||||
{
|
||||
update.add(y);
|
||||
}
|
||||
|
||||
public void dontUpdate(int y)
|
||||
{
|
||||
update.remove(y);
|
||||
}
|
||||
|
||||
public BlockData get(int h)
|
||||
{
|
||||
BlockData b = block.get(h);
|
||||
@ -65,21 +83,8 @@ public class AtomicSliver
|
||||
|
||||
public void set(int h, BlockData d)
|
||||
{
|
||||
if(d == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
block.put(h, d);
|
||||
lock.unlock();
|
||||
setSilently(h, d);
|
||||
modified = true;
|
||||
|
||||
if(d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(B.mat("CAVE_AIR")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
highestBlock = h > highestBlock ? h : highestBlock;
|
||||
lock.unlock();
|
||||
@ -95,6 +100,17 @@ public class AtomicSliver
|
||||
lock.lock();
|
||||
modified = true;
|
||||
block.put(h, d);
|
||||
|
||||
if(B.isLit(d))
|
||||
{
|
||||
update(h);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
dontUpdate(h);
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
@ -176,7 +192,9 @@ public class AtomicSliver
|
||||
this.block = new KMap<Integer, BlockData>();
|
||||
int h = din.readByte() - Byte.MIN_VALUE;
|
||||
int p = din.readByte() - Byte.MIN_VALUE;
|
||||
int u = din.readByte() - Byte.MIN_VALUE;
|
||||
KList<BlockData> palette = new KList<BlockData>();
|
||||
getUpdatables().clear();
|
||||
highestBlock = h;
|
||||
|
||||
for(int i = 0; i < p; i++)
|
||||
@ -188,6 +206,12 @@ public class AtomicSliver
|
||||
{
|
||||
block.put(i, palette.get(din.readByte() - Byte.MIN_VALUE).clone());
|
||||
}
|
||||
|
||||
for(int i = 0; i <= u; i++)
|
||||
{
|
||||
update(din.readByte() - Byte.MIN_VALUE);
|
||||
}
|
||||
|
||||
modified = false;
|
||||
lock.unlock();
|
||||
}
|
||||
@ -210,6 +234,7 @@ public class AtomicSliver
|
||||
}
|
||||
|
||||
dos.writeByte(palette.size() + Byte.MIN_VALUE);
|
||||
dos.writeByte(update.size() + Byte.MIN_VALUE);
|
||||
|
||||
for(String i : palette)
|
||||
{
|
||||
@ -223,6 +248,11 @@ public class AtomicSliver
|
||||
dos.writeByte(palette.indexOf(d) + Byte.MIN_VALUE);
|
||||
}
|
||||
|
||||
for(Integer i : getUpdatables())
|
||||
{
|
||||
dos.writeByte(i + Byte.MIN_VALUE);
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user