mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Drop Mantle.isCarved and MantleCaverns
The module mantles no longer answer isCarved, so MantleCaverns, which only served it, goes. Tests read the carved layer.
This commit is contained in:
1 parent
db4972b42a
commit
699ad3f6fe
5 files changed
+1
-100
No files matched your search
@@ -121,11 +121,6 @@ final class IrisModuleMantle implements Mantle {
|
||||
return carvedReadOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
return new MantleCaverns(bounds, chunks).isCarved(x, y, z);
|
||||
}
|
||||
|
||||
/** Stored as the biome pass reads it: the platform's id for the biome, as a custom biome inject. */
|
||||
@Override
|
||||
public void setPlatformBiome(int x, int y, int z, ResourceId biome) {
|
||||
@@ -289,12 +284,6 @@ final class IrisModuleMantle implements Mantle {
|
||||
return carvedForEdit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
requireOpen();
|
||||
return new MantleCaverns(bounds, chunks).isCarved(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MantleEdit edit() {
|
||||
throw new UnsupportedOperationException("Mantle edits cannot be nested; write through this edit");
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 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.core.modules;
|
||||
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import com.volmit.geometry.BlockBox;
|
||||
|
||||
/**
|
||||
* The voids Iris's mantle holds for chunks to take over, IrisApi's {@link com.volmit.mantle.Mantle#isCarved}: where the
|
||||
* cave planner marked a cavern in the mantle's cavern slice, whatever the cavern holds (air, fluid, lava).
|
||||
*/
|
||||
final class MantleCaverns {
|
||||
private static final int CHUNK_SHIFT = 4;
|
||||
private static final int SECTION_SHIFT = 4;
|
||||
private static final int LOCAL_MASK = 15;
|
||||
|
||||
private final BlockBox bounds;
|
||||
private final IrisModuleMantle.Chunks chunks;
|
||||
|
||||
MantleCaverns(BlockBox bounds, IrisModuleMantle.Chunks chunks) {
|
||||
this.bounds = bounds;
|
||||
this.chunks = chunks;
|
||||
}
|
||||
|
||||
boolean isCarved(int x, int y, int z) {
|
||||
requireInside(x, y, z);
|
||||
return cavernAt(requireChunk(x >> CHUNK_SHIFT, z >> CHUNK_SHIFT), x, y, z);
|
||||
}
|
||||
|
||||
private static boolean cavernAt(MantleChunk<Matter> chunk, int x, int y, int z) {
|
||||
int section = y >> SECTION_SHIFT;
|
||||
if (!chunk.exists(section)) {
|
||||
return false;
|
||||
}
|
||||
Matter matter = chunk.get(section);
|
||||
if (matter == null || !matter.hasSlice(MatterCavern.class)) {
|
||||
return false;
|
||||
}
|
||||
return matter.<MatterCavern>getSlice(MatterCavern.class).get(x & LOCAL_MASK, y & LOCAL_MASK, z & LOCAL_MASK) != null;
|
||||
}
|
||||
|
||||
private MantleChunk<Matter> requireChunk(int chunkX, int chunkZ) {
|
||||
MantleChunk<Matter> chunk = chunks.chunk(chunkX, chunkZ);
|
||||
if (chunk == null) {
|
||||
throw new IllegalStateException("Mantle chunk " + chunkX + ", " + chunkZ + " is inside " + bounds + " but was not prepared");
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
private void requireInside(int x, int y, int z) {
|
||||
if (!bounds.contains(x, y, z)) {
|
||||
throw new IndexOutOfBoundsException("Block " + x + ", " + y + ", " + z + " is outside the mantle this invocation prepared, " + bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,14 +78,6 @@ final class PlacementMantle implements Mantle, AutoCloseable {
|
||||
return new StoredRange<>(placement.carved());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
if (!bounds.contains(x, y, z)) {
|
||||
throw new IndexOutOfBoundsException("Block " + x + ", " + y + ", " + z + " is outside the placement area " + bounds);
|
||||
}
|
||||
return y >= storedBounds.minY() && y < storedBounds.maxY() && placement.isCarved(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MantleEdit edit() {
|
||||
throw new UnsupportedOperationException("The placement owns the mantle edit; write through layer()");
|
||||
|
||||
@@ -169,8 +169,6 @@ public class IrisModuleMantleTest {
|
||||
assertSame(CarvedVoid.LAVA, mantle.carved().get(6, 40, 5));
|
||||
assertSame(CarvedVoid.AIR, mantle.carved().get(7, 40, 5));
|
||||
assertNull(mantle.carved().get(8, 40, 5));
|
||||
assertTrue(mantle.isCarved(5, 40, 5));
|
||||
assertFalse(mantle.isCarved(8, 40, 5));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -203,7 +201,7 @@ public class IrisModuleMantleTest {
|
||||
assertNull(mantle.carved().get(-2, 9, 3));
|
||||
assertSame(CarvedVoid.LAVA, mantle.carved().get(17, 5, 3));
|
||||
mantle.carved().remove(17, 5, 3);
|
||||
assertFalse(mantle.isCarved(17, 5, 3));
|
||||
assertNull(mantle.carved().get(17, 5, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -537,11 +537,6 @@ public final class ApiChunk implements GenerationContext {
|
||||
return new CarvedLayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
return carved.contains(new BlockPosition(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MantleEdit edit() {
|
||||
throw new UnsupportedOperationException("Chunk stages do not edit the mantle");
|
||||
|
||||
Reference in new issue
Block a user