Keep a pack's side faces on hanging vines where a block or vine above holds them

Decorated vines had every face cleared and reattached to sturdy neighbours, so ceiling decorators that stack vines downward made flat sheets instead of curtains. Authored side faces now stay where a sturdy block or the vine above holds them, a sturdy ceiling holds them and adds the up face, and glow lichen is still not held by lichen above.

Upstream: 6d6bd4f05 c2eb8b5f4 067fffe06
This commit is contained in:
piexel committed 2026-11-10 01:05:43 +01:00
1 parent 36fcff7caf
commit 73863e8219
3 files changed
+169 -29

No files matched your search

@@ -13,6 +13,8 @@ import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -367,6 +369,94 @@ public class DecoratorCoreTest {
assertSame(STONE, DecoratorCore.fixFacesForHunk(scene(hunk(1, 1, 1)), STONE, 0, 0, 0, 0, 0));
}
@Test
public void aCurtainHangsFromTheWallItsTopStrandFaces() {
Hunk<BlockState> output = hunk(16, 8, 16);
output.set(8, 6, 8, STONE);
output.set(8, 5, 7, STONE);
output.set(9, 4, 8, STONE);
placeCurtain(output);
assertEquals(Set.of("north", "up"), setFaces(output.get(8, 5, 8)));
assertEquals(Set.of("north"), setFaces(output.get(8, 4, 8)));
assertEquals(Set.of("north"), setFaces(output.get(8, 3, 8)));
}
@Test
public void aCurtainHangsUnderAnOpenCeiling() {
Hunk<BlockState> output = hunk(16, 8, 16);
output.set(8, 6, 8, STONE);
placeCurtain(output);
assertEquals(Set.of("north", "up"), setFaces(output.get(8, 5, 8)));
assertEquals(Set.of("north"), setFaces(output.get(8, 4, 8)));
assertEquals(Set.of("north"), setFaces(output.get(8, 3, 8)));
}
@Test
public void anAuthoredSideFaceNothingHoldsIsDroppedAndTheVineReattaches() {
Hunk<BlockState> walled = hunk(16, 8, 16);
walled.set(9, 3, 8, STONE);
assertEquals(Set.of("east"), setFaces(DecoratorCore.fixFacesForHunk(scene(walled), authoredVine("north"), 8, 8, 8, 3, 8)));
assertEquals(Set.of("up"), setFaces(DecoratorCore.fixFacesForHunk(scene(hunk(16, 8, 16)), authoredVine("north"), 8, 8, 8, 3, 8)));
}
@Test
public void anAuthoredSideFaceAWallHoldsKeepsItsDirection() {
Hunk<BlockState> output = hunk(16, 8, 16);
output.set(8, 3, 7, STONE);
output.set(9, 3, 8, STONE);
assertEquals(Set.of("north"), setFaces(DecoratorCore.fixFacesForHunk(scene(output), authoredVine("north"), 8, 8, 8, 3, 8)));
}
@Test
public void aVineWithoutAnAuthoredSideFaceReattachesToEverySturdyNeighbour() {
Hunk<BlockState> output = hunk(16, 8, 16);
output.set(7, 3, 8, STONE);
output.set(8, 3, 9, STONE);
output.set(8, 4, 8, STONE);
BlockState fixed = DecoratorCore.fixFacesForHunk(scene(output), authoredVine("up"), 8, 8, 8, 3, 8);
assertEquals(Set.of("south", "west", "up"), setFaces(fixed));
}
@Test
public void glowLichenSideFaceIsNotHeldByTheLichenAboveIt() {
BlockState lichen = BlockState.parse("minecraft:glow_lichen[down=false,east=false,north=true,south=false,up=false,west=false]");
Hunk<BlockState> output = hunk(16, 8, 16);
output.set(8, 2, 8, STONE);
output.set(8, 4, 8, lichen);
assertEquals(Set.of("down"), setFaces(DecoratorCore.fixFacesForHunk(scene(output), lichen, 8, 8, 8, 3, 8)));
}
private static void placeCurtain(Hunk<BlockState> output) {
ResolvedDecorator decorator = mock(ResolvedDecorator.class);
BlockState vine = authoredVine("north");
when(decorator.stackHeight(anyDouble(), anyDouble())).thenReturn(3);
when(decorator.topThreshold()).thenReturn(1.0);
when(decorator.pickBlock(anyDouble(), anyDouble())).thenReturn(vine);
when(decorator.pickTopBlock(anyDouble(), anyDouble())).thenReturn(vine);
DecoratorCore.placeStackDown(decorator, scene(output), 8, 8, 8, 8, 5, 0, 3, new DecoratorCore.PlaceOpts());
}
private static BlockState authoredVine(String face) {
return BlockState.parse("minecraft:vine[east=false,north=false,south=false,up=false,west=false]").withProperty(face, "true");
}
private static Set<String> setFaces(BlockState state) {
return state.properties().entrySet().stream()
.filter(property -> "true".equals(property.getValue()))
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
}
private static BlockState vine() {
return BlockState.parse("minecraft:vine[down=false,east=false,north=false,south=false,up=false,west=false]");
}
@@ -133,7 +133,7 @@ public final class ApiChunk implements GenerationContext {
private static final Set<String> FOLIAGE = Set.of("minecraft:short_grass", "minecraft:poppy", "minecraft:tall_grass",
"minecraft:fern");
private static final Set<String> SOILS = Set.of("minecraft:grass_block", "minecraft:dirt", "minecraft:sand");
private static final Set<String> VINES = Set.of("minecraft:vine");
private static final Set<String> VINES = Set.of("minecraft:vine", "minecraft:glow_lichen");
private static final Comparator<BlockPosition> VISIT_ORDER = Comparator.comparingInt(BlockPosition::x)
.thenComparingInt(BlockPosition::y).thenComparingInt(BlockPosition::z);