mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-13 19:26:26 +00:00
Fixes
This commit is contained in:
@@ -26,8 +26,6 @@ import java.util.Arrays;
|
||||
public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootProvider, BlockUpdater, Renderer, Hotloadable {
|
||||
public void close();
|
||||
|
||||
public int getCurrentlyGenerating();
|
||||
|
||||
public boolean isClosed();
|
||||
|
||||
public EngineWorldManager getWorldManager();
|
||||
@@ -42,6 +40,8 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
|
||||
public void setMinHeight(int min);
|
||||
|
||||
public void recycle();
|
||||
|
||||
public int getIndex();
|
||||
|
||||
public int getMinHeight();
|
||||
@@ -56,7 +56,7 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
|
||||
default void save()
|
||||
{
|
||||
getParallax().saveAll();
|
||||
getParallax().saveAll();
|
||||
}
|
||||
|
||||
default void saveNow()
|
||||
|
||||
@@ -784,6 +784,11 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
|
||||
@Override
|
||||
public boolean isFailing() {
|
||||
if(getComposite() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return getComposite().isFailing();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ public interface EngineCompound extends Listener, Hotloadable, DataProvider
|
||||
|
||||
public World getWorld();
|
||||
|
||||
public int getCurrentlyGeneratingEngines();
|
||||
|
||||
public void printMetrics(CommandSender sender);
|
||||
|
||||
public int getSize();
|
||||
@@ -67,6 +65,14 @@ public interface EngineCompound extends Listener, Hotloadable, DataProvider
|
||||
return getEngine(getSize() - 1);
|
||||
}
|
||||
|
||||
public default void recycle()
|
||||
{
|
||||
for(int i = 0; i < getSize(); i++)
|
||||
{
|
||||
getEngine(i).recycle();
|
||||
}
|
||||
}
|
||||
|
||||
public default void save()
|
||||
{
|
||||
saveEngineMetadata();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class HunkRegionSlice<T>
|
||||
this.lastUse = new KMap<>();
|
||||
}
|
||||
|
||||
public int cleanup(long t)
|
||||
public int cleanup(long t)
|
||||
{
|
||||
int v = 0;
|
||||
if(loadedChunks.size() != lastUse.size())
|
||||
@@ -64,21 +64,18 @@ public class HunkRegionSlice<T>
|
||||
return v;
|
||||
}
|
||||
|
||||
public void clear()
|
||||
public void clear()
|
||||
{
|
||||
synchronized(save)
|
||||
for(String i : new KList<>(compound.getValue().keySet()))
|
||||
{
|
||||
for(String i : new KList<>(compound.getValue().keySet()))
|
||||
if(i.startsWith(key + "."))
|
||||
{
|
||||
if(i.startsWith(key + "."))
|
||||
{
|
||||
compound.getValue().remove(i);
|
||||
}
|
||||
compound.getValue().remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
public void save()
|
||||
{
|
||||
BurstExecutor e = MultiBurst.burst.burst();
|
||||
for(ChunkPosition i : save.copy())
|
||||
@@ -104,17 +101,17 @@ public class HunkRegionSlice<T>
|
||||
e.complete();
|
||||
}
|
||||
|
||||
public boolean contains(int x, int z)
|
||||
public boolean contains(int x, int z)
|
||||
{
|
||||
return compound.getValue().containsKey(key(x, z));
|
||||
}
|
||||
|
||||
public void delete(int x, int z)
|
||||
public void delete(int x, int z)
|
||||
{
|
||||
compound.getValue().remove(key(x, z));
|
||||
}
|
||||
|
||||
public Hunk<T> read(int x, int z) throws IOException
|
||||
public Hunk<T> read(int x, int z) throws IOException
|
||||
{
|
||||
Tag t = compound.getValue().get(key(x, z));
|
||||
|
||||
@@ -127,12 +124,12 @@ public class HunkRegionSlice<T>
|
||||
return adapter.read(factory, (ByteArrayTag) t);
|
||||
}
|
||||
|
||||
public void write(Hunk<T> hunk, int x, int z) throws IOException
|
||||
public void write(Hunk<T> hunk, int x, int z) throws IOException
|
||||
{
|
||||
compound.getValue().put(key(x, z), hunk.writeByteArrayTag(adapter, key(x, z)));
|
||||
}
|
||||
|
||||
public synchronized int unloadAll()
|
||||
public int unloadAll()
|
||||
{
|
||||
int v = 0;
|
||||
for(ChunkPosition i : loadedChunks.k())
|
||||
@@ -147,7 +144,7 @@ public class HunkRegionSlice<T>
|
||||
return v;
|
||||
}
|
||||
|
||||
public synchronized void save(Hunk<T> region, int x, int z)
|
||||
public void save(Hunk<T> region, int x, int z)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -159,12 +156,12 @@ public class HunkRegionSlice<T>
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLoaded(int x, int z)
|
||||
public boolean isLoaded(int x, int z)
|
||||
{
|
||||
return loadedChunks.containsKey(new ChunkPosition(x, z));
|
||||
}
|
||||
|
||||
public synchronized void save(int x, int z)
|
||||
public void save(int x, int z)
|
||||
{
|
||||
if(isLoaded(x, z))
|
||||
{
|
||||
@@ -172,7 +169,7 @@ public class HunkRegionSlice<T>
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void unload(int x, int z)
|
||||
public void unload(int x, int z)
|
||||
{
|
||||
ChunkPosition key = new ChunkPosition(x, z);
|
||||
if(isLoaded(x, z))
|
||||
@@ -188,7 +185,7 @@ public class HunkRegionSlice<T>
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Hunk<T> load(int x, int z)
|
||||
public Hunk<T> load(int x, int z)
|
||||
{
|
||||
if(isLoaded(x, z))
|
||||
{
|
||||
@@ -220,7 +217,7 @@ public class HunkRegionSlice<T>
|
||||
return v;
|
||||
}
|
||||
|
||||
public Hunk<T> get(int x, int z)
|
||||
public Hunk<T> get(int x, int z)
|
||||
{
|
||||
ChunkPosition key = new ChunkPosition(x, z);
|
||||
|
||||
@@ -236,12 +233,12 @@ public class HunkRegionSlice<T>
|
||||
return c;
|
||||
}
|
||||
|
||||
public Hunk<T> getR(int x, int z)
|
||||
public Hunk<T> getR(int x, int z)
|
||||
{
|
||||
return get(x, z).readOnly();
|
||||
}
|
||||
|
||||
public Hunk<T> getRW(int x, int z)
|
||||
public Hunk<T> getRW(int x, int z)
|
||||
{
|
||||
save.addIfMissing(new ChunkPosition(x, z));
|
||||
return get(x, z);
|
||||
@@ -257,7 +254,7 @@ public class HunkRegionSlice<T>
|
||||
return key + "." + x + "." + z;
|
||||
}
|
||||
|
||||
public int getLoadCount()
|
||||
public int getLoadCount()
|
||||
{
|
||||
return loadedChunks.size();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ public class ParallaxChunkMeta {
|
||||
dos.writeByte(parallaxChunkMeta.getMinObject() + Byte.MIN_VALUE);
|
||||
dos.writeByte(parallaxChunkMeta.getMaxObject() + Byte.MIN_VALUE);
|
||||
}
|
||||
|
||||
dos.writeInt(parallaxChunkMeta.count);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,7 +39,7 @@ public class ParallaxChunkMeta {
|
||||
boolean o = din.readBoolean();
|
||||
int min = o ? din.readByte() - Byte.MIN_VALUE : -1;
|
||||
int max = o ? din.readByte() - Byte.MIN_VALUE : -1;
|
||||
return new ParallaxChunkMeta(bb, g, p, o, min, max);
|
||||
return new ParallaxChunkMeta(bb, g, p, o, min, max, din.readInt());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -47,9 +49,10 @@ public class ParallaxChunkMeta {
|
||||
private boolean objects;
|
||||
private int maxObject = -1;
|
||||
private int minObject = -1;
|
||||
private int count;
|
||||
|
||||
public ParallaxChunkMeta()
|
||||
{
|
||||
this(false, false, false, false, -1, -1);
|
||||
this(false, false, false, false, -1, -1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,17 +49,17 @@ public class ParallaxRegion extends HunkRegion
|
||||
lastUse = M.ms();
|
||||
}
|
||||
|
||||
public boolean hasBeenIdleLongerThan(long time)
|
||||
public boolean hasBeenIdleLongerThan(long time)
|
||||
{
|
||||
return M.ms() - lastUse > time;
|
||||
}
|
||||
|
||||
public ParallaxChunkMeta getMetaR(int x, int z)
|
||||
public ParallaxChunkMeta getMetaR(int x, int z)
|
||||
{
|
||||
return getMetaHunkR().getOr(x, 0, z, new ParallaxChunkMeta());
|
||||
}
|
||||
|
||||
public ParallaxChunkMeta getMetaRW(int x, int z)
|
||||
public ParallaxChunkMeta getMetaRW(int x, int z)
|
||||
{
|
||||
lastUse = M.ms();
|
||||
dirtyMeta = true;
|
||||
@@ -73,7 +73,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
return p;
|
||||
}
|
||||
|
||||
private Hunk<ParallaxChunkMeta> getMetaHunkR()
|
||||
private Hunk<ParallaxChunkMeta> getMetaHunkR()
|
||||
{
|
||||
if(meta == null)
|
||||
{
|
||||
@@ -83,13 +83,13 @@ public class ParallaxRegion extends HunkRegion
|
||||
return meta;
|
||||
}
|
||||
|
||||
private Hunk<ParallaxChunkMeta> getMetaHunkRW()
|
||||
private Hunk<ParallaxChunkMeta> getMetaHunkRW()
|
||||
{
|
||||
dirtyMeta = true;
|
||||
return getMetaHunkR();
|
||||
}
|
||||
|
||||
public Hunk<ParallaxChunkMeta> loadMetaHunk()
|
||||
public Hunk<ParallaxChunkMeta> loadMetaHunk()
|
||||
{
|
||||
lastUse = M.ms();
|
||||
if(meta == null)
|
||||
@@ -114,7 +114,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void unloadMetaHunk()
|
||||
public void unloadMetaHunk()
|
||||
{
|
||||
if(dirtyMeta)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
meta = null;
|
||||
}
|
||||
|
||||
public void saveMetaHunk()
|
||||
public void saveMetaHunk()
|
||||
{
|
||||
if(meta != null && dirtyMeta)
|
||||
{
|
||||
@@ -138,7 +138,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
}
|
||||
}
|
||||
|
||||
public void save() throws IOException
|
||||
public void save() throws IOException
|
||||
{
|
||||
blockSlice.save();
|
||||
objectSlice.save();
|
||||
@@ -147,7 +147,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
super.save();
|
||||
}
|
||||
|
||||
public int unload()
|
||||
public int unload()
|
||||
{
|
||||
unloadMetaHunk();
|
||||
return blockSlice.unloadAll()+
|
||||
@@ -155,28 +155,28 @@ public class ParallaxRegion extends HunkRegion
|
||||
updateSlice.unloadAll();
|
||||
}
|
||||
|
||||
public HunkRegionSlice<BlockData> getBlockSlice() {
|
||||
public HunkRegionSlice<BlockData> getBlockSlice() {
|
||||
lastUse = M.ms();
|
||||
return blockSlice;
|
||||
}
|
||||
|
||||
public HunkRegionSlice<String> getObjectSlice() {
|
||||
public HunkRegionSlice<String> getObjectSlice() {
|
||||
lastUse = M.ms();
|
||||
return objectSlice;
|
||||
}
|
||||
|
||||
public HunkRegionSlice<Boolean> getUpdateSlice() {
|
||||
public HunkRegionSlice<Boolean> getUpdateSlice() {
|
||||
lastUse = M.ms();
|
||||
return updateSlice;
|
||||
}
|
||||
|
||||
public int cleanup(long c) {
|
||||
public int cleanup(long c) {
|
||||
return blockSlice.cleanup(c) +
|
||||
objectSlice.cleanup(c) +
|
||||
updateSlice.cleanup(c);
|
||||
}
|
||||
|
||||
public int getChunkCount() {
|
||||
public int getChunkCount() {
|
||||
return blockSlice.getLoadCount() + objectSlice.getLoadCount() + updateSlice.getLoadCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.volmit.iris.scaffold.parallax;
|
||||
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KMap;
|
||||
@@ -17,7 +16,6 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
private final KList<Long> save;
|
||||
private final File folder;
|
||||
private final int height;
|
||||
private final ChronoLatch cleanup;
|
||||
|
||||
public ParallaxWorld(int height, File folder)
|
||||
{
|
||||
@@ -25,16 +23,15 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
this.folder = folder;
|
||||
save = new KList<>();
|
||||
loadedRegions = new KMap<>();
|
||||
cleanup = new ChronoLatch(5000);
|
||||
folder.mkdirs();
|
||||
}
|
||||
|
||||
public int getRegionCount()
|
||||
public int getRegionCount()
|
||||
{
|
||||
return loadedRegions.size();
|
||||
}
|
||||
|
||||
public int getChunkCount()
|
||||
public int getChunkCount()
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
@@ -54,7 +51,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
return m;
|
||||
}
|
||||
|
||||
public void close()
|
||||
public void close()
|
||||
{
|
||||
for(ParallaxRegion i : loadedRegions.v())
|
||||
{
|
||||
@@ -65,7 +62,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
loadedRegions.clear();
|
||||
}
|
||||
|
||||
public void save(ParallaxRegion region)
|
||||
public void save(ParallaxRegion region)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -78,12 +75,12 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLoaded(int x, int z)
|
||||
public boolean isLoaded(int x, int z)
|
||||
{
|
||||
return loadedRegions.containsKey(key(x, z));
|
||||
}
|
||||
|
||||
public void save(int x, int z)
|
||||
public void save(int x, int z)
|
||||
{
|
||||
if(isLoaded(x, z))
|
||||
{
|
||||
@@ -91,7 +88,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
}
|
||||
}
|
||||
|
||||
public int unload(int x, int z)
|
||||
public int unload(int x, int z)
|
||||
{
|
||||
long key = key(x, z);
|
||||
int v = 0;
|
||||
@@ -114,7 +111,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
return v;
|
||||
}
|
||||
|
||||
public ParallaxRegion load(int x, int z)
|
||||
public ParallaxRegion load(int x, int z)
|
||||
{
|
||||
if(isLoaded(x, z))
|
||||
{
|
||||
@@ -124,15 +121,10 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
ParallaxRegion v = new ParallaxRegion(height, folder, x, z);
|
||||
loadedRegions.put(key(x, z), v);
|
||||
|
||||
if(cleanup.flip())
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public ParallaxRegion getR(int x, int z)
|
||||
public ParallaxRegion getR(int x, int z)
|
||||
{
|
||||
long key = key(x, z);
|
||||
|
||||
@@ -146,7 +138,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
return region;
|
||||
}
|
||||
|
||||
public ParallaxRegion getRW(int x, int z)
|
||||
public ParallaxRegion getRW(int x, int z)
|
||||
{
|
||||
save.addIfMissing(key(x, z));
|
||||
return getR(x, z);
|
||||
@@ -158,60 +150,60 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hunk<BlockData> getBlocksR(int x, int z)
|
||||
public Hunk<BlockData> getBlocksR(int x, int z)
|
||||
{
|
||||
return getR(x >> 5, z >> 5).getBlockSlice().getR(x & 31, z & 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hunk<BlockData> getBlocksRW(int x, int z)
|
||||
public Hunk<BlockData> getBlocksRW(int x, int z)
|
||||
{
|
||||
return getRW(x >> 5, z >> 5).getBlockSlice().getRW(x & 31, z & 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hunk<String> getObjectsR(int x, int z)
|
||||
public Hunk<String> getObjectsR(int x, int z)
|
||||
{
|
||||
return getR(x >> 5, z >> 5).getObjectSlice().getR(x & 31, z & 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hunk<String> getObjectsRW(int x, int z)
|
||||
public Hunk<String> getObjectsRW(int x, int z)
|
||||
{
|
||||
return getRW(x >> 5, z >> 5).getObjectSlice().getRW(x & 31, z & 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hunk<Boolean> getUpdatesR(int x, int z)
|
||||
public Hunk<Boolean> getUpdatesR(int x, int z)
|
||||
{
|
||||
return getR(x >> 5, z >> 5).getUpdateSlice().getR(x & 31, z & 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hunk<Boolean> getUpdatesRW(int x, int z)
|
||||
public Hunk<Boolean> getUpdatesRW(int x, int z)
|
||||
{
|
||||
return getRW(x >> 5, z >> 5).getUpdateSlice().getRW(x & 31, z & 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParallaxChunkMeta getMetaR(int x, int z)
|
||||
public ParallaxChunkMeta getMetaR(int x, int z)
|
||||
{
|
||||
return getR(x >> 5, z >> 5).getMetaR(x & 31, z & 31);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParallaxChunkMeta getMetaRW(int x, int z)
|
||||
public ParallaxChunkMeta getMetaRW(int x, int z)
|
||||
{
|
||||
return getRW(x >> 5, z >> 5).getMetaRW(x & 31, z & 31);
|
||||
}
|
||||
|
||||
public void cleanup()
|
||||
public void cleanup()
|
||||
{
|
||||
cleanup(IrisSettings.get().getParallaxRegionEvictionMS(), IrisSettings.get().getParallaxChunkEvictionMS());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup(long r, long c) {
|
||||
public void cleanup(long r, long c) {
|
||||
J.a(() -> {
|
||||
try
|
||||
{
|
||||
@@ -241,12 +233,12 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAll() {
|
||||
public void saveAll() {
|
||||
J.a(this::saveAllNOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAllNOW() {
|
||||
public void saveAllNOW() {
|
||||
for(ParallaxRegion i : loadedRegions.v())
|
||||
{
|
||||
if(save.contains(key(i.getX(), i.getZ())))
|
||||
|
||||
Reference in New Issue
Block a user