mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Faster
This commit is contained in:
parent
3d00e96f89
commit
7bbae51c7d
5
pom.xml
5
pom.xml
@ -154,6 +154,11 @@
|
|||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.Querz</groupId>
|
||||||
|
<artifactId>NBT</artifactId>
|
||||||
|
<version>5.5</version>
|
||||||
|
</dependency>
|
||||||
<!-- Spigot API -->
|
<!-- Spigot API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
|
@ -51,6 +51,9 @@ public class IrisSettings
|
|||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
public boolean useGleamPregenerator = false;
|
public boolean useGleamPregenerator = false;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
public boolean useExperimentalGleamMCADirectWriteMode = false;
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
public boolean disableNMS = false;
|
public boolean disableNMS = false;
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ package com.volmit.iris.generator.actuator;
|
|||||||
import com.volmit.iris.scaffold.engine.Engine;
|
import com.volmit.iris.scaffold.engine.Engine;
|
||||||
import com.volmit.iris.scaffold.engine.EngineAssignedActuator;
|
import com.volmit.iris.scaffold.engine.EngineAssignedActuator;
|
||||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||||
|
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.PrecisionStopwatch;
|
import com.volmit.iris.util.PrecisionStopwatch;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
@ -15,21 +17,28 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome>
|
|||||||
@Override
|
@Override
|
||||||
public void onActuate(int x, int z, Hunk<Biome> h) {
|
public void onActuate(int x, int z, Hunk<Biome> h) {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
int i,zf;
|
int zf,hh;
|
||||||
Biome v;
|
BurstExecutor burst = MultiBurst.burst.burst(h.getWidth() * h.getDepth());
|
||||||
|
|
||||||
for(int xf = 0; xf < h.getWidth(); xf++)
|
for(int xf = 0; xf < h.getWidth(); xf++)
|
||||||
{
|
{
|
||||||
for(zf = 0; zf < h.getDepth(); zf++)
|
for(zf = 0; zf < h.getDepth(); zf++)
|
||||||
{
|
{
|
||||||
v = getComplex().getTrueBiomeStream().get(modX(xf+x), modZ(zf+z)).getDerivative();
|
int xxf = xf;
|
||||||
|
int zzf = zf;
|
||||||
|
|
||||||
for(i = 0; i < h.getHeight(); i++)
|
burst.queue(() -> {
|
||||||
{
|
Biome v = getComplex().getTrueBiomeStream().get(modX(xxf+x), modZ(zzf+z)).getDerivative();
|
||||||
h.set(xf, i, zf, v);
|
for(int i = 0; i < h.getHeight(); i++)
|
||||||
}
|
{
|
||||||
|
h.set(xxf, i, zzf, v);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
burst.complete();
|
||||||
|
|
||||||
getEngine().getMetrics().getBiome().put(p.getMilliseconds());
|
getEngine().getMetrics().getBiome().put(p.getMilliseconds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import com.volmit.iris.object.IrisBiome;
|
|||||||
import com.volmit.iris.scaffold.engine.Engine;
|
import com.volmit.iris.scaffold.engine.Engine;
|
||||||
import com.volmit.iris.scaffold.engine.EngineAssignedModifier;
|
import com.volmit.iris.scaffold.engine.EngineAssignedModifier;
|
||||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||||
|
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.B;
|
import com.volmit.iris.util.B;
|
||||||
import com.volmit.iris.util.CaveResult;
|
import com.volmit.iris.util.CaveResult;
|
||||||
import com.volmit.iris.util.PrecisionStopwatch;
|
import com.volmit.iris.util.PrecisionStopwatch;
|
||||||
@ -27,13 +29,18 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
@Override
|
@Override
|
||||||
public void onModify(int x, int z, Hunk<BlockData> output) {
|
public void onModify(int x, int z, Hunk<BlockData> output) {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
for(int i = 0; i < output.getWidth(); i++)
|
BurstExecutor b = MultiBurst.burst.burst(output.getWidth() * output.getDepth());
|
||||||
|
int i, j;
|
||||||
|
for(i = 0; i < output.getWidth(); i++)
|
||||||
{
|
{
|
||||||
for(int j = 0; j < output.getDepth(); j++)
|
int ii = i;
|
||||||
|
for(j = 0; j < output.getDepth(); j++)
|
||||||
{
|
{
|
||||||
post(i, j, output, i+x, j+z);
|
int jj = j;
|
||||||
|
b.queue(() -> post(ii, jj, output, ii+x, jj+z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
b.complete();
|
||||||
getEngine().getMetrics().getPost().put(p.getMilliseconds());
|
getEngine().getMetrics().getPost().put(p.getMilliseconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,4 +33,6 @@ public interface INMSBinding
|
|||||||
return getCreator().createWorld(creator, loadSpawn);
|
return getCreator().createWorld(creator, loadSpawn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getBiomeId(Biome biome);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.volmit.iris.scaffold.cache.AtomicCache;
|
|||||||
import com.volmit.iris.util.KMap;
|
import com.volmit.iris.util.KMap;
|
||||||
import net.minecraft.server.v1_16_R2.BiomeBase;
|
import net.minecraft.server.v1_16_R2.BiomeBase;
|
||||||
import net.minecraft.server.v1_16_R2.IRegistry;
|
import net.minecraft.server.v1_16_R2.IRegistry;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
||||||
@ -41,6 +42,20 @@ public class NMSBinding16_2 implements INMSBinding
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBiomeId(Biome biome) {
|
||||||
|
for(World i : Bukkit.getWorlds())
|
||||||
|
{
|
||||||
|
if(i.getEnvironment().equals(World.Environment.NORMAL))
|
||||||
|
{
|
||||||
|
IRegistry<BiomeBase> registry = ((CraftWorld)i).getHandle().r().b(IRegistry.ay);
|
||||||
|
return registry.a((BiomeBase) getBiomeBase(registry, biome));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return biome.ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBukkit() {
|
public boolean isBukkit() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -6,6 +6,7 @@ import com.volmit.iris.scaffold.cache.AtomicCache;
|
|||||||
import com.volmit.iris.util.KMap;
|
import com.volmit.iris.util.KMap;
|
||||||
import net.minecraft.server.v1_16_R3.BiomeBase;
|
import net.minecraft.server.v1_16_R3.BiomeBase;
|
||||||
import net.minecraft.server.v1_16_R3.IRegistry;
|
import net.minecraft.server.v1_16_R3.IRegistry;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
||||||
@ -40,6 +41,20 @@ public class NMSBinding16_3 implements INMSBinding
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBiomeId(Biome biome) {
|
||||||
|
for(World i : Bukkit.getWorlds())
|
||||||
|
{
|
||||||
|
if(i.getEnvironment().equals(World.Environment.NORMAL))
|
||||||
|
{
|
||||||
|
IRegistry<BiomeBase> registry = ((CraftWorld)i).getHandle().r().b(net.minecraft.server.v1_16_R3.IRegistry.ay);
|
||||||
|
return registry.a((BiomeBase) getBiomeBase(registry, biome));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return biome.ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBukkit() {
|
public boolean isBukkit() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -30,4 +30,9 @@ public class NMSBinding1X implements INMSBinding
|
|||||||
public boolean isBukkit() {
|
public boolean isBukkit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBiomeId(Biome biome) {
|
||||||
|
return biome.ordinal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,210 @@
|
|||||||
|
package com.volmit.iris.scaffold.engine;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.nms.INMS;
|
||||||
|
import com.volmit.iris.scaffold.cache.Cache;
|
||||||
|
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||||
|
import com.volmit.iris.util.B;
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
|
import com.volmit.iris.util.KMap;
|
||||||
|
import net.querz.mca.Chunk;
|
||||||
|
import net.querz.mca.MCAFile;
|
||||||
|
import net.querz.mca.MCAUtil;
|
||||||
|
import net.querz.mca.Section;
|
||||||
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
import net.querz.nbt.tag.StringTag;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class DirectWorldWriter {
|
||||||
|
private final File worldFolder;
|
||||||
|
private final KMap<Long, MCAFile> writeBuffer;
|
||||||
|
|
||||||
|
public DirectWorldWriter(File worldFolder)
|
||||||
|
{
|
||||||
|
this.worldFolder = worldFolder;
|
||||||
|
writeBuffer = new KMap<>();
|
||||||
|
new File(worldFolder, "region").mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void flush()
|
||||||
|
{
|
||||||
|
BurstExecutor ex = MultiBurst.burst.burst(writeBuffer.size());
|
||||||
|
writeBuffer.v().forEach((i) -> ex.queue(i::cleanupPalettesAndBlockStates));
|
||||||
|
ex.complete();
|
||||||
|
BurstExecutor ex2 = MultiBurst.burst.burst(writeBuffer.size());
|
||||||
|
|
||||||
|
for(Long i : writeBuffer.k())
|
||||||
|
{
|
||||||
|
int x = Cache.keyX(i);
|
||||||
|
int z = Cache.keyZ(i);
|
||||||
|
try {
|
||||||
|
File f = getMCAFile(x, z);
|
||||||
|
|
||||||
|
if(!f.exists())
|
||||||
|
{
|
||||||
|
f.getParentFile().mkdirs();
|
||||||
|
f.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
MCAUtil.write(writeBuffer.get(i), f, true);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writeBuffer.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getMCAFile(int x, int z)
|
||||||
|
{
|
||||||
|
return new File(worldFolder, "region/r." + x + "." + z + ".mca");
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockData getBlockData(CompoundTag tag)
|
||||||
|
{
|
||||||
|
String p = tag.getString("Name");
|
||||||
|
|
||||||
|
if(tag.containsKey("Properties"))
|
||||||
|
{
|
||||||
|
CompoundTag props = tag.getCompoundTag("Properties");
|
||||||
|
p += "[";
|
||||||
|
KList<String> m = new KList<>();
|
||||||
|
|
||||||
|
for(String i : props.keySet())
|
||||||
|
{
|
||||||
|
m.add(i + "=" + props.getString(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
p += m.toString(",") + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
return B.get(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag getCompound(BlockData blockData)
|
||||||
|
{
|
||||||
|
CompoundTag s = new CompoundTag();
|
||||||
|
NamespacedKey key = blockData.getMaterial().getKey();
|
||||||
|
s.putString("Name", key.getNamespace() + ":" + key.getKey());
|
||||||
|
|
||||||
|
String data = blockData.getAsString(true);
|
||||||
|
|
||||||
|
if(data.contains("["))
|
||||||
|
{
|
||||||
|
String raw = data.split("\\Q[\\E")[1].replaceAll("\\Q]\\E", "");
|
||||||
|
CompoundTag props = new CompoundTag();
|
||||||
|
if(raw.contains(","))
|
||||||
|
{
|
||||||
|
for(String i : raw.split("\\Q,\\E"))
|
||||||
|
{
|
||||||
|
String[] m = i.split("\\Q=\\E");
|
||||||
|
String k = m[0];
|
||||||
|
String v = m[1];
|
||||||
|
props.put(k, new StringTag(v));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String[] m = raw.split("\\Q=\\E");
|
||||||
|
String k = m[0];
|
||||||
|
String v = m[1];
|
||||||
|
props.put(k, new StringTag(v));
|
||||||
|
}
|
||||||
|
s.put("Properties", props);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockData getBlockData(int x, int y, int z)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CompoundTag tag = getChunkSection(x >> 4, y >> 4, z >> 4).getBlockStateAt(x & 15, y & 15, z & 15);
|
||||||
|
|
||||||
|
if(tag == null)
|
||||||
|
{
|
||||||
|
return B.get("AIR");
|
||||||
|
}
|
||||||
|
|
||||||
|
return getBlockData(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return B.get("AIR");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockData(int x, int y, int z, BlockData data)
|
||||||
|
{
|
||||||
|
getChunkSection(x >> 4, y >> 4, z >> 4).setBlockStateAt(x & 15, y & 15, z & 15, getCompound(data), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBiome(int x, int y, int z, Biome biome)
|
||||||
|
{
|
||||||
|
getChunk(x>>4, z>>4).setBiomeAt(x&15, y, z &15, INMS.get().getBiomeId(biome));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Section getChunkSection(int x, int y, int z)
|
||||||
|
{
|
||||||
|
Chunk c = getChunk(x, z);
|
||||||
|
Section s = c.getSection(y);
|
||||||
|
|
||||||
|
if(s == null)
|
||||||
|
{
|
||||||
|
s = Section.newSection();
|
||||||
|
c.setSection(y, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chunk getChunk(int x, int z)
|
||||||
|
{
|
||||||
|
MCAFile mca = getMCA(x >> 5, z >> 5);
|
||||||
|
Chunk c = mca.getChunk(x & 31, z & 31);
|
||||||
|
|
||||||
|
if(c == null)
|
||||||
|
{
|
||||||
|
c = Chunk.newChunk();
|
||||||
|
mca.setChunk(x&31, z&31, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MCAFile getMCA(int x, int z)
|
||||||
|
{
|
||||||
|
long key = Cache.key(x, z);
|
||||||
|
MCAFile mca = writeBuffer.get(key);
|
||||||
|
|
||||||
|
if(mca != null)
|
||||||
|
{
|
||||||
|
return mca;
|
||||||
|
}
|
||||||
|
|
||||||
|
File f = getMCAFile(x, z);
|
||||||
|
mca = new MCAFile(x, z);
|
||||||
|
if(f.exists())
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
mca = MCAUtil.read(f);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Iris.warn("Failed to read RandomAccessFile " + f.getAbsolutePath() + ", assuming empty region!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writeBuffer.put(key, mca);
|
||||||
|
return mca;
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,8 @@ import com.volmit.iris.object.IrisDimension;
|
|||||||
import com.volmit.iris.scaffold.IrisWorlds;
|
import com.volmit.iris.scaffold.IrisWorlds;
|
||||||
import com.volmit.iris.scaffold.cache.Cache;
|
import com.volmit.iris.scaffold.cache.Cache;
|
||||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||||
|
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.*;
|
import com.volmit.iris.util.*;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -308,6 +310,129 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
return tc.getRaw();
|
return tc.getRaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void directWriteMCA(World w, int x, int z, DirectWorldWriter writer, MultiBurst burst)
|
||||||
|
{
|
||||||
|
if(writer.getMCAFile(x, z).exists())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BurstExecutor e = burst.burst(1024);
|
||||||
|
int mcaox = x << 5;
|
||||||
|
int mcaoz = z << 5;
|
||||||
|
|
||||||
|
for(int i = 0; i < 32; i++)
|
||||||
|
{
|
||||||
|
int ii = i;
|
||||||
|
for(int j = 0; j < 32; j++)
|
||||||
|
{
|
||||||
|
int jj = j;
|
||||||
|
e.queue(() -> directWriteChunk(w, ii + mcaox, jj + mcaoz, writer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
e.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void directWriteChunk(World w, int x, int z, DirectWorldWriter writer)
|
||||||
|
{
|
||||||
|
int ox = x << 4;
|
||||||
|
int oz = z << 4;
|
||||||
|
generateChunkRawData(w, x, z, new TerrainChunk() {
|
||||||
|
@Override
|
||||||
|
public void setRaw(ChunkData data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome getBiome(int x, int z) {
|
||||||
|
return Biome.THE_VOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome getBiome(int x, int y, int z) {
|
||||||
|
return Biome.THE_VOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBiome(int x, int z, Biome bio) {
|
||||||
|
writer.setBiome(ox + x, 0, oz + z, bio);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBiome(int x, int y, int z, Biome bio) {
|
||||||
|
writer.setBiome(ox + x, y, oz + z, bio);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHeight() {
|
||||||
|
return w.getMaxHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(int x, int y, int z, BlockData blockData) {
|
||||||
|
writer.setBlockData(x+ox, y, z+oz, blockData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockData getBlockData(int x, int y, int z) {
|
||||||
|
return writer.getBlockData(x + ox, y, z + oz);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkData getRaw() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inject(BiomeGrid biome) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(int x, int y, int z, @NotNull Material material) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(int x, int y, int z, @NotNull MaterialData material) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull Material material) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull MaterialData material) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull BlockData blockData) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Material getType(int x, int y, int z) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public MaterialData getTypeAndData(int x, int y, int z) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte getData(int x, int y, int z) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}).run();
|
||||||
|
}
|
||||||
|
|
||||||
public Chunk generatePaper(World world, int x, int z)
|
public Chunk generatePaper(World world, int x, int z)
|
||||||
{
|
{
|
||||||
precache(world, x, z);
|
precache(world, x, z);
|
||||||
|
@ -151,15 +151,19 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
|
|||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
int s = (int) Math.ceil(getParallaxSize() / 2D);
|
int s = (int) Math.ceil(getParallaxSize() / 2D);
|
||||||
int i,j;
|
int i,j;
|
||||||
|
BurstExecutor b = MultiBurst.burst.burst((s * 2) * (s * 2));
|
||||||
|
|
||||||
for(i = -s; i <= s; i++)
|
for(i = -s; i <= s; i++)
|
||||||
{
|
{
|
||||||
|
int ii = i;
|
||||||
for(j = -s; j <= s; j++)
|
for(j = -s; j <= s; j++)
|
||||||
{
|
{
|
||||||
generateParallaxLayer((i*16)+x, (j*16)+z);
|
int jj = j;
|
||||||
|
b.queue(() -> generateParallaxLayer((ii*16)+x, (jj*16)+z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.complete();
|
||||||
getParallaxAccess().setChunkGenerated(x>>4, z>>4);
|
getParallaxAccess().setChunkGenerated(x>>4, z>>4);
|
||||||
p.end();
|
p.end();
|
||||||
getEngine().getMetrics().getParallax().put(p.getMilliseconds());
|
getEngine().getMetrics().getParallax().put(p.getMilliseconds());
|
||||||
|
@ -3,6 +3,7 @@ package com.volmit.iris.scaffold.engine;
|
|||||||
import com.volmit.iris.manager.IrisDataManager;
|
import com.volmit.iris.manager.IrisDataManager;
|
||||||
import com.volmit.iris.object.*;
|
import com.volmit.iris.object.*;
|
||||||
import com.volmit.iris.scaffold.data.DataProvider;
|
import com.volmit.iris.scaffold.data.DataProvider;
|
||||||
|
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.*;
|
import com.volmit.iris.util.*;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -16,6 +17,10 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public interface IrisAccess extends Hotloadable, DataProvider {
|
public interface IrisAccess extends Hotloadable, DataProvider {
|
||||||
|
|
||||||
|
public void directWriteMCA(World w, int x, int z, DirectWorldWriter writer, MultiBurst burst);
|
||||||
|
|
||||||
|
public void directWriteChunk(World w, int x, int z, DirectWorldWriter writer);
|
||||||
|
|
||||||
public int getGenerated();
|
public int getGenerated();
|
||||||
|
|
||||||
public double getGeneratedPerSecond();
|
public double getGeneratedPerSecond();
|
||||||
|
1282
src/main/java/com/volmit/iris/util/FakeWorld.java
Normal file
1282
src/main/java/com/volmit/iris/util/FakeWorld.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,7 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.IrisSettings;
|
import com.volmit.iris.IrisSettings;
|
||||||
import com.volmit.iris.manager.gui.PregenGui;
|
import com.volmit.iris.manager.gui.PregenGui;
|
||||||
import com.volmit.iris.scaffold.IrisWorlds;
|
import com.volmit.iris.scaffold.IrisWorlds;
|
||||||
|
import com.volmit.iris.scaffold.engine.DirectWorldWriter;
|
||||||
import com.volmit.iris.scaffold.engine.IrisAccess;
|
import com.volmit.iris.scaffold.engine.IrisAccess;
|
||||||
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
@ -60,12 +61,14 @@ public class PregenJob implements Listener
|
|||||||
private long pausedAt = 0;
|
private long pausedAt = 0;
|
||||||
private double pms = 0;
|
private double pms = 0;
|
||||||
private boolean gleaming = false;
|
private boolean gleaming = false;
|
||||||
|
private final DirectWorldWriter writer;
|
||||||
int xc = 0;
|
int xc = 0;
|
||||||
private IrisAccess access = null;
|
private IrisAccess access = null;
|
||||||
|
|
||||||
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
||||||
{
|
{
|
||||||
gleaming = (IrisSettings.get().isUseGleamPregenerator() && PaperLib.isPaper());
|
writer = new DirectWorldWriter(world.getWorldFolder());
|
||||||
|
gleaming = (IrisSettings.get().isUseGleamPregenerator());
|
||||||
g.set(0);
|
g.set(0);
|
||||||
burst = new MultiBurst(gleaming ? IrisSettings.get().getMaxAsyncChunkPregenThreads() : tc());
|
burst = new MultiBurst(gleaming ? IrisSettings.get().getMaxAsyncChunkPregenThreads() : tc());
|
||||||
instance = this;
|
instance = this;
|
||||||
@ -393,26 +396,48 @@ public class PregenJob implements Listener
|
|||||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.cyan.darker().darker().darker());
|
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.cyan.darker().darker().darker());
|
||||||
}
|
}
|
||||||
|
|
||||||
J.a(() -> {
|
Runnable g = () -> {
|
||||||
try {
|
try {
|
||||||
working.acquire();
|
working.acquire();
|
||||||
if(consumer != null)
|
if(consumer != null)
|
||||||
{
|
{
|
||||||
consumer.accept(new ChunkPosition(cx, cz), Color.cyan);
|
consumer.accept(new ChunkPosition(cx, cz), Color.cyan);
|
||||||
}
|
}
|
||||||
Chunk chunk = access().generatePaper(world, cx, cz);
|
int xx = cx;
|
||||||
|
int zz = cz;
|
||||||
|
|
||||||
|
if(IrisSettings.get().isUseExperimentalGleamMCADirectWriteMode())
|
||||||
|
{
|
||||||
|
access().directWriteChunk(world, cx, cz, writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
access().generatePaper(world, cx, cz);
|
||||||
|
}
|
||||||
|
|
||||||
working.release();
|
working.release();
|
||||||
genned++;
|
genned++;
|
||||||
nogen = M.ms();
|
nogen = M.ms();
|
||||||
|
|
||||||
if(consumer != null)
|
if(consumer != null)
|
||||||
{
|
{
|
||||||
consumer.accept(new ChunkPosition(chunk.getX(), chunk.getZ()), Color.yellow);
|
if(IrisSettings.get().isUseExperimentalGleamMCADirectWriteMode())
|
||||||
|
{
|
||||||
|
consumer.accept(new ChunkPosition(xx, zz), Color.blue);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
consumer.accept(new ChunkPosition(xx, zz), Color.yellow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
J.a(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -559,6 +584,8 @@ public class PregenJob implements Listener
|
|||||||
world.save();
|
world.save();
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-all");
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-all");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writer.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int max()
|
public int max()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user