mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Fixes
This commit is contained in:
parent
8dd858e813
commit
a921845ae3
@ -16,7 +16,6 @@ import org.bukkit.generator.BlockPopulator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
public class IrisEngine extends BlockPopulator implements Engine
|
||||
{
|
||||
@ -48,19 +47,15 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
@Setter
|
||||
@Getter
|
||||
private volatile int minHeight;
|
||||
private int permits;
|
||||
private boolean failing;
|
||||
private boolean closed;
|
||||
private int cacheId;
|
||||
private Semaphore s;
|
||||
private int art;
|
||||
private final int art;
|
||||
|
||||
public IrisEngine(EngineTarget target, EngineCompound compound, int index)
|
||||
{
|
||||
Iris.info("Initializing Engine: " + target.getWorld().getName() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
|
||||
metrics = new EngineMetrics(32);
|
||||
permits = 10000;
|
||||
this.s = new Semaphore(permits);
|
||||
this.target = target;
|
||||
this.framework = new IrisEngineFramework(this);
|
||||
worldManager = new IrisWorldManager(this);
|
||||
@ -84,13 +79,13 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentlyGenerating() {
|
||||
return permits - s.availablePermits();
|
||||
public boolean isClosed() {
|
||||
return closed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return closed;
|
||||
public void recycle() {
|
||||
getFramework().recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,7 +103,6 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
try
|
||||
{
|
||||
boolean structures = postblocks != null;
|
||||
s.acquire(1);
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Hunk<BlockData> blocks = vblocks.synchronize().listen((xx,y,zz,t) -> catchBlockUpdates(x+xx,y+getMinHeight(),z+zz, t));
|
||||
Hunk<BlockData> pblocks = structures ? postblocks.synchronize().listen((xx,y,zz,t) -> catchBlockUpdates(x+xx,y+getMinHeight(),z+zz, t)) : null;
|
||||
@ -120,11 +114,9 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
getFramework().getRavineModifier().modify(x, z, blocks);
|
||||
getFramework().getPostModifier().modify(x, z, blocks);
|
||||
getFramework().getDecorantActuator().actuate(x, z, structures ? fringe : blocks);
|
||||
getFramework().getEngineParallax().insertParallax(x, z, structures ? fringe : blocks);
|
||||
getFramework().getEngineParallax().insertParallax(x, z, blocks);
|
||||
getFramework().getDepositModifier().modify(x, z, blocks);
|
||||
getMetrics().getTotal().put(p.getMilliseconds());
|
||||
s.release(1);
|
||||
getFramework().recycle();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
|
@ -210,6 +210,7 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
@Override
|
||||
public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<BlockData> postblocks, Hunk<Biome> biomes)
|
||||
{
|
||||
recycle();
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
if(engines.length == 1 && !getEngine(0).getTarget().isInverted())
|
||||
{
|
||||
@ -272,17 +273,6 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
wallClock.put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentlyGeneratingEngines() {
|
||||
int v = 0;
|
||||
for(Engine i : engines)
|
||||
{
|
||||
v+= i.getCurrentlyGenerating();
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return engines.length;
|
||||
|
@ -12,6 +12,9 @@ public class CommandIrisStudio extends MortarCommand
|
||||
@Command
|
||||
private CommandIrisStudioCreate create;
|
||||
|
||||
@Command
|
||||
private CommandIrisStudioFix fix;
|
||||
|
||||
@Command
|
||||
private CommandIrisStudioOpen open;
|
||||
|
||||
|
@ -0,0 +1,65 @@
|
||||
package com.volmit.iris.manager.command;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class CommandIrisStudioFix extends MortarCommand
|
||||
{
|
||||
public CommandIrisStudioFix()
|
||||
{
|
||||
super("fix");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Go to the spawn of the currently open studio world.");
|
||||
setCategory("Studio");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!Iris.proj.isProjectOpen())
|
||||
{
|
||||
sender.sendMessage("There is not a studio currently loaded.");
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Chunk c = sender.player().getLocation().getChunk();
|
||||
int cx = c.getX() * 16;
|
||||
int cz = c.getZ() * 16;
|
||||
Hunk<BlockData> bd = Hunk.viewBlocks(c);
|
||||
Iris.proj.getActiveProject().getActiveProvider().getCompound().getDefaultEngine().getFramework().getEngineParallax().insertParallax(cx, cz, bd);
|
||||
sender.sendMessage("Done!");
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
sender.sendMessage("Failed to teleport to the studio world. Try re-opening the project.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
package com.volmit.iris.manager.edit;
|
||||
|
||||
import com.volmit.iris.util.*;
|
||||
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
|
||||
import com.volmit.iris.scaffold.IrisWorlds;
|
||||
import com.volmit.iris.scaffold.engine.IrisAccess;
|
||||
import com.volmit.iris.scaffold.parallax.ParallaxAccess;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.Data;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -18,10 +19,11 @@ public class DustRevealer {
|
||||
public static void spawn(Block block, MortarSender sender)
|
||||
{
|
||||
World world = block.getWorld();
|
||||
IrisAccess access = IrisWorlds.access(world);
|
||||
|
||||
if(world.getGenerator() instanceof EngineCompositeGenerator)
|
||||
if(access != null)
|
||||
{
|
||||
ParallaxAccess a = ((EngineCompositeGenerator)world.getGenerator()).getComposite().getEngineForHeight(block.getY()).getParallax();
|
||||
ParallaxAccess a = access.getEngineAccess(block.getY()).getParallaxAccess();
|
||||
|
||||
if(a.getObject(block.getX(), block.getY(), block.getZ()) != null)
|
||||
{
|
||||
@ -43,32 +45,39 @@ public class DustRevealer {
|
||||
J.s(() -> {
|
||||
new BlockSignal(world.getBlockAt(block.getX(), block.getY(), block.getZ()), 100);
|
||||
J.a(() -> {
|
||||
is(new BlockPosition(block.getX() + 1, block.getY(), block.getZ()));
|
||||
is(new BlockPosition(block.getX() - 1, block.getY(), block.getZ()));
|
||||
is(new BlockPosition(block.getX(), block.getY() + 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX(), block.getY() - 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX(), block.getY(), block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX(), block.getY(), block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX() + 1, block.getY(), block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX() + 1, block.getY(), block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX() - 1, block.getY(), block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX() - 1, block.getY(), block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX() + 1, block.getY() + 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX() + 1, block.getY() - 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX() - 1, block.getY() + 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX() - 1, block.getY() - 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX(), block.getY() + 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX(), block.getY() + 1, block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX(), block.getY() - 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX(), block.getY() - 1, block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX()-1, block.getY() + 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX()-1, block.getY() + 1, block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX()-1, block.getY() - 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX()-1, block.getY() - 1, block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX()+1, block.getY() + 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX()+1, block.getY() + 1, block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX()+1, block.getY() - 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX()+1, block.getY() - 1, block.getZ() + 1));
|
||||
try {
|
||||
is(new BlockPosition(block.getX() + 1, block.getY(), block.getZ()));
|
||||
is(new BlockPosition(block.getX() - 1, block.getY(), block.getZ()));
|
||||
is(new BlockPosition(block.getX(), block.getY() + 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX(), block.getY() - 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX(), block.getY(), block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX(), block.getY(), block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX() + 1, block.getY(), block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX() + 1, block.getY(), block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX() - 1, block.getY(), block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX() - 1, block.getY(), block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX() + 1, block.getY() + 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX() + 1, block.getY() - 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX() - 1, block.getY() + 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX() - 1, block.getY() - 1, block.getZ()));
|
||||
is(new BlockPosition(block.getX(), block.getY() + 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX(), block.getY() + 1, block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX(), block.getY() - 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX(), block.getY() - 1, block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX()-1, block.getY() + 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX()-1, block.getY() + 1, block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX()-1, block.getY() - 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX()-1, block.getY() - 1, block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX()+1, block.getY() + 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX()+1, block.getY() + 1, block.getZ() + 1));
|
||||
is(new BlockPosition(block.getX()+1, block.getY() - 1, block.getZ() - 1));
|
||||
is(new BlockPosition(block.getX()+1, block.getY() - 1, block.getZ() + 1));
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}, RNG.r.i(3,6));
|
||||
}
|
||||
@ -78,6 +87,7 @@ public class DustRevealer {
|
||||
{
|
||||
hits.add(a);
|
||||
new DustRevealer(parallax, world, a, key, hits);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -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())))
|
||||
|
@ -645,7 +645,6 @@ Runnable rr = () ->
|
||||
|
||||
try
|
||||
{
|
||||
vv.add("Parallelism: " + access().getCompound().getCurrentlyGeneratingEngines());
|
||||
vv.add("Plax Cache : " + Form.f(access().getParallaxChunkCount()));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user