From 8755449c135d7e8987cf0d0963f27880f1f2fd2d Mon Sep 17 00:00:00 2001 From: RePixelatedMC Date: Fri, 18 Oct 2024 15:36:09 +0200 Subject: [PATCH] Untested but should work though --- .../engine/object/IrisMergeStrategies.java | 9 +-- .../volmit/iris/engine/object/IrisMerger.java | 81 ++++++++++++------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisMergeStrategies.java b/core/src/main/java/com/volmit/iris/engine/object/IrisMergeStrategies.java index 099a0fcc2..5521ed5f7 100644 --- a/core/src/main/java/com/volmit/iris/engine/object/IrisMergeStrategies.java +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisMergeStrategies.java @@ -1,20 +1,13 @@ package com.volmit.iris.engine.object; -import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.object.annotations.Desc; -import com.volmit.iris.util.stream.ProceduralStream; - -import java.util.function.Function; @Desc("Modes for generator merging") public enum IrisMergeStrategies { @Desc("Splits the world in height. Use the split settings to customize this option") SPLIT, - @Desc("Split from of the engine height") - SPLIT_ENGINE_HEIGHT, - @Desc("Merge from of the engine height") - MERGE_ENGINE_HEIGHT, + SPLIT_ENGINE_HEIGHT, } diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisMerger.java b/core/src/main/java/com/volmit/iris/engine/object/IrisMerger.java index 2c26f6a81..5b8634721 100644 --- a/core/src/main/java/com/volmit/iris/engine/object/IrisMerger.java +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisMerger.java @@ -6,7 +6,6 @@ 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.view.ChunkDataHunkHolder; import com.volmit.iris.util.hunk.view.ChunkDataHunkView; import com.volmit.iris.util.math.RollingSequence; import com.volmit.iris.util.parallel.BurstExecutor; @@ -40,6 +39,15 @@ public class IrisMerger { @Desc("How deep till it should use vanilla terrain") private int depth = 30; + @Desc("Gets the terrain x,z height as the limit") + private IrisMergeStrategies mode = null; + + @Desc("If it should put the selected generator above or under the split") + private boolean splitUnder = true; + + @Desc("Splits in the engine height") + private int split = 0; + /** * Merges underground from a selected chunk into the corresponding chunk in the outcome world. */ @@ -69,8 +77,6 @@ public class IrisMerger { var cache = new ChunkedDataCache<>(b, engine.getComplex().getHeightStream(), wX, wZ); b.complete(); - boolean vanillaMode = false; - Set caveBiomes = new HashSet<>(Arrays.asList( Biome.DRIPSTONE_CAVES, Biome.LUSH_CAVES, @@ -79,34 +85,38 @@ public class IrisMerger { var nms = INMS.get(); var flag = new Flags(false, false, true, false, false).value(); + for (int xx = 0; xx < 16; xx++) { for (int zz = 0; zz < 16; zz++) { - for (int y = 0; y < totalHeight; y++) { - int height = (int) Math.ceil(cache.get(xx, zz) - depth); - if (y < height || vanillaMode) { - BlockData blockData = vh.get(xx, y, zz); - nms.setBlock( - world, - wX + xx, - y - minHeight, - wZ + zz, - blockData, - flag, - 0 - ); - //TODO improve? - 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)); - } - } + int height = (int) Math.ceil(cache.get(xx, zz) - depth); - 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); - } + for (int y = 0; y < totalHeight; y++) { + if (shouldSkip(y, height)) { + continue; + } + + BlockData blockData = vh.get(xx, y, zz); + 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 (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); } } } @@ -120,6 +130,21 @@ public class IrisMerger { } } + private boolean shouldSkip(int y, int ht) { + int threshold; + switch (mode) { + case SPLIT_ENGINE_HEIGHT: + threshold = ht; + break; + case SPLIT: + threshold = split; + break; + default: + return false; + } + return splitUnder ? y > threshold : y < threshold; + } + public record Flags(boolean listener, boolean flag, boolean client, boolean update, boolean physics) { public static Flags fromValue(int value) { return new Flags(