CTM Transitions - neighbor detection and influence (#2047)

This commit is contained in:
Nick Smith authored and GitHub committed 2026-09-03 22:33:18 -07:00
1 parent 0e539ae034
commit 61b5301f1a
2 files changed
+22

No files matched your search

@@ -36,6 +36,7 @@ abstract public class RenderBlockState {
public static final int CONNECT_BY_BLOCK = 0;
public static final int CONNECT_BY_TILE = 1;
public static final int CONNECT_BY_MATERIAL = 2;
public static final int CONNECT_BY_LIST = 3;
protected static int[] add(int[] a, int[] b) {
if (a.length != b.length) {
@@ -1,6 +1,7 @@
package com.prupe.mcpatcher.ctm;
import static com.prupe.mcpatcher.ctm.RenderBlockState.CONNECT_BY_BLOCK;
import static com.prupe.mcpatcher.ctm.RenderBlockState.CONNECT_BY_LIST;
import static com.prupe.mcpatcher.ctm.RenderBlockState.CONNECT_BY_MATERIAL;
import static com.prupe.mcpatcher.ctm.RenderBlockState.CONNECT_BY_TILE;
import static com.prupe.mcpatcher.ctm.RenderBlockState.NORMALS;
@@ -44,6 +45,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
private final int registrationOrder = nextRegistrationOrder++;
private final List<BlockStateMatcher> matchBlocks;
private final Set<String> matchTiles;
private final List<BlockStateMatcher> connectBlocks;
private final BlockFaceMatcher faceMatcher;
private final int connectType;
private final boolean innerSeams;
@@ -161,6 +163,7 @@ public abstract class TileOverride implements Comparable<TileOverride> {
if (matchBlocks.isEmpty() && matchTiles.isEmpty()) {
matchTiles.add(baseFilename);
}
connectBlocks = getBlockList(properties.getString("connectBlocks", ""), properties.getString("connectMetadata", ""));
faceMatcher = BlockFaceMatcher.create(properties.getString("faces", ""));
@@ -171,6 +174,14 @@ public abstract class TileOverride implements Comparable<TileOverride> {
case "block" -> connectType = CONNECT_BY_BLOCK;
case "tile" -> connectType = CONNECT_BY_TILE;
case "material" -> connectType = CONNECT_BY_MATERIAL;
case "list" -> {
if (connectBlocks.isEmpty()) {
properties.error("connect=list requires a non-empty connectBlocks= list");
connectType = CONNECT_BY_BLOCK;
} else {
connectType = CONNECT_BY_LIST;
}
}
default -> {
properties.error("invalid connect type %s", connectType1);
connectType = CONNECT_BY_BLOCK;
@@ -443,6 +454,16 @@ public abstract class TileOverride implements Comparable<TileOverride> {
case CONNECT_BY_TILE -> renderBlockState.shouldConnectByTile(neighbor, icon, x, y, z);
case CONNECT_BY_BLOCK -> renderBlockState.shouldConnectByBlock(neighbor, x, y, z);
case CONNECT_BY_MATERIAL -> block.blockMaterial == neighbor.blockMaterial;
case CONNECT_BY_LIST -> {
boolean matched = false;
for (BlockStateMatcher matcher : connectBlocks) {
if (matcher.match(blockAccess, x, y, z)) {
matched = true;
break;
}
}
yield matched;
}
default -> false;
};
}