From 2296c1368b9b9bba13b645704df94fdba64dcc9a Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Tue, 9 Jul 2024 16:19:22 +0200 Subject: [PATCH 1/7] fix WorldEditLink --- .../volmit/iris/core/link/WorldEditLink.java | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/core/link/WorldEditLink.java b/core/src/main/java/com/volmit/iris/core/link/WorldEditLink.java index 168b8c066..42e335a10 100644 --- a/core/src/main/java/com/volmit/iris/core/link/WorldEditLink.java +++ b/core/src/main/java/com/volmit/iris/core/link/WorldEditLink.java @@ -1,12 +1,19 @@ package com.volmit.iris.core.link; +import com.volmit.iris.Iris; +import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.util.data.Cuboid; +import com.volmit.iris.util.data.KCache; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; +import java.lang.reflect.InvocationTargetException; +import java.time.Duration; +import java.util.UUID; + public class WorldEditLink { - private static Boolean enabled = null; + private static final AtomicCache active = new AtomicCache<>(); public static Cuboid getSelection(Player p) { if (!hasWorldEdit()) @@ -15,29 +22,38 @@ public class WorldEditLink { try { Object instance = Class.forName("com.sk89q.worldedit.WorldEdit").getDeclaredMethod("getInstance").invoke(null); Object sessionManager = instance.getClass().getDeclaredMethod("getSessionManager").invoke(instance); - Object player = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", Player.class).invoke(null, p); + Class bukkitAdapter = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter"); + Object world = bukkitAdapter.getDeclaredMethod("adapt", World.class).invoke(null, p.getWorld()); + Object player = bukkitAdapter.getDeclaredMethod("adapt", Player.class).invoke(null, p); Object localSession = sessionManager.getClass().getDeclaredMethod("getIfPresent", Class.forName("com.sk89q.worldedit.session.SessionOwner")).invoke(sessionManager, player); - Object world = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", World.class).invoke(null, p.getWorld()); - Object region = localSession.getClass().getDeclaredMethod("getSelection", world.getClass()).invoke(localSession, world); + if (localSession == null) return null; + + Object region = null; + try { + region = localSession.getClass().getDeclaredMethod("getSelection", Class.forName("com.sk89q.worldedit.world.World")).invoke(localSession, world); + } catch (InvocationTargetException ignored) {} + if (region == null) return null; + Object min = region.getClass().getDeclaredMethod("getMinimumPoint").invoke(region); Object max = region.getClass().getDeclaredMethod("getMaximumPoint").invoke(region); return new Cuboid(p.getWorld(), - (int) min.getClass().getDeclaredMethod("getX").invoke(min), - (int) min.getClass().getDeclaredMethod("getY").invoke(min), - (int) min.getClass().getDeclaredMethod("getZ").invoke(min), - (int) min.getClass().getDeclaredMethod("getX").invoke(max), - (int) min.getClass().getDeclaredMethod("getY").invoke(max), - (int) min.getClass().getDeclaredMethod("getZ").invoke(max) + (int) min.getClass().getDeclaredMethod("x").invoke(min), + (int) min.getClass().getDeclaredMethod("y").invoke(min), + (int) min.getClass().getDeclaredMethod("z").invoke(min), + (int) min.getClass().getDeclaredMethod("x").invoke(max), + (int) min.getClass().getDeclaredMethod("y").invoke(max), + (int) min.getClass().getDeclaredMethod("z").invoke(max) ); - } catch (Throwable ignored) { - + } catch (Throwable e) { + Iris.error("Could not get selection"); + e.printStackTrace(); + active.reset(); + active.aquire(() -> false); } return null; } public static boolean hasWorldEdit() { - if (enabled == null) - enabled = Bukkit.getPluginManager().isPluginEnabled("WorldEdit"); - return enabled; + return active.aquire(() -> Bukkit.getPluginManager().isPluginEnabled("WorldEdit")); } } From e31d39c5f795696f9e25c14dbd860d97aa853116 Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Tue, 9 Jul 2024 16:19:56 +0200 Subject: [PATCH 2/7] fix worldedit selection not updating --- core/src/main/java/com/volmit/iris/core/service/WandSVC.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/core/service/WandSVC.java b/core/src/main/java/com/volmit/iris/core/service/WandSVC.java index e71392c89..559d3629f 100644 --- a/core/src/main/java/com/volmit/iris/core/service/WandSVC.java +++ b/core/src/main/java/com/volmit/iris/core/service/WandSVC.java @@ -318,7 +318,7 @@ public class WandSVC implements IrisService { Vector gx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65); d[0].getWorld().spawnParticle(CRIT_MAGIC, d[0], 1, 0.5 + gx.getX(), 0.5 + gx.getY(), 0.5 + gx.getZ(), 0, null, false); Vector gxx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65); - d[1].getWorld().spawnParticle(Particle.CRIT, d[1], 1, 0.5 + gxx.getX(), 0.5 + gxx.getY(), 0.5 + gxx.getZ(), 0, null, false); + d[1].getWorld().spawnParticle(CRIT_MAGIC, d[1], 1, 0.5 + gxx.getX(), 0.5 + gxx.getY(), 0.5 + gxx.getZ(), 0, null, false); if (!d[0].getWorld().equals(d[1].getWorld())) { return; @@ -388,7 +388,7 @@ public class WandSVC implements IrisService { if (e.getHand() != EquipmentSlot.HAND) return; try { - if (isHoldingWand(e.getPlayer())) { + if (isHoldingIrisWand(e.getPlayer())) { if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) { e.setCancelled(true); e.getPlayer().getInventory().setItemInMainHand(update(true, Objects.requireNonNull(e.getClickedBlock()).getLocation(), e.getPlayer().getInventory().getItemInMainHand())); From 84ce7372c329c61df53b0438fc33a39fcc48cae9 Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Tue, 9 Jul 2024 16:23:32 +0200 Subject: [PATCH 3/7] implement dimension zoom options --- core/src/main/java/com/volmit/iris/engine/IrisComplex.java | 7 +++++++ .../java/com/volmit/iris/engine/object/IrisDecorator.java | 2 ++ .../java/com/volmit/iris/engine/object/IrisDimension.java | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/volmit/iris/engine/IrisComplex.java b/core/src/main/java/com/volmit/iris/engine/IrisComplex.java index 3b271951f..cc3dc996e 100644 --- a/core/src/main/java/com/volmit/iris/engine/IrisComplex.java +++ b/core/src/main/java/com/volmit/iris/engine/IrisComplex.java @@ -124,6 +124,7 @@ public class IrisComplex implements DataProvider { ProceduralStream.of((x, z) -> focusRegion, Interpolated.of(a -> 0D, a -> focusRegion)) : regionStyleStream + .zoom(engine.getDimension().getRegionZoom()) .selectRarity(data.getRegionLoader().loadAll(engine.getDimension().getRegions())) .cache2D("regionStream", engine, cacheSize).waste("Region Stream"); regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i), @@ -131,6 +132,7 @@ public class IrisComplex implements DataProvider { caveBiomeStream = regionStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z)) .convert((r) -> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream() + .zoom(engine.getDimension().getBiomeZoom()) .zoom(r.getCaveBiomeZoom()) .selectRarity(data.getBiomeLoader().loadAll(r.getCaveBiomes())) .onNull(emptyBiome) @@ -139,6 +141,8 @@ public class IrisComplex implements DataProvider { landBiomeStream = regionStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z)) .convert((r) -> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream() + .zoom(engine.getDimension().getBiomeZoom()) + .zoom(engine.getDimension().getLandZoom()) .zoom(r.getLandBiomeZoom()) .selectRarity(data.getBiomeLoader().loadAll(r.getLandBiomes(), (t) -> t.setInferredType(InferredType.LAND))) ).convertAware2D(ProceduralStream::get) @@ -147,6 +151,8 @@ public class IrisComplex implements DataProvider { seaBiomeStream = regionStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z)) .convert((r) -> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream() + .zoom(engine.getDimension().getBiomeZoom()) + .zoom(engine.getDimension().getSeaZoom()) .zoom(r.getSeaBiomeZoom()) .selectRarity(data.getBiomeLoader().loadAll(r.getSeaBiomes(), (t) -> t.setInferredType(InferredType.SEA))) ).convertAware2D(ProceduralStream::get) @@ -155,6 +161,7 @@ public class IrisComplex implements DataProvider { shoreBiomeStream = regionStream.contextInjecting((c, x, z) -> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z)) .convert((r) -> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream() + .zoom(engine.getDimension().getBiomeZoom()) .zoom(r.getShoreBiomeZoom()) .selectRarity(data.getBiomeLoader().loadAll(r.getShoreBiomes(), (t) -> t.setInferredType(InferredType.SHORE))) ).convertAware2D(ProceduralStream::get).cache2D("shoreBiomeStream", engine, cacheSize).waste("Shore Biome Stream"); diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java b/core/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java index 50f8e112d..8bdd2ec91 100644 --- a/core/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java @@ -55,6 +55,8 @@ public class IrisDecorator { @ArrayType(min = 1, type = IrisBlockData.class) @Desc("When set, the decorator will never place onto any of these blocks.") private KList blacklist; + @Desc("The slope at which this decorator can be placed. Range from 0 to 10 by default. Calculated from a 3-block radius from the center of the decorator placement.") + private IrisSlopeClip slopeCondition = new IrisSlopeClip(); @DependsOn({"scaleStack", "stackMin", "stackMax"}) @Desc("If stackMax is set to true, use this to limit its max height for large caverns") private int absoluteMaxStack = 30; diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisDimension.java b/core/src/main/java/com/volmit/iris/engine/object/IrisDimension.java index fafeb768d..7206b2a3d 100644 --- a/core/src/main/java/com/volmit/iris/engine/object/IrisDimension.java +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisDimension.java @@ -244,7 +244,7 @@ public class IrisDimension extends IrisRegistrant { @MinNumber(0.0001) @MaxNumber(512) @Desc("Zoom in or out the biome size. Higher = bigger biomes") - private double biomeZoom = 5D; + private double biomeZoom = 1D; @MinNumber(0) @MaxNumber(360) @Desc("You can rotate the input coordinates by an angle. This can make terrain appear more natural (less sharp corners and lines). This literally rotates the entire dimension by an angle. Hint: Try 12 degrees or something not on a 90 or 45 degree angle.") From af80f882dab36580714df5fd7126987c1707ff51 Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Tue, 9 Jul 2024 16:25:07 +0200 Subject: [PATCH 4/7] add slope condition to sear/shore/surface decorators --- .../volmit/iris/engine/decorator/IrisSeaFloorDecorator.java | 4 ++++ .../volmit/iris/engine/decorator/IrisShoreLineDecorator.java | 5 +++++ .../volmit/iris/engine/decorator/IrisSurfaceDecorator.java | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/core/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java b/core/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java index dc3ac48c5..545078ad3 100644 --- a/core/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java +++ b/core/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java @@ -39,6 +39,10 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator { if (decorator != null) { if (!decorator.isStacking()) { + if (!decorator.isForcePlace() && !decorator.getSlopeCondition().isDefault() + && !decorator.getSlopeCondition().isValid(getComplex().getSlopeStream().get(realX, realZ))) { + return; + } if (height >= 0 || height < getEngine().getHeight()) { if (null != decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())) { data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); diff --git a/core/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java b/core/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java index bd8bb2ef2..6585f0a40 100644 --- a/core/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java +++ b/core/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java @@ -45,6 +45,11 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator { IrisDecorator decorator = getDecorator(biome, realX, realZ); if (decorator != null) { + if (!decorator.isForcePlace() && !decorator.getSlopeCondition().isDefault() + && !decorator.getSlopeCondition().isValid(getComplex().getSlopeStream().get(realX, realZ))) { + return; + } + if (!decorator.isStacking()) { if (null != decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())) { data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); diff --git a/core/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java b/core/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java index fce2e413c..49e636220 100644 --- a/core/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java +++ b/core/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java @@ -53,6 +53,11 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator { boolean underwater = height < getDimension().getFluidHeight(); if (decorator != null) { + if (!decorator.isForcePlace() && !decorator.getSlopeCondition().isDefault() + && !decorator.getSlopeCondition().isValid(getComplex().getSlopeStream().get(realX, realZ))) { + return; + } + if (!decorator.isStacking()) { bd = decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()); From f8f0a65f0af9e8c8d9449e08c720690bd6559be3 Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Sun, 21 Jul 2024 15:25:31 +0200 Subject: [PATCH 5/7] add debug info to the updater --- .../iris/core/commands/CommandDeveloper.java | 13 +- .../iris/core/commands/CommandUpdater.java | 4 +- .../volmit/iris/engine/framework/Engine.java | 143 +++++++++--------- 3 files changed, 76 insertions(+), 84 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/core/commands/CommandDeveloper.java b/core/src/main/java/com/volmit/iris/core/commands/CommandDeveloper.java index 9439d29d6..da46c93f4 100644 --- a/core/src/main/java/com/volmit/iris/core/commands/CommandDeveloper.java +++ b/core/src/main/java/com/volmit/iris/core/commands/CommandDeveloper.java @@ -74,6 +74,7 @@ import java.util.zip.GZIPOutputStream; @Decree(name = "Developer", origin = DecreeOrigin.BOTH, description = "Iris World Manager", aliases = {"dev"}) public class CommandDeveloper implements DecreeExecutor { private CommandTurboPregen turboPregen; + private CommandUpdater updater; @Decree(description = "Get Loaded TectonicPlates Count", origin = DecreeOrigin.BOTH, sync = true) public void EngineStatus() { @@ -165,18 +166,6 @@ public class CommandDeveloper implements DecreeExecutor { sender().sendMessage(C.GREEN + "Done upgrading! You can now update your server version to " + version.getVersion()); } - @Decree(description = "Test") - public void updater( - @Param(description = "Updater for chunks") - World world - ) { - Iris.info("test"); - ChunkUpdater updater = new ChunkUpdater(world); - updater.start(); - - - } - @Decree(description = "test") public void mca ( @Param(description = "String") String world) { diff --git a/core/src/main/java/com/volmit/iris/core/commands/CommandUpdater.java b/core/src/main/java/com/volmit/iris/core/commands/CommandUpdater.java index cb1ff6eeb..bd910ad5d 100644 --- a/core/src/main/java/com/volmit/iris/core/commands/CommandUpdater.java +++ b/core/src/main/java/com/volmit/iris/core/commands/CommandUpdater.java @@ -30,13 +30,13 @@ import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.Form; -@Decree(name = "Updater", origin = DecreeOrigin.BOTH, description = "Iris World Updater") +@Decree(name = "updater", origin = DecreeOrigin.BOTH, description = "Iris World Updater") public class CommandUpdater implements DecreeExecutor { private ChunkUpdater chunkUpdater; @Decree(description = "Updates all chunk in the specified world") public void start( - @Param(description = "World to update chunks at") + @Param(description = "World to update chunks at", contextual = true) World world ) { if (!IrisToolbelt.isIrisWorld(world)) { diff --git a/core/src/main/java/com/volmit/iris/engine/framework/Engine.java b/core/src/main/java/com/volmit/iris/engine/framework/Engine.java index e1f6560dc..13e1d2b6a 100644 --- a/core/src/main/java/com/volmit/iris/engine/framework/Engine.java +++ b/core/src/main/java/com/volmit/iris/engine/framework/Engine.java @@ -269,77 +269,80 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat @ChunkCoordinates @Override default void updateChunk(Chunk c) { - if (c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() + 1) - && c.getWorld().isChunkLoaded(c.getX(), c.getZ() + 1) - && c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ()) - && c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() - 1) - && c.getWorld().isChunkLoaded(c.getX(), c.getZ() - 1) - && c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ()) - && c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() - 1) - && c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() + 1) && getMantle().getMantle().isLoaded(c)) { - - getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.TILE, () -> J.s(() -> { - getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), TileWrapper.class, (x, y, z, tile) -> { - int betterY = y + getWorld().minHeight(); - if (!TileData.setTileState(c.getBlock(x, betterY, z), tile.getData())) - Iris.warn("Failed to set tile entity data at [%d %d %d | %s] for tile %s!", x, betterY, z, c.getBlock(x, betterY, z).getBlockData().getMaterial().getKey(), tile.getData().getTileId()); - }); - })); - getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.CUSTOM, () -> J.s(() -> { - getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), Identifier.class, (x, y, z, v) -> { - Iris.service(ExternalDataSVC.class).processUpdate(this, c.getBlock(x & 15, y + getWorld().minHeight(), z & 15), v); - }); - })); - - getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.UPDATE, () -> J.s(() -> { - PrecisionStopwatch p = PrecisionStopwatch.start(); - KMap updates = new KMap<>(); - RNG r = new RNG(Cache.key(c.getX(), c.getZ())); - getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x, yf, z, v) -> { - int y = yf + getWorld().minHeight(); - if (!B.isFluid(c.getBlock(x & 15, y, z & 15).getBlockData())) { - return; - } - boolean u = false; - if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.DOWN).getBlockData())) { - u = true; - } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.WEST).getBlockData())) { - u = true; - } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.EAST).getBlockData())) { - u = true; - } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.SOUTH).getBlockData())) { - u = true; - } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.NORTH).getBlockData())) { - u = true; - } - - if (u) { - updates.compute(Cache.key(x & 15, z & 15), (k, vv) -> { - if (vv != null) { - return Math.max(vv, y); - } - - return y; - }); - } - }); - - updates.forEach((k, v) -> update(Cache.keyX(k), v, Cache.keyZ(k), c, r)); - getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterUpdate.class, (x, yf, z, v) -> { - int y = yf + getWorld().minHeight(); - if (v != null && v.isUpdate()) { - int vx = x & 15; - int vz = z & 15; - update(x, y, z, c, new RNG(Cache.key(c.getX(), c.getZ()))); - if (vx > 0 && vx < 15 && vz > 0 && vz < 15) { - updateLighting(x, y, z, c); - } - } - }); - getMantle().getMantle().deleteChunkSlice(c.getX(), c.getZ(), MatterUpdate.class); - getMetrics().getUpdates().put(p.getMilliseconds()); - }, RNG.r.i(0, 20))); + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + if (c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z)) + continue; + Iris.debug("Chunk %s, %s [%s, %s] is not loaded".formatted(c.getX() + x, c.getZ() + z, x, z)); + return; + } } + if (!getMantle().getMantle().isLoaded(c)) { + Iris.debug("Mantle Chunk " + c.getX() + c.getX() + " is not loaded"); + return; + } + + getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.TILE, () -> J.s(() -> { + getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), TileWrapper.class, (x, y, z, tile) -> { + int betterY = y + getWorld().minHeight(); + if (!TileData.setTileState(c.getBlock(x, betterY, z), tile.getData())) + Iris.warn("Failed to set tile entity data at [%d %d %d | %s] for tile %s!", x, betterY, z, c.getBlock(x, betterY, z).getBlockData().getMaterial().getKey(), tile.getData().getTileId()); + }); + })); + getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.CUSTOM, () -> J.s(() -> { + getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), Identifier.class, (x, y, z, v) -> { + Iris.service(ExternalDataSVC.class).processUpdate(this, c.getBlock(x & 15, y + getWorld().minHeight(), z & 15), v); + }); + })); + + getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.UPDATE, () -> J.s(() -> { + PrecisionStopwatch p = PrecisionStopwatch.start(); + KMap updates = new KMap<>(); + RNG r = new RNG(Cache.key(c.getX(), c.getZ())); + getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x, yf, z, v) -> { + int y = yf + getWorld().minHeight(); + if (!B.isFluid(c.getBlock(x & 15, y, z & 15).getBlockData())) { + return; + } + boolean u = false; + if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.DOWN).getBlockData())) { + u = true; + } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.WEST).getBlockData())) { + u = true; + } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.EAST).getBlockData())) { + u = true; + } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.SOUTH).getBlockData())) { + u = true; + } else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.NORTH).getBlockData())) { + u = true; + } + + if (u) { + updates.compute(Cache.key(x & 15, z & 15), (k, vv) -> { + if (vv != null) { + return Math.max(vv, y); + } + + return y; + }); + } + }); + + updates.forEach((k, v) -> update(Cache.keyX(k), v, Cache.keyZ(k), c, r)); + getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterUpdate.class, (x, yf, z, v) -> { + int y = yf + getWorld().minHeight(); + if (v != null && v.isUpdate()) { + int vx = x & 15; + int vz = z & 15; + update(x, y, z, c, new RNG(Cache.key(c.getX(), c.getZ()))); + if (vx > 0 && vx < 15 && vz > 0 && vz < 15) { + updateLighting(x, y, z, c); + } + } + }); + getMantle().getMantle().deleteChunkSlice(c.getX(), c.getZ(), MatterUpdate.class); + getMetrics().getUpdates().put(p.getMilliseconds()); + }, RNG.r.i(0, 20))); } @BlockCoordinates From 89e754245ddfa347a1b528847c98e137e0bc40a8 Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Sun, 21 Jul 2024 16:00:02 +0200 Subject: [PATCH 6/7] add maxTries to IrisLootTable to prevent crash --- .../java/com/volmit/iris/engine/object/IrisLootTable.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java b/core/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java index 089ec86fd..38964c72a 100644 --- a/core/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisLootTable.java @@ -59,6 +59,10 @@ public class IrisLootTable extends IrisRegistrant { @Desc("The minimum amount of loot that can be picked in this table at a time.") private int minPicked = 1; + @MinNumber(1) + @Desc("The maximum amount of tries to generate loot") + private int maxTries = 10; + @Desc("The loot in this table") @ArrayType(min = 1, type = IrisLoot.class) private KList loot = new KList<>(); @@ -67,9 +71,10 @@ public class IrisLootTable extends IrisRegistrant { KList lootf = new KList<>(); int m = 0; + int c = 0; int mx = rng.i(getMinPicked(), getMaxPicked()); - while (m < mx) { + while (m < mx && c++ < getMaxTries()) { int num = rng.i(loot.size()); IrisLoot l = loot.get(num); From 6d104a2d1c7429cf7beaf95b6810e11aea1d1f5d Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Tue, 23 Jul 2024 20:05:05 +0200 Subject: [PATCH 7/7] fix y-coordinate for getting biome --- core/src/main/java/com/volmit/iris/core/service/TreeSVC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/volmit/iris/core/service/TreeSVC.java b/core/src/main/java/com/volmit/iris/core/service/TreeSVC.java index edbf05993..72b5593c4 100644 --- a/core/src/main/java/com/volmit/iris/core/service/TreeSVC.java +++ b/core/src/main/java/com/volmit/iris/core/service/TreeSVC.java @@ -240,7 +240,7 @@ public class TreeSVC implements IrisService { boolean isUseAll = worldAccess.getEngine().getDimension().getTreeSettings().getMode().equals(IrisTreeModes.ALL); // Retrieve objectPlacements of type `species` from biome - IrisBiome biome = worldAccess.getEngine().getBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + IrisBiome biome = worldAccess.getEngine().getBiome(location.getBlockX(), location.getBlockY()-worldAccess.getTarget().getWorld().minHeight(), location.getBlockZ()); placements.addAll(matchObjectPlacements(biome.getObjects(), size, type)); // Add more or find any in the region