mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 23:47:21 +00:00
Help
This commit is contained in:
parent
dfd27ecbff
commit
9950551ecb
@ -55,7 +55,7 @@ dependencies {
|
|||||||
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
|
||||||
compileOnly 'org.apache.logging.log4j:log4j-api:2.19.0'
|
compileOnly 'org.apache.logging.log4j:log4j-api:2.19.0'
|
||||||
compileOnly 'org.apache.logging.log4j:log4j-core:2.19.0'
|
compileOnly 'org.apache.logging.log4j:log4j-core:2.19.0'
|
||||||
compileOnly 'commons-io:commons-io:2.13.0'
|
compileOnly 'commons-io:commons-io:2.14.0'
|
||||||
compileOnly 'commons-lang:commons-lang:2.6'
|
compileOnly 'commons-lang:commons-lang:2.6'
|
||||||
compileOnly 'com.github.oshi:oshi-core:5.8.5'
|
compileOnly 'com.github.oshi:oshi-core:5.8.5'
|
||||||
compileOnly 'org.lz4:lz4-java:1.8.0'
|
compileOnly 'org.lz4:lz4-java:1.8.0'
|
||||||
|
@ -134,6 +134,7 @@ public class IrisEngine implements Engine {
|
|||||||
cleaning = new AtomicBoolean(false);
|
cleaning = new AtomicBoolean(false);
|
||||||
context.touch();
|
context.touch();
|
||||||
merger = getDimension().getMerger();
|
merger = getDimension().getMerger();
|
||||||
|
merger.loadWorld(this);
|
||||||
updateMemoryWorld();
|
updateMemoryWorld();
|
||||||
getData().setEngine(this);
|
getData().setEngine(this);
|
||||||
getData().loadPrefetch(this);
|
getData().loadPrefetch(this);
|
||||||
|
@ -24,6 +24,7 @@ import com.volmit.iris.core.nms.INMS;
|
|||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
|
import com.volmit.iris.engine.object.IrisMerger;
|
||||||
import com.volmit.iris.engine.object.IrisRegion;
|
import com.volmit.iris.engine.object.IrisRegion;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.context.ChunkContext;
|
import com.volmit.iris.util.context.ChunkContext;
|
||||||
@ -57,20 +58,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
public IrisTerrainNormalActuator(Engine engine) {
|
public IrisTerrainNormalActuator(Engine engine) {
|
||||||
super(engine, "Terrain");
|
super(engine, "Terrain");
|
||||||
rng = new RNG(engine.getSeedManager().getTerrain());
|
rng = new RNG(engine.getSeedManager().getTerrain());
|
||||||
// todo: for v4
|
|
||||||
// boolean debug = getDimension().getMerger().isDatapackMode();
|
|
||||||
// if (!getDimension().getMerger().getGenerator().isBlank()) {
|
|
||||||
// try {
|
|
||||||
// if (!getDimension().getMerger().isDatapackMode()) {
|
|
||||||
// this.memoryWorld = INMS.get().createMemoryWorld(new WorldCreator("terrain").generator(getEngine().getDimension().getMerger().getGenerator()));
|
|
||||||
// } else {
|
|
||||||
// String test = getDimension().getMerger().getGenerator().toLowerCase();
|
|
||||||
// this.memoryWorld = INMS.get().createMemoryWorld(NamespacedKey.minecraft(test), new WorldCreator("terrain"));
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
@ -78,21 +65,15 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore, ChunkContext context) {
|
public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore, ChunkContext context) {
|
||||||
try {
|
try {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
AtomicReference<Hunk<BlockData>> hm = new AtomicReference<>();
|
|
||||||
if (memoryWorld != null) {
|
|
||||||
PaperLib.getChunkAtAsync(memoryWorld.getBukkit(), x, z, true).thenAccept((i) -> {
|
|
||||||
hm.set(toHunk(memoryWorld.getChunkData(x, z)));
|
|
||||||
}).get();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int xf = 0; xf < h.getWidth(); xf++) {
|
for (int xf = 0; xf < h.getWidth(); xf++) {
|
||||||
terrainSliver(x, z, xf, h, hm.get(), context);
|
terrainSliver(x, z, xf, h, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
getEngine().getMetrics().getTerrain().put(p.getMilliseconds());
|
getEngine().getMetrics().getTerrain().put(p.getMilliseconds());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Iris.error("Fatal Error!", e);
|
e.printStackTrace();
|
||||||
|
//Iris.error("Fatal Error!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +91,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
* @param h the blockdata
|
* @param h the blockdata
|
||||||
*/
|
*/
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h, @Nullable Hunk<BlockData> hm, ChunkContext context) {
|
public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h, ChunkContext context) {
|
||||||
int zf, realX, realZ, hf, he;
|
int zf, realX, realZ, hf, he;
|
||||||
IrisBiome biome;
|
IrisBiome biome;
|
||||||
IrisRegion region;
|
IrisRegion region;
|
||||||
@ -175,16 +156,15 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDimension().getMerger().generateVanillaUnderground(x, z, h, getEngine());
|
||||||
|
|
||||||
BlockData ore = biome.generateOres(realX, i, realZ, rng, getData());
|
BlockData ore = biome.generateOres(realX, i, realZ, rng, getData());
|
||||||
ore = ore == null ? region.generateOres(realX, i, realZ, rng, getData()) : ore;
|
ore = ore == null ? region.generateOres(realX, i, realZ, rng, getData()) : ore;
|
||||||
ore = ore == null ? getDimension().generateOres(realX, i, realZ, rng, getData()) : ore;
|
ore = ore == null ? getDimension().generateOres(realX, i, realZ, rng, getData()) : ore;
|
||||||
|
|
||||||
if (ore != null) {
|
if (!h.get(xf, i, zf).getMaterial().isAir()) {
|
||||||
h.set(xf, i, zf, ore);
|
if (ore != null) {
|
||||||
} else if (hm == null) {
|
h.set(xf, i, zf, ore);
|
||||||
// todo remove this ( TEMP )
|
|
||||||
if (getDimension().isDeepslateLayer() && i < 64) {
|
|
||||||
h.set(xf, i, zf, DEEPSLATE);
|
|
||||||
} else {
|
} else {
|
||||||
h.set(xf, i, zf, context.getRock().get(xf, zf));
|
h.set(xf, i, zf, context.getRock().get(xf, zf));
|
||||||
}
|
}
|
||||||
@ -193,17 +173,4 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Hunk<BlockData> toHunk(ChunkGenerator.ChunkData data) {
|
|
||||||
Hunk<BlockData> h = Hunk.newArrayHunk(16, memoryWorld.getBukkit().getMaxHeight(), 16);
|
|
||||||
for (int x = 0; x < 16; x++) {
|
|
||||||
for (int z = 0; z < 16; z++) {
|
|
||||||
for (int y = 0; y < memoryWorld.getBukkit().getMaxHeight(); y++) {
|
|
||||||
BlockData block = data.getBlockData(x, y, z);
|
|
||||||
h.set(x, y, z, block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,13 @@ import com.volmit.iris.engine.framework.Engine;
|
|||||||
import com.volmit.iris.engine.object.annotations.Desc;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
import com.volmit.iris.util.context.ChunkedDataCache;
|
import com.volmit.iris.util.context.ChunkedDataCache;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import com.volmit.iris.util.hunk.view.ChunkDataHunkView;
|
import com.volmit.iris.util.hunk.view.ChunkDataHunkView;
|
||||||
import com.volmit.iris.util.math.RollingSequence;
|
import com.volmit.iris.util.math.RollingSequence;
|
||||||
|
import com.volmit.iris.util.misc.E;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -32,7 +35,7 @@ import static org.bukkit.Bukkit.createChunkData;
|
|||||||
@Data
|
@Data
|
||||||
public class IrisMerger {
|
public class IrisMerger {
|
||||||
private transient RollingSequence mergeDuration = new RollingSequence(20);
|
private transient RollingSequence mergeDuration = new RollingSequence(20);
|
||||||
private transient Engine engine;
|
private transient World worldsave;
|
||||||
|
|
||||||
@Desc("Selected Generator")
|
@Desc("Selected Generator")
|
||||||
private String generator;
|
private String generator;
|
||||||
@ -59,11 +62,11 @@ public class IrisMerger {
|
|||||||
* Merges underground from a selected chunk into the corresponding chunk in the outcome world.
|
* Merges underground from a selected chunk into the corresponding chunk in the outcome world.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void generateVanillaUnderground(int x, int z, Engine engine) {
|
public void generateVanillaUnderground(int x, int z, Hunk<BlockData> h, Engine engine) {
|
||||||
if (engine.getMemoryWorld() == null)
|
if (engine.getMemoryWorld() == null)
|
||||||
throw new IllegalStateException("MemoryWorld is null. Ensure that it has been initialized.");
|
throw new IllegalStateException("MemoryWorld is null. Ensure that it has been initialized.");
|
||||||
if (engine.getWorld() == null)
|
if (engine.getWorld().realWorld() == null)
|
||||||
throw new IllegalStateException("World is null. Ensure that the world has been properly loaded.");
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
@ -73,11 +76,14 @@ public class IrisMerger {
|
|||||||
|
|
||||||
ChunkGenerator.ChunkData chunkData;
|
ChunkGenerator.ChunkData chunkData;
|
||||||
if (world.isBlank()) {
|
if (world.isBlank()) {
|
||||||
memoryWorld = engine.getMemoryWorld();
|
throw new UnsupportedOperationException("No.");
|
||||||
bukkit = memoryWorld.getBukkit();
|
// memoryWorld = engine.getMemoryWorld();
|
||||||
chunkData = memoryWorld.getChunkData(x, z);
|
// bukkit = memoryWorld.getBukkit();
|
||||||
|
// chunkData = memoryWorld.getChunkData(x, z);
|
||||||
} else {
|
} else {
|
||||||
bukkit = loadWorld(world);
|
bukkit = Bukkit.getWorld(world);
|
||||||
|
if (bukkit == null)
|
||||||
|
throw new IllegalStateException("Somehow world is null? Initialization Failed!");
|
||||||
chunkData = getChunkDataAt(bukkit, x, z);
|
chunkData = getChunkDataAt(bukkit, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,29 +119,36 @@ public class IrisMerger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockData blockData = vh.get(xx, y, zz);
|
BlockData blockData = vh.get(xx, y, zz);
|
||||||
nms.setBlock(
|
h.set(xx, y, zz, blockData);
|
||||||
world,
|
// nms.setBlock(
|
||||||
wX + xx,
|
// world,
|
||||||
y - minHeight,
|
// wX + xx,
|
||||||
wZ + zz,
|
// y - minHeight,
|
||||||
blockData,
|
// wZ + zz,
|
||||||
flag,
|
// blockData,
|
||||||
0
|
// flag,
|
||||||
);
|
// 0
|
||||||
|
// );
|
||||||
|
|
||||||
if (nms.hasTile(blockData.getMaterial())) {
|
// if (nms.hasTile(blockData.getMaterial())) {
|
||||||
var tile = nms.serializeTile(new Location(bukkit, wX + xx, y - minHeight, wZ + zz));
|
// var tile = nms.serializeTile(new Location(bukkit, wX + xx, y - minHeight, wZ + zz));
|
||||||
if (tile != null) {
|
// if (tile != null) {
|
||||||
nms.deserializeTile(tile, new Location(world, wX + xx, y - minHeight, wZ + zz));
|
// nms.deserializeTile(tile, new Location(world, wX + xx, y - minHeight, wZ + zz));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (x % 4 == 0 && z % 4 == 0 && y % 4 == 0) {
|
// if (x % 4 == 0 && z % 4 == 0 && y % 4 == 0) {
|
||||||
var biome = chunkData.getBiome(xx, y, zz);
|
// Biome biome;
|
||||||
if (caveBiomes.contains(biome)) {
|
// try {
|
||||||
world.setBiome(wX + xx, y - minHeight, wZ + zz, biome);
|
// biome = chunkData.getBiome(xx, y, zz);
|
||||||
}
|
// } catch (UnsupportedOperationException e) {
|
||||||
}
|
// biome = bukkit.getBiome(wX + xx, y, wZ + zz);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (caveBiomes.contains(biome)) {
|
||||||
|
// world.setBiome(wX + xx, y - minHeight, wZ + zz, biome);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,12 +222,27 @@ public class IrisMerger {
|
|||||||
return chunkData;
|
return chunkData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private World loadWorld(String worldName) {
|
public void loadWorld(Engine engine) {
|
||||||
World world = Bukkit.getWorld(worldName);
|
if (!engine.getDimension().isEnableExperimentalMerger())
|
||||||
if (world != null)
|
return;
|
||||||
return world;
|
J.sfut(() -> {
|
||||||
WorldCreator worldCreator = new WorldCreator(worldName);
|
worldsave = Bukkit.getWorld(world);
|
||||||
world = Bukkit.createWorld(worldCreator);
|
if (worldsave == null) {
|
||||||
return world;
|
WorldCreator worldCreator = new WorldCreator(world);
|
||||||
|
worldsave = Bukkit.createWorld(worldCreator);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// new Thread(() -> {
|
||||||
|
// try {
|
||||||
|
// boolean wait = true;
|
||||||
|
// while (wait) {
|
||||||
|
// Thread.sleep(100);
|
||||||
|
// if (Bukkit.getWorld(world) != null)
|
||||||
|
// wait = false;
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,8 +385,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onChunkGeneration(ChunkLoadEvent event) {
|
private void onChunkGeneration(ChunkLoadEvent event) {
|
||||||
if(!event.isNewChunk() || !engine.getWorld().realWorld().equals(event.getWorld()) || !engine.getDimension().isEnableExperimentalMerger() || engine.getMemoryWorld() == null) return;
|
//if(!event.isNewChunk() || !engine.getWorld().realWorld().equals(event.getWorld()) || !engine.getDimension().isEnableExperimentalMerger() || engine.getMemoryWorld() == null) return;
|
||||||
engine.getMerger().generateVanillaUnderground(event.getChunk().getX(), event.getChunk().getZ(), engine);
|
//engine.getMerger().generateVanillaUnderground(event.getChunk().getX(), event.getChunk().getZ(), engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user