Skip to content

Commit

Permalink
Fix improper handling of frames in mantle item layer
Browse files Browse the repository at this point in the history
Frames may be repeated, so the index both is not a valid index into the sprite and getting the index from the frame data may have duplicates.
Use the unique frames stream instead to guarantee unique valid frame indexes.
  • Loading branch information
KnightMiner committed May 3, 2024
1 parent f1ce5d0 commit aeb31a9
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import java.util.PrimitiveIterator.OfInt;
import java.util.Set;
import java.util.function.Function;

Expand Down Expand Up @@ -162,7 +163,10 @@ public static ImmutableList<BakedQuad> getQuadsForSprite(int color, int tint, Te
FaceData faceData = new FaceData(uMax, vMax);
boolean translucent = false;

for(int f = 0; f < sprite.getFrameCount(); f++) {
OfInt frames = sprite.getUniqueFrames().iterator();
boolean hasFrames = frames.hasNext();
while (frames.hasNext()) {
int f = frames.nextInt();
boolean ptu;
boolean[] ptv = new boolean[uMax];
Arrays.fill(ptv, true);
Expand Down Expand Up @@ -309,7 +313,7 @@ else if (building) {
// 3. only use the first frame
// of these, 2 would give the most accurate result. However, its also the hardest to calculate
// of the remaining methods, 3 is both more accurate and easier to calculate than 1, so I opted for that approach
if (sprite.getFrameCount() > 0) {
if (hasFrames) {
for(int v = 0; v < vMax; v++) {
for(int u = 0; u < uMax; u++) {
int alpha = sprite.getPixelRGBA(0, u, vMax - v - 1) >> 24 & 0xFF;
Expand Down

0 comments on commit aeb31a9

Please sign in to comment.