Coord docs & fix serious parallax issue

This commit is contained in:
Daniel Mills 2021-07-20 02:59:38 -04:00
parent 0595008fce
commit b27b26837f

View File

@ -25,6 +25,8 @@ import com.volmit.iris.engine.object.tile.TileData;
import com.volmit.iris.engine.parallel.MultiBurst;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.documentation.RegionCoordinates;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.block.TileState;
@ -85,16 +87,19 @@ public class ParallaxWorld implements ParallaxAccess {
}
}
@RegionCoordinates
public boolean isLoaded(int x, int z) {
return loadedRegions.containsKey(key(x, z));
}
@RegionCoordinates
public void save(int x, int z) {
if (isLoaded(x, z)) {
save(getR(x, z));
}
}
@RegionCoordinates
public int unload(int x, int z) {
long key = key(x, z);
int v = 0;
@ -114,6 +119,7 @@ public class ParallaxWorld implements ParallaxAccess {
return v;
}
@RegionCoordinates
public ParallaxRegion load(int x, int z) {
if (isLoaded(x, z)) {
return loadedRegions.get(key(x, z));
@ -125,6 +131,7 @@ public class ParallaxWorld implements ParallaxAccess {
return v;
}
@RegionCoordinates
public ParallaxRegion getR(int x, int z) {
long key = key(x, z);
@ -137,70 +144,84 @@ public class ParallaxWorld implements ParallaxAccess {
return region;
}
@RegionCoordinates
public ParallaxRegion getRW(int x, int z) {
save.addIfMissing(key(x, z));
return getR(x, z);
}
@RegionCoordinates
private long key(int x, int z) {
return (((long) x) << 32) | (((long) z) & 0xffffffffL);
}
@ChunkCoordinates
@Override
public Hunk<BlockData> getBlocksR(int x, int z) {
return getR(x >> 5, z >> 5).getBlockSlice().getR(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public Hunk<BlockData> getBlocksRW(int x, int z) {
return getRW(x >> 5, z >> 5).getBlockSlice().getRW(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public Hunk<TileData<? extends TileState>> getTilesR(int x, int z) {
return getR(x >> 5, z >> 5).getTileSlice().getR(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public Hunk<TileData<? extends TileState>> getTilesRW(int x, int z) {
return getRW(x >> 5, z >> 5).getTileSlice().getRW(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public Hunk<String> getObjectsR(int x, int z) {
return getR(x >> 5, z >> 5).getObjectSlice().getR(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public Hunk<String> getObjectsRW(int x, int z) {
return getRW(x >> 5, z >> 5).getObjectSlice().getRW(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public Hunk<String> getEntitiesRW(int x, int z) {
return getRW(x >> 5, z >> 5).getEntitySlice().getRW(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public Hunk<String> getEntitiesR(int x, int z) {
return getRW(x >> 5, z >> 5).getEntitySlice().getR(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public Hunk<Boolean> getUpdatesR(int x, int z) {
return getR(x >> 5, z >> 5).getUpdateSlice().getR(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public Hunk<Boolean> getUpdatesRW(int x, int z) {
return getRW(x >> 5, z >> 5).getUpdateSlice().getRW(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public ParallaxChunkMeta getMetaR(int x, int z) {
return getR(x >> 5, z >> 5).getMetaR(x & 31, z & 31);
}
@ChunkCoordinates
@Override
public ParallaxChunkMeta getMetaRW(int x, int z) {
return getRW(x >> 5, z >> 5).getMetaRW(x & 31, z & 31);