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.apache.logging.log4j:log4j-api: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 'com.github.oshi:oshi-core:5.8.5'
|
||||
compileOnly 'org.lz4:lz4-java:1.8.0'
|
||||
|
@ -134,6 +134,7 @@ public class IrisEngine implements Engine {
|
||||
cleaning = new AtomicBoolean(false);
|
||||
context.touch();
|
||||
merger = getDimension().getMerger();
|
||||
merger.loadWorld(this);
|
||||
updateMemoryWorld();
|
||||
getData().setEngine(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.EngineAssignedActuator;
|
||||
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.util.collection.KList;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
@ -57,20 +58,6 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
public IrisTerrainNormalActuator(Engine engine) {
|
||||
super(engine, "Terrain");
|
||||
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
|
||||
@ -78,21 +65,15 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore, ChunkContext context) {
|
||||
try {
|
||||
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++) {
|
||||
terrainSliver(x, z, xf, h, hm.get(), context);
|
||||
terrainSliver(x, z, xf, h, context);
|
||||
}
|
||||
|
||||
getEngine().getMetrics().getTerrain().put(p.getMilliseconds());
|
||||
} 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
|
||||
*/
|
||||
@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;
|
||||
IrisBiome biome;
|
||||
IrisRegion region;
|
||||
@ -175,16 +156,15 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
continue;
|
||||
}
|
||||
|
||||
getDimension().getMerger().generateVanillaUnderground(x, z, h, getEngine());
|
||||
|
||||
BlockData ore = biome.generateOres(realX, i, realZ, rng, getData());
|
||||
ore = ore == null ? region.generateOres(realX, i, realZ, rng, getData()) : ore;
|
||||
ore = ore == null ? getDimension().generateOres(realX, i, realZ, rng, getData()) : ore;
|
||||
|
||||
if (!h.get(xf, i, zf).getMaterial().isAir()) {
|
||||
if (ore != null) {
|
||||
h.set(xf, i, zf, ore);
|
||||
} else if (hm == null) {
|
||||
// todo remove this ( TEMP )
|
||||
if (getDimension().isDeepslateLayer() && i < 64) {
|
||||
h.set(xf, i, zf, DEEPSLATE);
|
||||
} else {
|
||||
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.util.context.ChunkedDataCache;
|
||||
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.math.RollingSequence;
|
||||
import com.volmit.iris.util.misc.E;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -32,7 +35,7 @@ import static org.bukkit.Bukkit.createChunkData;
|
||||
@Data
|
||||
public class IrisMerger {
|
||||
private transient RollingSequence mergeDuration = new RollingSequence(20);
|
||||
private transient Engine engine;
|
||||
private transient World worldsave;
|
||||
|
||||
@Desc("Selected 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.
|
||||
*/
|
||||
@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)
|
||||
throw new IllegalStateException("MemoryWorld is null. Ensure that it has been initialized.");
|
||||
if (engine.getWorld() == null)
|
||||
throw new IllegalStateException("World is null. Ensure that the world has been properly loaded.");
|
||||
if (engine.getWorld().realWorld() == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
@ -73,11 +76,14 @@ public class IrisMerger {
|
||||
|
||||
ChunkGenerator.ChunkData chunkData;
|
||||
if (world.isBlank()) {
|
||||
memoryWorld = engine.getMemoryWorld();
|
||||
bukkit = memoryWorld.getBukkit();
|
||||
chunkData = memoryWorld.getChunkData(x, z);
|
||||
throw new UnsupportedOperationException("No.");
|
||||
// memoryWorld = engine.getMemoryWorld();
|
||||
// bukkit = memoryWorld.getBukkit();
|
||||
// chunkData = memoryWorld.getChunkData(x, z);
|
||||
} 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);
|
||||
}
|
||||
|
||||
@ -113,29 +119,36 @@ public class IrisMerger {
|
||||
}
|
||||
|
||||
BlockData blockData = vh.get(xx, y, zz);
|
||||
nms.setBlock(
|
||||
world,
|
||||
wX + xx,
|
||||
y - minHeight,
|
||||
wZ + zz,
|
||||
blockData,
|
||||
flag,
|
||||
0
|
||||
);
|
||||
h.set(xx, y, zz, blockData);
|
||||
// nms.setBlock(
|
||||
// world,
|
||||
// wX + xx,
|
||||
// y - minHeight,
|
||||
// wZ + zz,
|
||||
// blockData,
|
||||
// flag,
|
||||
// 0
|
||||
// );
|
||||
|
||||
if (nms.hasTile(blockData.getMaterial())) {
|
||||
var tile = nms.serializeTile(new Location(bukkit, wX + xx, y - minHeight, wZ + zz));
|
||||
if (tile != null) {
|
||||
nms.deserializeTile(tile, new Location(world, wX + xx, y - minHeight, wZ + zz));
|
||||
}
|
||||
}
|
||||
// if (nms.hasTile(blockData.getMaterial())) {
|
||||
// var tile = nms.serializeTile(new Location(bukkit, wX + xx, y - minHeight, wZ + zz));
|
||||
// if (tile != null) {
|
||||
// nms.deserializeTile(tile, new Location(world, wX + xx, y - minHeight, wZ + zz));
|
||||
// }
|
||||
// }
|
||||
|
||||
if (x % 4 == 0 && z % 4 == 0 && y % 4 == 0) {
|
||||
var biome = chunkData.getBiome(xx, y, zz);
|
||||
if (caveBiomes.contains(biome)) {
|
||||
world.setBiome(wX + xx, y - minHeight, wZ + zz, biome);
|
||||
}
|
||||
}
|
||||
// if (x % 4 == 0 && z % 4 == 0 && y % 4 == 0) {
|
||||
// Biome biome;
|
||||
// try {
|
||||
// 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;
|
||||
}
|
||||
|
||||
private World loadWorld(String worldName) {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world != null)
|
||||
return world;
|
||||
WorldCreator worldCreator = new WorldCreator(worldName);
|
||||
world = Bukkit.createWorld(worldCreator);
|
||||
return world;
|
||||
public void loadWorld(Engine engine) {
|
||||
if (!engine.getDimension().isEnableExperimentalMerger())
|
||||
return;
|
||||
J.sfut(() -> {
|
||||
worldsave = Bukkit.getWorld(world);
|
||||
if (worldsave == null) {
|
||||
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
|
||||
private void onChunkGeneration(ChunkLoadEvent event) {
|
||||
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);
|
||||
//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);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user