Keep custom leaves from decaying and from cutting logs

- Implement the log and leaves checks added in https://github.com/VolmitSoftware/VolmLib/pull/4 so master compiles against the current VolmLib again
- Let external providers make a block persistent and report block tags
- Make CraftEngine leaves with a persistent property keep their leaves when decay is prevented
- Count CraftEngine blocks with the logs and leaves tags as logs and leaves
- Skip leaf placements that would replace a log another object placed
- Make object placement persist leaves by their persistent property, not their distance property
This commit is contained in:
piexel committed 2026-11-23 23:31:03 +01:00
1 parent 435ed10648
commit 1e04f61957
22 files changed
+402 -10

No files matched your search

@@ -208,6 +208,16 @@ public class IrisDepositModifierOrderingTest {
return false;
}
@Override
public boolean isLog() {
return false;
}
@Override
public boolean isLeaves() {
return false;
}
@Override
public boolean isFoliagePlantable() {
return false;
@@ -466,6 +466,16 @@ public class IrisDepositModifierParityTest {
return false;
}
@Override
public boolean isLog() {
return false;
}
@Override
public boolean isLeaves() {
return false;
}
@Override
public boolean isFoliagePlantable() {
return false;
@@ -339,6 +339,16 @@ public class IrisPerfectionModifierColumnTest {
return false;
}
@Override
public boolean isLog() {
return false;
}
@Override
public boolean isLeaves() {
return false;
}
@Override
public boolean isFoliagePlantable() {
return false;
@@ -252,6 +252,16 @@ final class CompatFixtures {
return false;
}
@Override
public boolean isLog() {
return false;
}
@Override
public boolean isLeaves() {
return false;
}
@Override
public boolean isFoliagePlantable() {
return false;
@@ -119,8 +119,12 @@ public class BukkitPersistedBlockStateTest {
IrisCustomData custom = IrisCustomData.of(carrier, Identifier.fromString(key));
ExternalDataSVC provider = mock(ExternalDataSVC.class);
when(provider.getBlockData(Identifier.fromString(key))).thenReturn(Optional.of(custom));
try (MockedStatic<IrisServices> services = mockStatic(IrisServices.class)) {
when(provider.withoutDecay(custom)).thenReturn(custom);
IrisSettings configuration = new IrisSettings();
try (MockedStatic<IrisServices> services = mockStatic(IrisServices.class);
MockedStatic<IrisSettings> settings = mockStatic(IrisSettings.class)) {
services.when(() -> IrisServices.get(ExternalDataSVC.class)).thenReturn(provider);
settings.when(IrisSettings::get).thenReturn(configuration);
NativeBlockState decoded = registries.decodeBlockState(key);
assertEquals(key, decoded.key());
assertEquals(key, decoded.deferredPlacementKey());
@@ -172,6 +172,16 @@ public class IrisObjectTransformsNearestBlockIndexTest {
return false;
}
@Override
public boolean isLog() {
return false;
}
@Override
public boolean isLeaves() {
return false;
}
@Override
public boolean isFoliagePlantable() {
return false;
@@ -0,0 +1,92 @@
package art.arcane.iris.structure.object;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ObjectLeafAndLogRulesTest {
@Test
public void leavesNeverCutALog() {
assertTrue(ObjectBlockPass.keepsExisting(leaves(), log()));
}
@Test
public void leavesReplaceOtherLeavesAndAir() {
assertFalse(ObjectBlockPass.keepsExisting(leaves(), leaves()));
assertFalse(ObjectBlockPass.keepsExisting(leaves(), null));
}
@Test
public void logsStillReplaceLeaves() {
assertFalse(ObjectBlockPass.keepsExisting(log(), leaves()));
}
@Test
public void vinesStillKeepSolidBlocks() {
NativeBlockState vine = mock(NativeBlockState.class);
when(vine.isVineBlock()).thenReturn(true);
NativeBlockState solid = mock(NativeBlockState.class);
when(solid.isSolid()).thenReturn(true);
assertTrue(ObjectBlockPass.keepsExisting(vine, solid));
assertFalse(ObjectBlockPass.keepsExisting(vine, leaves()));
}
@Test
public void customLeavesLosingTheirDecayAreMadePersistent() {
NativeBlockState persistent = mock(NativeBlockState.class);
NativeBlockState decaying = mock(NativeBlockState.class);
when(decaying.key()).thenReturn("craftengine:test/leaves[persistent=false,distance=7]");
when(decaying.withProperty("persistent", "true")).thenReturn(persistent);
assertSame(persistent, paletteOf(true, decaying).decayed(0));
}
@Test
public void customLeavesWithoutADistanceAreMadePersistentToo() {
NativeBlockState persistent = mock(NativeBlockState.class);
NativeBlockState decaying = mock(NativeBlockState.class);
when(decaying.key()).thenReturn("craftengine:test/leaves[persistent=false]");
when(decaying.withProperty("persistent", "true")).thenReturn(persistent);
assertSame(persistent, paletteOf(true, decaying).decayed(0));
}
@Test
public void decayIsLeftAloneWhenItIsNotPrevented() {
NativeBlockState decaying = mock(NativeBlockState.class);
when(decaying.key()).thenReturn("minecraft:oak_leaves[distance=3,persistent=false]");
assertSame(decaying, paletteOf(false, decaying).decayed(0));
}
@Test
public void blocksWithoutAPersistentPropertyAreLeftAlone() {
NativeBlockState stone = mock(NativeBlockState.class);
when(stone.key()).thenReturn("minecraft:stone");
assertSame(stone, paletteOf(true, stone).decayed(0));
}
private static PlacementPalette paletteOf(boolean preventingDecay, NativeBlockState state) {
return new PlacementPalette(new NativeBlockState[]{state}, new IrisObjectRotation(), 0, 0, 0,
preventingDecay, false, java.util.Set.of());
}
private static NativeBlockState leaves() {
NativeBlockState state = mock(NativeBlockState.class);
when(state.isLeaves()).thenReturn(true);
return state;
}
private static NativeBlockState log() {
NativeBlockState state = mock(NativeBlockState.class);
when(state.isLog()).thenReturn(true);
return state;
}
}
@@ -583,7 +583,17 @@ public class ObjectPlacementGoldenTest {
@Override
public boolean isTreeBlock() {
return material.endsWith("_log") || material.endsWith("_leaves");
return isLog() || isLeaves();
}
@Override
public boolean isLog() {
return material.endsWith("_log");
}
@Override
public boolean isLeaves() {
return material.endsWith("_leaves");
}
@Override
@@ -183,6 +183,16 @@ public class TreePlausibilizerTest {
return false;
}
@Override
public boolean isLog() {
return false;
}
@Override
public boolean isLeaves() {
return false;
}
@Override
public boolean isFoliagePlantable() {
return false;
@@ -89,6 +89,16 @@ public final class KeyedBlockState implements NativeBlockState {
return false;
}
@Override
public boolean isLog() {
return false;
}
@Override
public boolean isLeaves() {
return false;
}
@Override
public boolean isFoliagePlantable() {
return false;
@@ -136,6 +136,16 @@ public final class PlantBlockState implements NativeBlockState {
return false;
}
@Override
public boolean isLog() {
return false;
}
@Override
public boolean isLeaves() {
return false;
}
@Override
public boolean isFoliagePlantable() {
return false;