mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Skip floating object work for packs with no floating objects
The floating object stage widened the mantle window by at least 16 blocks and sampled every column of each chunk even when no floating biome places an object. Reach is now 0 unless a placement list has entries, with 16 as the fallback when the scan fails, and placing returns early when the reach is 0.
Upstream: 875735517
This commit is contained in:
1 parent
887daac844
commit
fd936f4dd8
3 files changed
+54
-9
No files matched your search
@@ -78,7 +78,7 @@ public class ModuleMantleComponentTest {
|
||||
assertEquals(List.of(MantleFlag.of(first), MantleFlag.of(first + 1), MantleFlag.of(first + 2), MantleFlag.of(first + 3), MantleFlag.of(first + 4)),
|
||||
components.stream().map(ModuleMantleComponent::getFlag).toList());
|
||||
assertEquals(List.of(0, 1, 2, 3, 4), components.stream().map(ModuleMantleComponent::getPriority).toList());
|
||||
assertEquals("a pack without objects or structures: caves 1, floating objects at least 16", List.of(1, 0, 16, 0, MARK_REACH),
|
||||
assertEquals("a pack without objects or structures: caves 1, no floating objects", List.of(1, 0, 0, 0, MARK_REACH),
|
||||
components.stream().map(ModuleMantleComponent::getRadius).toList());
|
||||
assertEquals("disabledComponents: [iris:carve/caves] turns the cave pass off", List.of(false, true, true, true, true),
|
||||
components.stream().map(ModuleMantleComponent::isEnabled).toList());
|
||||
|
||||
+34
@@ -38,6 +38,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -58,6 +59,39 @@ public class FloatingObjectPlacingBoundaryRadiusTest {
|
||||
assertEquals(33, FloatingObjectPlacing.reach(pack(new FloatingChildSettings(List.of(floatingChild)), resources), ModuleLogs.discarding()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void packWithoutFloatingChildrenHasNoReach() {
|
||||
assertEquals(0, FloatingObjectPlacing.reach(pack(new FloatingChildSettings(List.of()), mock(PackResources.class)), ModuleLogs.discarding()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void floatingChildWithoutObjectsHasNoReach() {
|
||||
FloatingChildBiome floatingChild = TestSettings.with(new FloatingChildBiome(), "inheritObjects", false);
|
||||
|
||||
assertEquals(0, FloatingObjectPlacing.reach(pack(new FloatingChildSettings(List.of(floatingChild)), mock(PackResources.class)), ModuleLogs.discarding()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void placementOfMissingObjectKeepsTheMinimumReach() {
|
||||
ObjectPlacement placement = TestSettings.of(ObjectPlacement.class, "{\"place\":[\"test/missing\"]}");
|
||||
FloatingChildBiome floatingChild = TestSettings.with(new FloatingChildBiome(), "extraObjects", List.of(placement));
|
||||
PackResources resources = mock(PackResources.class);
|
||||
PackObjects objects = mock(PackObjects.class);
|
||||
when(resources.objects()).thenReturn(objects);
|
||||
when(objects.sizeOf(any())).thenReturn(Optional.empty());
|
||||
|
||||
assertEquals(16, FloatingObjectPlacing.reach(pack(new FloatingChildSettings(List.of(floatingChild)), resources), ModuleLogs.discarding()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failedReachScanKeepsTheMinimumReach() {
|
||||
PackSettings failing = mock(PackSettings.class);
|
||||
when(failing.resources()).thenReturn(mock(PackResources.class));
|
||||
when(failing.declared(any())).thenThrow(new IllegalStateException("Unavailable settings"));
|
||||
|
||||
assertEquals(16, FloatingObjectPlacing.reach(failing, ModuleLogs.discarding()));
|
||||
}
|
||||
|
||||
private static PackSettings pack(FloatingChildSettings declared, PackResources resources) {
|
||||
return new PackSettings() {
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user