Delete the engine actuator and modifier base classes and follow the carve rename in the cave tests

This commit is contained in:
piexel committed 2026-10-08 13:47:00 +02:00
1 parent a319b36f2d
commit 21efc385da
8 files changed
+46 -193

No files matched your search

@@ -1,27 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.engine.framework;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.iris.util.project.hunk.Hunk;
public interface EngineActuator<O> extends EngineComponent {
@BlockCoordinates
void actuate(int x, int z, Hunk<O> output, boolean multicore, ChunkContext context);
}
@@ -1,52 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.engine.framework;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.iris.util.project.hunk.Hunk;
public abstract class EngineAssignedActuator<T> extends EngineAssignedComponent implements EngineActuator<T> {
public EngineAssignedActuator(Engine engine, String name) {
super(engine, name);
}
public abstract void onActuate(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context);
@BlockCoordinates
@Override
public void actuate(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context) {
try {
onActuate(x, z, output, multicore, context);
} catch (Throwable e) {
// Same contract as EngineAssignedModifier.modify: a failed actuator leaves a
// half-written chunk. Never continue as if it succeeded; let the chunk
// generation failure path abort the chunk instead of persisting it.
IrisLogging.error("Actuator Failure: " + getName());
IrisLogging.reportError(e);
if (e instanceof Error error) {
throw error;
}
if (e instanceof RuntimeException runtimeException) {
throw runtimeException;
}
throw new IllegalStateException("Actuator Failure: " + getName(), e);
}
}
}
@@ -1,55 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.engine.framework;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.iris.util.project.hunk.Hunk;
public abstract class EngineAssignedModifier<T> extends EngineAssignedComponent implements EngineModifier<T> {
public EngineAssignedModifier(Engine engine, String name) {
super(engine, name);
}
@BlockCoordinates
public abstract void onModify(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context);
@BlockCoordinates
@Override
public void modify(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context) {
try {
onModify(x, z, output, multicore, context);
} catch (Throwable e) {
IrisLogging.error("Modifier Failure: " + getName());
IrisLogging.reportError(e);
// A failed modifier leaves a half-written chunk. Never continue as if it succeeded,
// let the chunk generation failure path handle it.
if (e instanceof Error error) {
throw error;
}
if (e instanceof RuntimeException runtime) {
throw runtime;
}
throw new IllegalStateException("Modifier Failure: " + getName(), e);
}
}
}
@@ -1,27 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.engine.framework;
import art.arcane.iris.util.project.context.ChunkContext;
import art.arcane.volmlib.util.documentation.BlockCoordinates;
import art.arcane.iris.util.project.hunk.Hunk;
public interface EngineModifier<T> extends EngineComponent {
@BlockCoordinates
void modify(int x, int z, Hunk<T> t, boolean multicore, ChunkContext context);
}
@@ -2,7 +2,9 @@ package art.arcane.iris.engine.modifier;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.loader.ResourceLoader;
import art.arcane.iris.engine.UsableBlockPlatform;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.SeedManager;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
import art.arcane.iris.spi.PlatformBlockState;
@@ -12,6 +14,8 @@ import art.arcane.volmlib.util.matter.Matter;
import art.arcane.volmlib.util.matter.MatterCavern;
import art.arcane.volmlib.util.matter.MatterSlice;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
@@ -23,11 +27,20 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
public class IrisCarveModifierBoundarySupportTest {
public class CaveApplyingBoundarySupportTest {
@Before
public void bindPlatform() {
UsableBlockPlatform.bind();
}
@After
public void unbindPlatform() {
UsableBlockPlatform.unbind();
}
@Test
@SuppressWarnings("unchecked")
public void boundaryBiomeUsesCustomMatterAtItsOwnY() {
@@ -42,8 +55,8 @@ public class IrisCarveModifierBoundarySupportTest {
doReturn(data).when(engine).getData();
doReturn(resolvedCeiling).when(engine).getCaveBiome(anyInt(), eq(42), anyInt(), any(IrisDimensionCarvingResolver.State.class));
IrisCarveModifier modifier = mock(IrisCarveModifier.class, CALLS_REAL_METHODS);
doReturn(engine).when(modifier).getEngine();
doReturn(mock(SeedManager.class)).when(engine).getSeedManager();
CaveApplying modifier = new CaveApplying(engine);
MantleChunk<Matter> mantleChunk = mock(MantleChunk.class);
Matter floorMatter = mock(Matter.class);
@@ -84,11 +97,11 @@ public class IrisCarveModifierBoundarySupportTest {
PlatformBlockState stone = state("minecraft:stone", true);
doReturn(air).when(output).getRaw(0, 4, 0);
assertFalse(IrisCarveModifier.canReplaceCaveFloorLayer(output, 0, 5, 0, sand));
assertTrue(IrisCarveModifier.canReplaceCaveFloorLayer(output, 0, 5, 0, stone));
assertFalse(CaveApplying.canReplaceCaveFloorLayer(output, 0, 5, 0, sand));
assertTrue(CaveApplying.canReplaceCaveFloorLayer(output, 0, 5, 0, stone));
doReturn(solid).when(output).getRaw(0, 4, 0);
assertTrue(IrisCarveModifier.canReplaceCaveFloorLayer(output, 0, 5, 0, sand));
assertTrue(CaveApplying.canReplaceCaveFloorLayer(output, 0, 5, 0, sand));
}
@Test
@@ -101,10 +114,10 @@ public class IrisCarveModifierBoundarySupportTest {
doReturn(sand).when(output).getRaw(0, 5, 0);
doReturn(air).when(output).getRaw(0, 4, 0);
assertFalse(IrisCarveModifier.hasStableCaveFloorSupport(output, 0, 6, 0));
assertFalse(CaveApplying.hasStableCaveFloorSupport(output, 0, 6, 0));
doReturn(stone).when(output).getRaw(0, 4, 0);
assertTrue(IrisCarveModifier.hasStableCaveFloorSupport(output, 0, 6, 0));
assertTrue(CaveApplying.hasStableCaveFloorSupport(output, 0, 6, 0));
}
private PlatformBlockState state(String key, boolean solid) {
@@ -11,7 +11,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class IrisCarveModifierFluidIntentTest {
public class CaveApplyingFluidIntentTest {
@Test
public void explicitCavernIntentsOverrideExistingFluid() {
MatterCavern airIntent = new MatterCavern(true, "", (byte) 0);
@@ -24,24 +24,24 @@ public class IrisCarveModifierFluidIntentTest {
PlatformBlockState air = mock(PlatformBlockState.class);
when(existingFluid.isFluid()).thenReturn(true);
assertFalse(IrisCarveModifier.hasExplicitCarveIntent(null));
assertTrue(IrisCarveModifier.shouldPreserveExistingFluid(airIntent, existingFluid));
assertTrue(IrisCarveModifier.isFluidIntent(fluidIntent));
assertFalse(IrisCarveModifier.shouldPreserveExistingFluid(fluidIntent, existingFluid));
assertFalse(IrisCarveModifier.shouldPreserveExistingFluid(lavaIntent, existingFluid));
assertFalse(IrisCarveModifier.shouldPreserveExistingFluid(forcedAirIntent, existingFluid));
assertNull(IrisCarveModifier.resolveExplicitCarveState(null, fluid, lava, air));
assertSame(fluid, IrisCarveModifier.resolveExplicitCarveState(fluidIntent, fluid, lava, air));
assertSame(lava, IrisCarveModifier.resolveExplicitCarveState(lavaIntent, fluid, lava, air));
assertSame(air, IrisCarveModifier.resolveExplicitCarveState(forcedAirIntent, fluid, lava, air));
assertNull(IrisCarveModifier.resolveExplicitCarveState(airIntent, fluid, lava, air));
assertFalse(CaveApplying.hasExplicitCarveIntent(null));
assertTrue(CaveApplying.shouldPreserveExistingFluid(airIntent, existingFluid));
assertTrue(CaveApplying.isFluidIntent(fluidIntent));
assertFalse(CaveApplying.shouldPreserveExistingFluid(fluidIntent, existingFluid));
assertFalse(CaveApplying.shouldPreserveExistingFluid(lavaIntent, existingFluid));
assertFalse(CaveApplying.shouldPreserveExistingFluid(forcedAirIntent, existingFluid));
assertNull(CaveApplying.resolveExplicitCarveState(null, fluid, lava, air));
assertSame(fluid, CaveApplying.resolveExplicitCarveState(fluidIntent, fluid, lava, air));
assertSame(lava, CaveApplying.resolveExplicitCarveState(lavaIntent, fluid, lava, air));
assertSame(air, CaveApplying.resolveExplicitCarveState(forcedAirIntent, fluid, lava, air));
assertNull(CaveApplying.resolveExplicitCarveState(airIntent, fluid, lava, air));
}
@Test
public void defaultLavaIncludesConfiguredBoundary() {
assertTrue(IrisCarveModifier.usesDefaultLava(18, 17));
assertTrue(IrisCarveModifier.usesDefaultLava(18, 18));
assertFalse(IrisCarveModifier.usesDefaultLava(18, 19));
assertTrue(CaveApplying.usesDefaultLava(18, 17));
assertTrue(CaveApplying.usesDefaultLava(18, 18));
assertFalse(CaveApplying.usesDefaultLava(18, 19));
}
@Test
@@ -55,8 +55,8 @@ public class IrisCarveModifierFluidIntentTest {
when(air.isSolid()).thenReturn(false);
when(solid.isSolid()).thenReturn(true);
assertTrue(IrisCarveModifier.isUnsupportedSurfaceOre(ore, air));
assertFalse(IrisCarveModifier.isUnsupportedSurfaceOre(ore, solid));
assertFalse(IrisCarveModifier.isUnsupportedSurfaceOre(ordinarySurface, air));
assertTrue(CaveApplying.isUnsupportedSurfaceOre(ore, air));
assertFalse(CaveApplying.isUnsupportedSurfaceOre(ore, solid));
assertFalse(CaveApplying.isUnsupportedSurfaceOre(ordinarySurface, air));
}
}
@@ -3,6 +3,7 @@ package art.arcane.iris.engine.modifier;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.engine.IrisComplex;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.engine.framework.SeedManager;
import art.arcane.iris.engine.object.world.biome.InferredType;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
@@ -34,7 +35,7 @@ import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
public class IrisCarveModifierInferenceIsolationTest {
public class CaveApplyingInferenceIsolationTest {
@BeforeClass
public static void bindPlatform() {
IrisPlatforms.unbind();
@@ -63,14 +64,14 @@ public class IrisCarveModifierInferenceIsolationTest {
doReturn(mock(IrisDimension.class)).when(engine).getDimension();
doReturn(mock(IrisComplex.class)).when(engine).getComplex();
doReturn(IrisWorld.builder().minHeight(-256).maxHeight(512).build()).when(engine).getWorld();
IrisCarveModifier modifier = mock(IrisCarveModifier.class, CALLS_REAL_METHODS);
doReturn(engine).when(modifier).getEngine();
doReturn(mock(SeedManager.class)).when(engine).getSeedManager();
CaveApplying modifier = new CaveApplying(engine);
Map<String, IrisBiome> customBiomes = new HashMap<>();
customBiomes.put("shared", biome);
CarveWallBuffer walls = new CarveWallBuffer(1);
walls.put(0, 1, 0, new MatterCavern(true, "shared", (byte) 0));
Method paintBoundaryZone = IrisCarveModifier.class.getDeclaredMethod(
Method paintBoundaryZone = CaveApplying.class.getDeclaredMethod(
"paintBoundaryZone",
Hunk.class,
CarveWallBuffer.class,
@@ -11,7 +11,7 @@ import java.util.Set;
import static org.junit.Assert.assertEquals;
public class IrisCarveModifierZoneParityTest {
public class CaveApplyingZoneParityTest {
@Test
public void randomColumnZonesMatchLegacySortedResolver() {
CarveColumnMask columnMask = new CarveColumnMask();