mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Smoothiemaps for everyone
This commit is contained in:
parent
bb69ae887f
commit
89da5fe08a
@ -5,7 +5,11 @@ import com.volmit.iris.nms.INMS;
|
|||||||
import com.volmit.iris.scaffold.cache.Cache;
|
import com.volmit.iris.scaffold.cache.Cache;
|
||||||
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.*;
|
import com.volmit.iris.util.B;
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
|
import com.volmit.iris.util.M;
|
||||||
|
import io.timeandspace.smoothie.OptimizationObjective;
|
||||||
|
import io.timeandspace.smoothie.SmoothieMap;
|
||||||
import net.querz.mca.Chunk;
|
import net.querz.mca.Chunk;
|
||||||
import net.querz.mca.MCAFile;
|
import net.querz.mca.MCAFile;
|
||||||
import net.querz.mca.MCAUtil;
|
import net.querz.mca.MCAUtil;
|
||||||
@ -18,19 +22,20 @@ import org.bukkit.block.data.BlockData;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class DirectWorldWriter {
|
public class DirectWorldWriter {
|
||||||
private final File worldFolder;
|
private final File worldFolder;
|
||||||
private final KMap<Long, MCAFile> writeBuffer;
|
private final Map<Long, MCAFile> writeBuffer;
|
||||||
private final KMap<Long, Long> lastUse;
|
private final Map<Long, Long> lastUse;
|
||||||
private static final KMap<String, CompoundTag> blockDataCache = new KMap<>();
|
private static final Map<String, CompoundTag> blockDataCache = SmoothieMap.<String, CompoundTag>newBuilder().build();;
|
||||||
private static final KMap<Biome, Integer> biomeIds = computeBiomeIDs();
|
private static final Map<Biome, Integer> biomeIds = computeBiomeIDs();
|
||||||
|
|
||||||
public DirectWorldWriter(File worldFolder)
|
public DirectWorldWriter(File worldFolder)
|
||||||
{
|
{
|
||||||
this.worldFolder = worldFolder;
|
this.worldFolder = worldFolder;
|
||||||
lastUse = new KMap<>();
|
lastUse = SmoothieMap.<Long, Long>newBuilder().build();
|
||||||
writeBuffer = new KMap<>();
|
writeBuffer = SmoothieMap.<Long, MCAFile>newBuilder().build();
|
||||||
new File(worldFolder, "region").mkdirs();
|
new File(worldFolder, "region").mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,9 +43,9 @@ public class DirectWorldWriter {
|
|||||||
{
|
{
|
||||||
BurstExecutor ex2 = MultiBurst.burst.burst(writeBuffer.size());
|
BurstExecutor ex2 = MultiBurst.burst.burst(writeBuffer.size());
|
||||||
|
|
||||||
for(Long i : writeBuffer.k())
|
for(Long i : new KList<>(writeBuffer.keySet()))
|
||||||
{
|
{
|
||||||
if(M.ms() - lastUse.get(i) < 15000)
|
if(M.ms() - lastUse.get(i) < 5000)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -69,7 +74,10 @@ public class DirectWorldWriter {
|
|||||||
|
|
||||||
lastUse.remove(i);
|
lastUse.remove(i);
|
||||||
MCAUtil.write(writeBuffer.get(i), f, true);
|
MCAUtil.write(writeBuffer.get(i), f, true);
|
||||||
|
synchronized (writeBuffer)
|
||||||
|
{
|
||||||
writeBuffer.remove(i);
|
writeBuffer.remove(i);
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -253,8 +261,11 @@ public class DirectWorldWriter {
|
|||||||
return writeBuffer.size();
|
return writeBuffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KMap<Biome, Integer> computeBiomeIDs() {
|
private static Map<Biome, Integer> computeBiomeIDs() {
|
||||||
KMap<Biome, Integer> biomeIds = new KMap<>();
|
Map<Biome, Integer> biomeIds = SmoothieMap.<Biome, Integer>newBuilder()
|
||||||
|
.expectedSize(Biome.values().length)
|
||||||
|
.optimizeFor(OptimizationObjective.FOOTPRINT)
|
||||||
|
.build();
|
||||||
|
|
||||||
for(Biome i : Biome.values())
|
for(Biome i : Biome.values())
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ public class PregenJob implements Listener
|
|||||||
private double cps = 0;
|
private double cps = 0;
|
||||||
private int lg = 0;
|
private int lg = 0;
|
||||||
private long lt = M.ms();
|
private long lt = M.ms();
|
||||||
private int cubeSize = 32;
|
private int cubeSize = 9;
|
||||||
private long nogen = M.ms();
|
private long nogen = M.ms();
|
||||||
private KList<ChunkPosition> requeueMCA = new KList<ChunkPosition>();
|
private KList<ChunkPosition> requeueMCA = new KList<ChunkPosition>();
|
||||||
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
|
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user