mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Parallax support tile data
This commit is contained in:
parent
1d052231f0
commit
2a51454682
@ -1,6 +1,8 @@
|
||||
package com.volmit.iris.scaffold.parallax;
|
||||
|
||||
import com.volmit.iris.object.tile.TileData;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public interface ParallaxAccess {
|
||||
@ -12,6 +14,14 @@ public interface ParallaxAccess {
|
||||
getBlocksRW(x >> 4, z >> 4).set(x & 15, y, z & 15, d);
|
||||
}
|
||||
|
||||
default TileData<? extends TileState> getTile(int x, int y, int z) {
|
||||
return getTilesR(x >> 4, z >> 4).get(x & 15, y, z & 15);
|
||||
}
|
||||
|
||||
default void setTile(int x, int y, int z, TileData<? extends TileState> d) {
|
||||
getTilesRW(x >> 4, z >> 4).set(x & 15, y, z & 15, d);
|
||||
}
|
||||
|
||||
default String getObject(int x, int y, int z) {
|
||||
return getObjectsR(x >> 4, z >> 4).get(x & 15, y, z & 15);
|
||||
}
|
||||
@ -87,6 +97,10 @@ public interface ParallaxAccess {
|
||||
getMetaRW(x, z).setFeatureGenerated(v);
|
||||
}
|
||||
|
||||
public Hunk<TileData<? extends TileState>> getTilesR(int x, int z);
|
||||
|
||||
public Hunk<TileData<? extends TileState>> getTilesRW(int x, int z);
|
||||
|
||||
public Hunk<BlockData> getBlocksR(int x, int z);
|
||||
|
||||
public Hunk<BlockData> getBlocksRW(int x, int z);
|
||||
@ -119,6 +133,7 @@ public interface ParallaxAccess {
|
||||
{
|
||||
getUpdatesRW(x, z).fill(false);
|
||||
getBlocksRW(x, z).fill(null);
|
||||
getTilesRW(x, z).fill(null);
|
||||
getObjectsRW(x, z).fill(null);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.volmit.iris.scaffold.parallax;
|
||||
|
||||
import com.volmit.iris.object.tile.TileData;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.scaffold.hunk.io.HunkIOAdapter;
|
||||
import com.volmit.iris.scaffold.hunk.io.HunkRegion;
|
||||
@ -9,6 +10,7 @@ import com.volmit.iris.util.ByteArrayTag;
|
||||
import com.volmit.iris.util.CompoundTag;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.Tag;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.io.File;
|
||||
@ -20,6 +22,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
private Hunk<ParallaxChunkMeta> meta;
|
||||
private HunkIOAdapter<ParallaxChunkMeta> metaAdapter;
|
||||
private HunkRegionSlice<BlockData> blockSlice;
|
||||
private HunkRegionSlice<TileData<? extends TileState>> tileSlice;
|
||||
private HunkRegionSlice<String> objectSlice;
|
||||
private HunkRegionSlice<Boolean> updateSlice;
|
||||
private final GridLock lock;
|
||||
@ -45,6 +48,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
private void setupSlices()
|
||||
{
|
||||
blockSlice = HunkRegionSlice.BLOCKDATA.apply(height, getCompound());
|
||||
tileSlice = HunkRegionSlice.TILE.apply(height, getCompound());
|
||||
objectSlice = HunkRegionSlice.STRING.apply(height, getCompound(), "objects");
|
||||
updateSlice = HunkRegionSlice.BOOLEAN.apply(height, getCompound(), "updates");
|
||||
metaAdapter = ParallaxChunkMeta.adapter.apply(getCompound());
|
||||
@ -148,6 +152,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
{
|
||||
blockSlice.save();
|
||||
objectSlice.save();
|
||||
tileSlice.save();
|
||||
updateSlice.save();
|
||||
saveMetaHunk();
|
||||
super.save();
|
||||
@ -158,6 +163,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
unloadMetaHunk();
|
||||
return blockSlice.unloadAll()+
|
||||
objectSlice.unloadAll()+
|
||||
tileSlice.unloadAll()+
|
||||
updateSlice.unloadAll();
|
||||
}
|
||||
|
||||
@ -166,6 +172,11 @@ public class ParallaxRegion extends HunkRegion
|
||||
return blockSlice;
|
||||
}
|
||||
|
||||
public HunkRegionSlice<TileData<? extends TileState>> getTileSlice() {
|
||||
lastUse = M.ms();
|
||||
return tileSlice;
|
||||
}
|
||||
|
||||
public HunkRegionSlice<String> getObjectSlice() {
|
||||
lastUse = M.ms();
|
||||
return objectSlice;
|
||||
@ -179,10 +190,11 @@ public class ParallaxRegion extends HunkRegion
|
||||
public synchronized int cleanup(long c) {
|
||||
return blockSlice.cleanup(c) +
|
||||
objectSlice.cleanup(c) +
|
||||
tileSlice.cleanup(c) +
|
||||
updateSlice.cleanup(c);
|
||||
}
|
||||
|
||||
public int getChunkCount() {
|
||||
return blockSlice.getLoadCount() + objectSlice.getLoadCount() + updateSlice.getLoadCount();
|
||||
return blockSlice.getLoadCount() + objectSlice.getLoadCount() + tileSlice.getLoadCount() + updateSlice.getLoadCount();
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.volmit.iris.scaffold.parallax;
|
||||
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.object.tile.TileData;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.io.File;
|
||||
@ -161,6 +163,18 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
return getRW(x >> 5, z >> 5).getBlockSlice().getRW(x & 31, z & 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hunk<TileData<? extends TileState>> getTilesR(int x, int z)
|
||||
{
|
||||
return getR(x >> 5, z >> 5).getTileSlice().getR(x & 31, z & 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hunk<TileData<? extends TileState>> getTilesRW(int x, int z)
|
||||
{
|
||||
return getRW(x >> 5, z >> 5).getTileSlice().getRW(x & 31, z & 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hunk<String> getObjectsR(int x, int z)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user