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