mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 01:04:29 +00:00
Generate CraftEngine blocks in place, keep their leaves and tags
Ported from v3e (31615dc05,ee7f54429, 92b02db15, 3ba277aa4). CraftEngine blocks now resolve to their own block data and generate with the chunk, warning once about properties the block does not have, so only furniture is placed after generation. A deferred block with a state finds its provider by its id alone. Where leaf decay is prevented, CraftEngine leaves are made persistent too, and logs and leaves include CraftEngine blocks with those tags, for IrisModule501862b.
This commit is contained in:
1 parent
6522174c83
commit
6429b6ea5e
7 files changed
+164
-27
No files matched your search
@@ -0,0 +1,21 @@
|
||||
package art.arcane.iris.core.service;
|
||||
|
||||
import art.arcane.iris.core.link.Identifier;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ExternalDataSVCStateTest {
|
||||
@Test
|
||||
public void aDeferredBlockFindsItsProviderByTheIdWithoutItsState() {
|
||||
assertEquals(new Identifier("craftengine", "chair"),
|
||||
ExternalDataSVC.withoutState(new Identifier("craftengine", "chair[yaw=90,randomPitch=true]")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anIdWithoutStateStaysAsItIs() {
|
||||
Identifier chair = new Identifier("craftengine", "chair");
|
||||
|
||||
assertEquals(chair, ExternalDataSVC.withoutState(chair));
|
||||
}
|
||||
}
|
||||
+22
@@ -71,6 +71,7 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@@ -95,6 +96,7 @@ public class ObjectPlacementRegressionTest {
|
||||
IrisPlatforms.unbind();
|
||||
PlatformRegistries registries = mock(PlatformRegistries.class);
|
||||
when(registries.block(anyString())).thenAnswer(invocation -> registryState(invocation.getArgument(0)));
|
||||
when(registries.blockOrNull(anyString(), anyBoolean())).thenAnswer(invocation -> registryState(invocation.getArgument(0)));
|
||||
IrisPlatform platform = mock(IrisPlatform.class);
|
||||
when(platform.registries()).thenReturn(registries);
|
||||
IrisPlatforms.bind(platform);
|
||||
@@ -210,6 +212,23 @@ public class ObjectPlacementRegressionTest {
|
||||
assertTrue(placer.sampledColumns().size() >= 25);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void leavesNeverCutALogAnotherObjectPlaced() {
|
||||
PlatformBlockState log = registryState("minecraft:oak_log");
|
||||
PlatformBlockState leaves = registryState("minecraft:oak_leaves");
|
||||
RecordingPlacer placer = new RecordingPlacer(null);
|
||||
IrisObject trunk = new IrisObject(1, 1, 1);
|
||||
trunk.setUnsigned(0, 0, 0, log);
|
||||
IrisObject canopy = new IrisObject(1, 1, 1);
|
||||
canopy.setUnsigned(0, 0, 0, leaves);
|
||||
|
||||
placed(trunk, 0, ANCHOR_Y, 0, placer, placement().build(), new RNG(2L), data);
|
||||
placed(canopy, 0, ANCHOR_Y, 0, placer, placement().build(), new RNG(2L), data);
|
||||
|
||||
assertEquals(1, placer.writes().size());
|
||||
assertEquals("minecraft:oak_log", placer.writes().get(0).state().key());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void snowUsesOnlyBlocksThatWereWritten() {
|
||||
RecordingPlacer placer = new RecordingPlacer(null);
|
||||
@@ -732,12 +751,15 @@ public class ObjectPlacementRegressionTest {
|
||||
return PlatformBlockStates.namespaced(builtIn.key());
|
||||
}
|
||||
|
||||
/** A platform state mock; logs and leaves are told by their key, as the platform tells them by tag. */
|
||||
private static PlatformBlockState state(String key, boolean solid) {
|
||||
PlatformBlockState state = mock(PlatformBlockState.class);
|
||||
when(state.key()).thenReturn(key);
|
||||
when(state.materialKey()).thenReturn(key);
|
||||
when(state.isSolid()).thenReturn(solid);
|
||||
when(state.isOccluding()).thenReturn(solid);
|
||||
when(state.isLog()).thenReturn(key.endsWith("_log"));
|
||||
when(state.isLeaves()).thenReturn(key.endsWith("_leaves"));
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user