Skip to content

Commit a52f35c

Browse files
committed
Merge branch 'refs/heads/1.19.4/dev' into 1.20.1/dev
2 parents 3f97830 + eb58bb1 commit a52f35c

56 files changed

Lines changed: 515 additions & 391 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ yarn_mappings = 1.20.1+build.10
99
loader_version = 0.15.10
1010

1111
# Mod Properties
12-
mod_version = 3.0.0-beta.5
12+
mod_version = 3.0.0-beta.6
1313
mod_minecraft_version = 1.20.1
1414
maven_group = me.pepperbell
1515
archives_base_name = continuity

src/main/java/me/pepperbell/continuity/api/client/QuadProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import net.minecraft.world.BlockRenderView;
1616

1717
public interface QuadProcessor {
18-
ProcessingResult processQuad(MutableQuadView quad, Sprite sprite, BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, int pass, ProcessingContext context);
18+
ProcessingResult processQuad(MutableQuadView quad, Sprite sprite, BlockRenderView blockView, BlockState appearanceState, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, int pass, ProcessingContext context);
1919

2020
interface ProcessingContext extends ProcessingDataProvider {
2121
void addEmitterConsumer(Consumer<QuadEmitter> consumer);

src/main/java/me/pepperbell/continuity/client/mixin/AtlasLoaderMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ abstract class AtlasLoaderMixin {
6363
Map<Identifier, Identifier> emissiveIdMap = new Object2ObjectOpenHashMap<>();
6464
suppliers.forEach((id, supplier) -> {
6565
if (!id.getPath().endsWith(emissiveSuffix)) {
66-
Identifier emissiveId = new Identifier(id.getNamespace(), id.getPath() + emissiveSuffix);
66+
Identifier emissiveId = id.withPath(id.getPath() + emissiveSuffix);
6767
if (!suppliers.containsKey(emissiveId)) {
6868
Identifier emissiveLocation = emissiveId.withPath("textures/" + emissiveId.getPath() + ".png");
6969
Optional<Resource> optionalResource = resourceManager.getResource(emissiveLocation);

src/main/java/me/pepperbell/continuity/client/model/CtmBakedModel.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.minecraft.client.render.model.BakedModel;
1515
import net.minecraft.client.texture.Sprite;
1616
import net.minecraft.util.math.BlockPos;
17+
import net.minecraft.util.math.Direction;
1718
import net.minecraft.util.math.random.Random;
1819
import net.minecraft.world.BlockRenderView;
1920

@@ -47,7 +48,24 @@ public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos
4748
return;
4849
}
4950

50-
quadTransform.prepare(blockView, state, pos, randomSupplier, context, ContinuityConfig.INSTANCE.useManualCulling.get(), getSliceFunc(state));
51+
// The correct way to get the appearance of the origin state from within a block model is to (1) call
52+
// getAppearance on the result of blockView.getBlockState(pos) instead of the passed state and (2) pass the
53+
// pos and world state of the adjacent block as the source pos and source state.
54+
// (1) is not followed here because at this point in execution, within this call to
55+
// CtmBakedModel#emitBlockQuads, the state parameter must already contain the world state. Even if this
56+
// CtmBakedModel is wrapped, then the wrapper must pass the same state as it received because not doing so can
57+
// cause crashes when the wrapped model is a vanilla multipart model or delegates to one. Thus, getting the
58+
// world state again is inefficient and unnecessary.
59+
// (2) is not possible here because the appearance state is necessary to get the slice and only the processors
60+
// within the slice actually perform checks on adjacent blocks. Likewise, the processors themselves cannot
61+
// retrieve the appearance state since the correct processors can only be chosen with the initially correct
62+
// appearance state.
63+
// Additionally, the side is chosen to always be the first constant of the enum (DOWN) for simplicity. Querying
64+
// the appearance for all six sides would be more correct, but less efficient. This may be fixed in the future,
65+
// especially if there is an actual use case for it.
66+
BlockState appearanceState = state.getAppearance(blockView, pos, Direction.DOWN, state, pos);
67+
68+
quadTransform.prepare(blockView, appearanceState, state, pos, randomSupplier, context, ContinuityConfig.INSTANCE.useManualCulling.get(), getSliceFunc(appearanceState));
5169

5270
context.pushTransform(quadTransform);
5371
super.emitBlockQuads(blockView, state, pos, randomSupplier, context);
@@ -86,6 +104,7 @@ protected static class CtmQuadTransform implements RenderContext.QuadTransform {
86104
protected final ProcessingContextImpl processingContext = new ProcessingContextImpl();
87105

88106
protected BlockRenderView blockView;
107+
protected BlockState appearanceState;
89108
protected BlockState state;
90109
protected BlockPos pos;
91110
protected Supplier<Random> randomSupplier;
@@ -116,7 +135,7 @@ protected Boolean transformOnce(MutableQuadView quad, int pass) {
116135
QuadProcessors.Slice slice = sliceFunc.apply(sprite);
117136
QuadProcessor[] processors = pass == 0 ? slice.processors() : slice.multipassProcessors();
118137
for (QuadProcessor processor : processors) {
119-
QuadProcessor.ProcessingResult result = processor.processQuad(quad, sprite, blockView, state, pos, randomSupplier, pass, processingContext);
138+
QuadProcessor.ProcessingResult result = processor.processQuad(quad, sprite, blockView, appearanceState, state, pos, randomSupplier, pass, processingContext);
120139
if (result == QuadProcessor.ProcessingResult.NEXT_PROCESSOR) {
121140
continue;
122141
}
@@ -137,8 +156,9 @@ public boolean isActive() {
137156
return active;
138157
}
139158

140-
public void prepare(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext renderContext, boolean useManualCulling, Function<Sprite, QuadProcessors.Slice> sliceFunc) {
159+
public void prepare(BlockRenderView blockView, BlockState appearanceState, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext renderContext, boolean useManualCulling, Function<Sprite, QuadProcessors.Slice> sliceFunc) {
141160
this.blockView = blockView;
161+
this.appearanceState = appearanceState;
142162
this.state = state;
143163
this.pos = pos;
144164
this.randomSupplier = randomSupplier;
@@ -153,6 +173,7 @@ public void prepare(BlockRenderView blockView, BlockState state, BlockPos pos, S
153173

154174
public void reset() {
155175
blockView = null;
176+
appearanceState = null;
156177
state = null;
157178
pos = null;
158179
randomSupplier = null;

src/main/java/me/pepperbell/continuity/client/processor/AbstractQuadProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public AbstractQuadProcessor(Sprite[] sprites, ProcessingPredicate processingPre
2020
}
2121

2222
@Override
23-
public ProcessingResult processQuad(MutableQuadView quad, Sprite sprite, BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, int pass, ProcessingContext context) {
24-
if (!processingPredicate.shouldProcessQuad(quad, sprite, blockView, state, pos, context)) {
23+
public ProcessingResult processQuad(MutableQuadView quad, Sprite sprite, BlockRenderView blockView, BlockState appearanceState, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, int pass, ProcessingContext context) {
24+
if (!processingPredicate.shouldProcessQuad(quad, sprite, blockView, appearanceState, state, pos, context)) {
2525
return ProcessingResult.NEXT_PROCESSOR;
2626
}
27-
return processQuadInner(quad, sprite, blockView, state, pos, randomSupplier, pass, context);
27+
return processQuadInner(quad, sprite, blockView, appearanceState, state, pos, randomSupplier, pass, context);
2828
}
2929

30-
public abstract ProcessingResult processQuadInner(MutableQuadView quad, Sprite sprite, BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, int pass, ProcessingContext context);
30+
public abstract ProcessingResult processQuadInner(MutableQuadView quad, Sprite sprite, BlockRenderView blockView, BlockState appearanceState, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, int pass, ProcessingContext context);
3131
}

src/main/java/me/pepperbell/continuity/client/processor/AbstractQuadProcessorFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public QuadProcessor createProcessor(T properties, Function<SpriteIdentifier, Sp
1919
int max = provided;
2020

2121
if (provided > textureAmount) {
22-
ContinuityClient.LOGGER.warn("Method '" + properties.getMethod() + "' requires " + textureAmount + " tiles but " + provided + " were provided in file '" + properties.getResourceId() + "' in pack '" + properties.getPackName() + "'");
22+
ContinuityClient.LOGGER.warn("Method '" + properties.getMethod() + "' requires " + textureAmount + " tiles but " + provided + " were provided in file '" + properties.getResourceId() + "' in pack '" + properties.getPackId() + "'");
2323
max = textureAmount;
2424
}
2525

@@ -40,7 +40,7 @@ public QuadProcessor createProcessor(T properties, Function<SpriteIdentifier, Sp
4040
}
4141

4242
if (provided < textureAmount) {
43-
ContinuityClient.LOGGER.error("Method '" + properties.getMethod() + "' requires " + textureAmount + " tiles but only " + provided + " were provided in file '" + properties.getResourceId() + "' in pack '" + properties.getPackName() + "'");
43+
ContinuityClient.LOGGER.error("Method '" + properties.getMethod() + "' requires " + textureAmount + " tiles but only " + provided + " were provided in file '" + properties.getResourceId() + "' in pack '" + properties.getPackId() + "'");
4444
for (int i = provided; i < textureAmount; i++) {
4545
sprites[i] = missingSprite;
4646
}

src/main/java/me/pepperbell/continuity/client/processor/BaseProcessingPredicate.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ public BaseProcessingPredicate(@Nullable EnumSet<Direction> faces, @Nullable Pre
3838
}
3939

4040
@Override
41-
public boolean shouldProcessQuad(QuadView quad, Sprite sprite, BlockRenderView blockView, BlockState state, BlockPos pos, ProcessingDataProvider dataProvider) {
41+
public boolean shouldProcessQuad(QuadView quad, Sprite sprite, BlockRenderView blockView, BlockState appearanceState, BlockState state, BlockPos pos, ProcessingDataProvider dataProvider) {
4242
if (heightPredicate != null) {
4343
if (!heightPredicate.test(pos.getY())) {
4444
return false;
4545
}
4646
}
4747
if (faces != null) {
4848
Direction face = quad.lightFace();
49-
if (state.contains(Properties.AXIS)) {
50-
Direction.Axis axis = state.get(Properties.AXIS);
49+
if (appearanceState.contains(Properties.AXIS)) {
50+
Direction.Axis axis = appearanceState.get(Properties.AXIS);
5151
if (axis == Direction.Axis.X) {
5252
face = face.rotateClockwise(Direction.Axis.Z);
5353
} else if (axis == Direction.Axis.Z) {
@@ -59,13 +59,13 @@ public boolean shouldProcessQuad(QuadView quad, Sprite sprite, BlockRenderView b
5959
}
6060
}
6161
if (biomePredicate != null) {
62-
Biome biome = dataProvider.getData(ProcessingDataKeys.BIOME_CACHE_KEY).get(blockView, pos);
62+
Biome biome = dataProvider.getData(ProcessingDataKeys.BIOME_CACHE).get(blockView, pos);
6363
if (biome == null || !biomePredicate.test(biome)) {
6464
return false;
6565
}
6666
}
6767
if (blockEntityNamePredicate != null) {
68-
String blockEntityName = dataProvider.getData(ProcessingDataKeys.BLOCK_ENTITY_NAME_CACHE_KEY).get(blockView, pos);
68+
String blockEntityName = dataProvider.getData(ProcessingDataKeys.BLOCK_ENTITY_NAME_CACHE).get(blockView, pos);
6969
if (blockEntityName == null || !blockEntityNamePredicate.test(blockEntityName)) {
7070
return false;
7171
}
@@ -78,6 +78,7 @@ public static BaseProcessingPredicate fromProperties(BaseCtmProperties propertie
7878
}
7979

8080
public static class BiomeCache {
81+
@Nullable
8182
protected Biome biome;
8283
protected boolean invalid = true;
8384

@@ -96,6 +97,7 @@ public void reset() {
9697
}
9798

9899
public static class BlockEntityNameCache {
100+
@Nullable
99101
protected String blockEntityName;
100102
protected boolean invalid = true;
101103

src/main/java/me/pepperbell/continuity/client/processor/CompactCtmQuadProcessor.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ public CompactCtmQuadProcessor(Sprite[] sprites, ProcessingPredicate processingP
6868
}
6969

7070
@Override
71-
public ProcessingResult processQuadInner(MutableQuadView quad, Sprite sprite, BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, int pass, ProcessingContext context) {
72-
int orientation = orientationMode.getOrientation(quad, state);
71+
public ProcessingResult processQuadInner(MutableQuadView quad, Sprite sprite, BlockRenderView blockView, BlockState appearanceState, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, int pass, ProcessingContext context) {
72+
int orientation = orientationMode.getOrientation(quad, appearanceState);
7373
Direction[] directions = DirectionMaps.getMap(quad.lightFace())[orientation];
74-
BlockPos.Mutable mutablePos = context.getData(ProcessingDataKeys.MUTABLE_POS_KEY);
75-
int connections = CtmSpriteProvider.getConnections(connectionPredicate, innerSeams, directions, mutablePos, blockView, state, pos, quad.lightFace(), sprite);
74+
BlockPos.Mutable mutablePos = context.getData(ProcessingDataKeys.MUTABLE_POS);
75+
int connections = CtmSpriteProvider.getConnections(directions, connectionPredicate, innerSeams, mutablePos, blockView, appearanceState, state, pos, quad.lightFace(), sprite);
7676

7777
//
7878

@@ -156,7 +156,7 @@ public ProcessingResult processQuadInner(MutableQuadView quad, Sprite sprite, Bl
156156
return ProcessingResult.STOP;
157157
}
158158

159-
VertexContainer vertexContainer = context.getData(ProcessingDataKeys.VERTEX_CONTAINER_KEY);
159+
VertexContainer vertexContainer = context.getData(ProcessingDataKeys.VERTEX_CONTAINER);
160160
vertexContainer.fillBaseVertices(quad);
161161

162162
QuadEmitter extraQuadEmitter = context.getExtraQuadEmitter();
@@ -382,7 +382,7 @@ public ProcessingResult processQuadInner(MutableQuadView quad, Sprite sprite, Bl
382382
spriteIndexB = temp;
383383
}
384384

385-
VertexContainer vertexContainer = context.getData(ProcessingDataKeys.VERTEX_CONTAINER_KEY);
385+
VertexContainer vertexContainer = context.getData(ProcessingDataKeys.VERTEX_CONTAINER);
386386
vertexContainer.fillBaseVertices(quad);
387387

388388
QuadEmitter extraQuadEmitter = context.getExtraQuadEmitter();
@@ -627,17 +627,17 @@ public QuadProcessor createProcessor(CompactConnectingCtmProperties properties,
627627
if (value < provided) {
628628
replacementSprites[key] = textureGetter.apply(spriteIds.get(value));
629629
} else {
630-
ContinuityClient.LOGGER.warn("Cannot replace tile " + key + " with tile " + value + " as only " + provided + " tiles were provided in file '" + properties.getResourceId() + "' in pack '" + properties.getPackName() + "'");
630+
ContinuityClient.LOGGER.warn("Cannot replace tile " + key + " with tile " + value + " as only " + provided + " tiles were provided in file '" + properties.getResourceId() + "' in pack '" + properties.getPackId() + "'");
631631
}
632632
} else {
633-
ContinuityClient.LOGGER.warn("Cannot replace tile " + key + " as method '" + properties.getMethod() + "' only supports " + replacementTextureAmount + " replacement tiles in file '" + properties.getResourceId() + "' in pack '" + properties.getPackName() + "'");
633+
ContinuityClient.LOGGER.warn("Cannot replace tile " + key + " as method '" + properties.getMethod() + "' only supports " + replacementTextureAmount + " replacement tiles in file '" + properties.getResourceId() + "' in pack '" + properties.getPackId() + "'");
634634
}
635635
}
636636
}
637637

638638
if (provided > textureAmount) {
639639
if (replacementSprites == null) {
640-
ContinuityClient.LOGGER.warn("Method '" + properties.getMethod() + "' requires " + textureAmount + " tiles but " + provided + " were provided in file '" + properties.getResourceId() + "' in pack '" + properties.getPackName() + "'");
640+
ContinuityClient.LOGGER.warn("Method '" + properties.getMethod() + "' requires " + textureAmount + " tiles but " + provided + " were provided in file '" + properties.getResourceId() + "' in pack '" + properties.getPackId() + "'");
641641
}
642642
max = textureAmount;
643643
}
@@ -659,7 +659,7 @@ public QuadProcessor createProcessor(CompactConnectingCtmProperties properties,
659659
}
660660

661661
if (provided < textureAmount) {
662-
ContinuityClient.LOGGER.error("Method '" + properties.getMethod() + "' requires at least " + textureAmount + " tiles but only " + provided + " were provided in file '" + properties.getResourceId() + "' in pack '" + properties.getPackName() + "'");
662+
ContinuityClient.LOGGER.error("Method '" + properties.getMethod() + "' requires at least " + textureAmount + " tiles but only " + provided + " were provided in file '" + properties.getResourceId() + "' in pack '" + properties.getPackId() + "'");
663663
for (int i = provided; i < textureAmount; i++) {
664664
sprites[i] = missingSprite;
665665
}

src/main/java/me/pepperbell/continuity/client/processor/ConnectionPredicate.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@
77
import net.minecraft.world.BlockRenderView;
88

99
public interface ConnectionPredicate {
10-
boolean shouldConnect(BlockRenderView blockView, BlockState state, BlockPos pos, BlockState toState, Direction face, Sprite quadSprite);
10+
boolean shouldConnect(BlockRenderView blockView, BlockState appearanceState, BlockState state, BlockPos pos, BlockState otherAppearanceState, BlockState otherState, BlockPos otherPos, Direction face, Sprite quadSprite);
1111

12-
default boolean shouldConnect(BlockRenderView blockView, BlockState state, BlockPos pos, BlockPos toPos, Direction face, Sprite quadSprite) {
13-
return shouldConnect(blockView, state, pos, blockView.getBlockState(toPos), face, quadSprite);
12+
default boolean shouldConnect(BlockRenderView blockView, BlockState appearanceState, BlockState state, BlockPos pos, BlockPos otherPos, Direction face, Sprite quadSprite) {
13+
BlockState otherState = blockView.getBlockState(otherPos);
14+
BlockState otherAppearanceState = otherState.getAppearance(blockView, otherPos, face, state, pos);
15+
return shouldConnect(blockView, appearanceState, state, pos, otherAppearanceState, otherState, otherPos, face, quadSprite);
1416
}
1517

16-
default boolean shouldConnect(BlockRenderView blockView, BlockState state, BlockPos pos, BlockPos.Mutable toPos, Direction face, Sprite quadSprite, boolean innerSeams) {
17-
if (shouldConnect(blockView, state, pos, toPos, face, quadSprite)) {
18+
default boolean shouldConnect(BlockRenderView blockView, BlockState appearanceState, BlockState state, BlockPos pos, BlockPos.Mutable otherPos, Direction face, Sprite quadSprite, boolean innerSeams) {
19+
if (shouldConnect(blockView, appearanceState, state, pos, otherPos, face, quadSprite)) {
1820
if (innerSeams) {
19-
toPos.move(face);
20-
return !shouldConnect(blockView, state, pos, toPos, face, quadSprite);
21+
otherPos.move(face);
22+
return !shouldConnect(blockView, appearanceState, state, pos, otherPos, face, quadSprite);
2123
} else {
2224
return true;
2325
}

0 commit comments

Comments
 (0)