Skip to content

Commit

Permalink
Delay normal face calculation to use
Browse files Browse the repository at this point in the history
This potentially fixes some cases of #2835.
  • Loading branch information
IMS212 committed Oct 24, 2024
1 parent 93cdb01 commit 8a8d6ab
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class BakedQuadMixin implements BakedQuadView {
private int flags;

@Unique
private int normal;
private int normal = -1;

@Unique
private ModelQuadFacing normalFace = null;
Expand All @@ -53,9 +53,6 @@ public abstract class BakedQuadMixin implements BakedQuadView {
"<init>([IILnet/minecraft/core/Direction;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;ZZ)V"
}, at = @At("RETURN"))
private void init(int[] is, int i, Direction face, TextureAtlasSprite arg2, boolean bl, boolean hasAmbientOcclusion, CallbackInfo ci) {
this.normal = this.calculateNormal();
this.normalFace = ModelQuadFacing.fromPackedNormal(this.normal);

this.flags = ModelQuadFlags.getQuadFlags(this, face);
}

Expand Down Expand Up @@ -116,11 +113,19 @@ public int getColorIndex() {

@Override
public ModelQuadFacing getNormalFace() {
if (this.normalFace == null) {
this.normalFace = ModelQuadFacing.fromPackedNormal(this.getFaceNormal());
}

return this.normalFace;
}

@Override
public int getFaceNormal() {
if (this.normal == -1) {
this.normal = this.calculateNormal();
}

return this.normal;
}

Expand Down

0 comments on commit 8a8d6ab

Please sign in to comment.