Skip to content

Commit

Permalink
Merge pull request #208 from romanalexander/features/persona-image-data
Browse files Browse the repository at this point in the history
Support bedrock persona ImageData
  • Loading branch information
SupremeMortal committed Jan 20, 2024
2 parents e407541 + e301ff5 commit 14da2b0
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ImageData {
private static final int DOUBLE_SKIN_SIZE = 64 * 64 * PIXEL_SIZE;
private static final int SKIN_128_64_SIZE = 128 * 64 * PIXEL_SIZE;
private static final int SKIN_128_128_SIZE = 128 * 128 * PIXEL_SIZE;
private static final int SKIN_PERSONA_SIZE = 256 * 256 * PIXEL_SIZE;

private final int width;
private final int height;
Expand All @@ -43,8 +44,10 @@ public static ImageData of(byte[] image) {
return new ImageData(128, 64, image);
case SKIN_128_128_SIZE:
return new ImageData(128, 128, image);
case SKIN_PERSONA_SIZE:
return new ImageData(256, 256, image);
default:
throw new IllegalArgumentException("Invalid legacy skin");
throw new IllegalArgumentException("Invalid skin length");
}
}

Expand All @@ -60,6 +63,15 @@ public void checkLegacySkinSize() {
}
}

public void checkPersonaSkinSize() {
switch (image.length) {
case SKIN_PERSONA_SIZE:
return;
default:
throw new IllegalArgumentException("Invalid persona skin");
}
}

public void checkLegacyCapeSize() {
if (image.length != 0 && image.length != SINGLE_SKIN_SIZE) {
throw new IllegalArgumentException("Invalid legacy cape");
Expand Down

0 comments on commit 14da2b0

Please sign in to comment.