mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-09 17:26:22 +00:00
Parallax 2
This commit is contained in:
@@ -25,24 +25,24 @@ import lombok.Data;
|
||||
public class AtomicSliver
|
||||
{
|
||||
public static final BlockData AIR = B.getBlockData("AIR");
|
||||
private transient KMap<Integer, IrisBiome> truebiome;
|
||||
private transient KMap<Integer, Biome> biome;
|
||||
private transient IrisLock lock = new IrisLock("Sliver");
|
||||
private transient int highestBiome = 0;
|
||||
private transient long last = M.ms();
|
||||
private transient int x;
|
||||
private transient int z;
|
||||
private transient boolean modified = false;
|
||||
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 KSet<Integer> blockUpdates;
|
||||
private int highestBlock = 0;
|
||||
private int highestBiome = 0;
|
||||
private long last = M.ms();
|
||||
private int x;
|
||||
private int z;
|
||||
boolean modified = false;
|
||||
|
||||
public AtomicSliver(int x, int z)
|
||||
{
|
||||
lock.setDisabled(true);
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
update = new KSet<>();
|
||||
blockUpdates = new KSet<>();
|
||||
this.block = new KMap<>();
|
||||
this.biome = new KMap<>();
|
||||
this.truebiome = new KMap<>();
|
||||
@@ -55,17 +55,17 @@ public class AtomicSliver
|
||||
|
||||
public KSet<Integer> getUpdatables()
|
||||
{
|
||||
return update;
|
||||
return blockUpdates;
|
||||
}
|
||||
|
||||
public void update(int y)
|
||||
{
|
||||
update.add(y);
|
||||
blockUpdates.add(y);
|
||||
}
|
||||
|
||||
public void dontUpdate(int y)
|
||||
{
|
||||
update.remove(y);
|
||||
blockUpdates.remove(y);
|
||||
}
|
||||
|
||||
public BlockData get(int h)
|
||||
@@ -81,6 +81,19 @@ public class AtomicSliver
|
||||
return b;
|
||||
}
|
||||
|
||||
public BlockData getOrNull(int h)
|
||||
{
|
||||
BlockData b = block.get(h);
|
||||
last = M.ms();
|
||||
|
||||
if(b.getMaterial().equals(Material.AIR))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
public void set(int h, BlockData d)
|
||||
{
|
||||
setSilently(h, d);
|
||||
@@ -190,6 +203,8 @@ public class AtomicSliver
|
||||
{
|
||||
lock.lock();
|
||||
this.block = new KMap<Integer, BlockData>();
|
||||
|
||||
// Block Palette
|
||||
int h = din.readByte() - Byte.MIN_VALUE;
|
||||
int p = din.readByte() - Byte.MIN_VALUE;
|
||||
int u = din.readByte() - Byte.MIN_VALUE;
|
||||
@@ -202,11 +217,13 @@ public class AtomicSliver
|
||||
palette.add(B.getBlockData(din.readUTF()));
|
||||
}
|
||||
|
||||
// Blocks
|
||||
for(int i = 0; i <= h; i++)
|
||||
{
|
||||
block.put(i, palette.get(din.readByte() - Byte.MIN_VALUE).clone());
|
||||
}
|
||||
|
||||
// Updates
|
||||
for(int i = 0; i <= u; i++)
|
||||
{
|
||||
update(din.readByte() - Byte.MIN_VALUE);
|
||||
@@ -220,6 +237,8 @@ public class AtomicSliver
|
||||
{
|
||||
lock.lock();
|
||||
dos.writeByte(highestBlock + Byte.MIN_VALUE);
|
||||
|
||||
// Block Palette
|
||||
KList<String> palette = new KList<>();
|
||||
|
||||
for(int i = 0; i <= highestBlock; i++)
|
||||
@@ -234,13 +253,14 @@ public class AtomicSliver
|
||||
}
|
||||
|
||||
dos.writeByte(palette.size() + Byte.MIN_VALUE);
|
||||
dos.writeByte(update.size() + Byte.MIN_VALUE);
|
||||
dos.writeByte(blockUpdates.size() + Byte.MIN_VALUE);
|
||||
|
||||
for(String i : palette)
|
||||
{
|
||||
dos.writeUTF(i);
|
||||
}
|
||||
|
||||
// Blocks
|
||||
for(int i = 0; i <= highestBlock; i++)
|
||||
{
|
||||
BlockData dat = block.get(i);
|
||||
@@ -248,6 +268,7 @@ public class AtomicSliver
|
||||
dos.writeByte(palette.indexOf(d) + Byte.MIN_VALUE);
|
||||
}
|
||||
|
||||
// Updates
|
||||
for(Integer i : getUpdatables())
|
||||
{
|
||||
dos.writeByte(i + Byte.MIN_VALUE);
|
||||
@@ -296,6 +317,6 @@ public class AtomicSliver
|
||||
|
||||
public void inject(KSet<Integer> updatables)
|
||||
{
|
||||
update.addAll(updatables);
|
||||
blockUpdates.addAll(updatables);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,13 @@ import java.io.OutputStream;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
|
||||
import com.volmit.iris.gen.DimensionChunkGenerator;
|
||||
import com.volmit.iris.object.IrisStructure;
|
||||
import com.volmit.iris.object.IrisStructureTile;
|
||||
import com.volmit.iris.util.HeightMap;
|
||||
import com.volmit.iris.util.IrisStructureResult;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KMap;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -17,11 +23,13 @@ import lombok.Data;
|
||||
public class AtomicSliverMap
|
||||
{
|
||||
private final AtomicSliver[] slivers;
|
||||
private KMap<Integer, String> structures;
|
||||
private boolean parallaxGenerated;
|
||||
private boolean worldGenerated;
|
||||
|
||||
public AtomicSliverMap()
|
||||
{
|
||||
structures = new KMap<>();
|
||||
parallaxGenerated = false;
|
||||
worldGenerated = false;
|
||||
slivers = new AtomicSliver[256];
|
||||
@@ -43,6 +51,32 @@ public class AtomicSliverMap
|
||||
}
|
||||
}
|
||||
|
||||
public void setStructure(int y, IrisStructure s, IrisStructureTile t)
|
||||
{
|
||||
structures.put(y, s.getLoadKey() + "." + s.getTiles().indexOf(t));
|
||||
}
|
||||
|
||||
public IrisStructureResult getStructure(DimensionChunkGenerator g, int y)
|
||||
{
|
||||
String v = structures.get(y);
|
||||
|
||||
if(v == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] a = v.split("\\Q.\\E");
|
||||
|
||||
IrisStructure s = g.getData().getStructureLoader().load(a[0]);
|
||||
|
||||
if(s == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new IrisStructureResult(s.getTiles().get(Integer.valueOf(a[1])), s);
|
||||
}
|
||||
|
||||
public void write(OutputStream out) throws IOException
|
||||
{
|
||||
DataOutputStream dos = new DataOutputStream(out);
|
||||
@@ -53,6 +87,33 @@ public class AtomicSliverMap
|
||||
slivers[i].write(dos);
|
||||
}
|
||||
|
||||
KList<String> structurePalette = new KList<>();
|
||||
|
||||
for(Integer i : structures.k())
|
||||
{
|
||||
String struct = structures.get(i);
|
||||
|
||||
if(!structurePalette.contains(struct))
|
||||
{
|
||||
structurePalette.add(struct);
|
||||
}
|
||||
}
|
||||
|
||||
dos.writeByte(structurePalette.size() + Byte.MIN_VALUE);
|
||||
|
||||
for(String i : structurePalette)
|
||||
{
|
||||
dos.writeUTF(i);
|
||||
}
|
||||
|
||||
dos.writeByte(structures.size() + Byte.MIN_VALUE);
|
||||
|
||||
for(Integer i : structures.k())
|
||||
{
|
||||
dos.writeByte(i + Byte.MIN_VALUE);
|
||||
dos.writeByte(structurePalette.indexOf(structures.get(i)) + Byte.MIN_VALUE);
|
||||
}
|
||||
|
||||
dos.flush();
|
||||
}
|
||||
|
||||
@@ -74,6 +135,21 @@ public class AtomicSliverMap
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int spc = din.readByte() - Byte.MIN_VALUE;
|
||||
KList<String> spal = new KList<>();
|
||||
for(int i = 0; i < spc; i++)
|
||||
{
|
||||
spal.add(din.readUTF());
|
||||
}
|
||||
|
||||
int smc = din.readByte() - Byte.MIN_VALUE;
|
||||
structures.clear();
|
||||
|
||||
for(int i = 0; i < smc; i++)
|
||||
{
|
||||
structures.put(din.readByte() - Byte.MIN_VALUE, spal.get(din.readByte() - Byte.MIN_VALUE));
|
||||
}
|
||||
}
|
||||
|
||||
public AtomicSliver getSliver(int x, int z)
|
||||
@@ -122,7 +198,7 @@ public class AtomicSliverMap
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
getSliver(i, j).inject(map.getSliver(i, j).getUpdatables());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user