diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java index 4d902abf..b21b8e8c 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java @@ -320,7 +320,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener { metadata = new HashMap<>(); } else if (metadata.containsKey("model")) { // try to reset the model. - metadata.put("model", metadata.get("model").contains("slim") ? "slim" : "default"); + metadata.put("model", VanillaModels.of(metadata.get("model"))); } for (ISkinParser parser : skinParsers) { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/VanillaModels.java b/src/hdskins/java/com/voxelmodpack/hdskins/VanillaModels.java new file mode 100644 index 00000000..3595381a --- /dev/null +++ b/src/hdskins/java/com/voxelmodpack/hdskins/VanillaModels.java @@ -0,0 +1,22 @@ +package com.voxelmodpack.hdskins; + +public class VanillaModels { + public static final String SLIM = "slim"; + public static final String DEFAULT = "default"; + + public static String of(String model) { + return model != null && model.contains(SLIM) ? SLIM : DEFAULT; + } + + public static String nonNull(String model) { + return model == null ? DEFAULT : SLIM; + } + + public static boolean isSlim(String model) { + return SLIM.equals(model); + } + + public static boolean isFat(String model) { + return DEFAULT.equals(model); + } +} diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java index 8ec65c1e..615572ce 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java @@ -14,6 +14,7 @@ import com.voxelmodpack.hdskins.HDSkinManager; import com.voxelmodpack.hdskins.SkinChooser; import com.voxelmodpack.hdskins.SkinUploader; import com.voxelmodpack.hdskins.SkinUploader.ISkinUploadHandler; +import com.voxelmodpack.hdskins.VanillaModels; import com.voxelmodpack.hdskins.server.SkinServer; import com.voxelmodpack.hdskins.upload.GLWindow; import com.voxelmodpack.hdskins.util.CallableFutures; @@ -173,15 +174,15 @@ public class GuiSkins extends GameGui implements ISkinUploadHandler { addButton(new Button(width / 2 - 50, height - 25, 100, 20, "hdskins.options.close", sender -> mc.displayGuiScreen(new GuiMainMenu()))); - addButton(btnModeSteve = new FeatureSwitch(width - 25, 32, sender -> switchSkinMode("default"))) + addButton(btnModeSteve = new FeatureSwitch(width - 25, 32, sender -> switchSkinMode(VanillaModels.DEFAULT))) .setIcon(new ItemStack(Items.LEATHER_LEGGINGS), 0x3c5dcb) - .setEnabled("slim".equals(uploader.getMetadataField("model"))) + .setEnabled(VanillaModels.isSlim(uploader.getMetadataField("model"))) .setTooltip("hdskins.mode.steve") .setTooltipOffset(0, 10); - addButton(btnModeAlex = new FeatureSwitch(width - 25, 51, sender -> switchSkinMode("slim"))) + addButton(btnModeAlex = new FeatureSwitch(width - 25, 51, sender -> switchSkinMode(VanillaModels.SLIM))) .setIcon(new ItemStack(Items.LEATHER_LEGGINGS), 0xfff500) - .setEnabled("default".equals(uploader.getMetadataField("model"))) + .setEnabled(VanillaModels.isFat(uploader.getMetadataField("model"))) .setTooltip("hdskins.mode.alex") .setTooltipOffset(0, 10); @@ -248,7 +249,7 @@ public class GuiSkins extends GameGui implements ISkinUploadHandler { protected void switchSkinMode(String model) { playSound(SoundEvents.BLOCK_BREWING_STAND_BREW); - boolean thinArmType = "slim".equals(model); + boolean thinArmType = VanillaModels.isSlim(model); btnModeSteve.enabled = thinArmType; btnModeAlex.enabled = !thinArmType; diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/resources/PreviewTexture.java b/src/hdskins/java/com/voxelmodpack/hdskins/resources/PreviewTexture.java index 700775e6..dd25aa9a 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/resources/PreviewTexture.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/resources/PreviewTexture.java @@ -4,6 +4,8 @@ import net.minecraft.client.renderer.IImageBuffer; import net.minecraft.client.renderer.ThreadDownloadImageData; import net.minecraft.util.ResourceLocation; +import com.voxelmodpack.hdskins.VanillaModels; + import javax.annotation.Nullable; public class PreviewTexture extends ThreadDownloadImageData { @@ -17,7 +19,7 @@ public class PreviewTexture extends ThreadDownloadImageData { public PreviewTexture(@Nullable String model, String url, ResourceLocation fallbackTexture, @Nullable IImageBuffer imageBuffer) { super(null, url, fallbackTexture, imageBuffer); - this.model = model == null ? "default" : model; + this.model = VanillaModels.nonNull(model); this.fileUrl = url; } @@ -40,6 +42,6 @@ public class PreviewTexture extends ThreadDownloadImageData { } public boolean usesThinArms() { - return "slim".equals(model); + return VanillaModels.isSlim(model); } } diff --git a/src/main/java/com/minelittlepony/PonySkinParser.java b/src/main/java/com/minelittlepony/PonySkinParser.java index 056233b1..75be1684 100644 --- a/src/main/java/com/minelittlepony/PonySkinParser.java +++ b/src/main/java/com/minelittlepony/PonySkinParser.java @@ -3,6 +3,8 @@ package com.minelittlepony; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.voxelmodpack.hdskins.ISkinParser; +import com.voxelmodpack.hdskins.VanillaModels; + import net.minecraft.util.ResourceLocation; import java.util.Map; @@ -13,7 +15,7 @@ public class PonySkinParser implements ISkinParser { public void parse(GameProfile profile, MinecraftProfileTexture.Type type, ResourceLocation resource, Map metadata) { if (type == MinecraftProfileTexture.Type.SKIN) { - boolean slim = "slim".equals(metadata.get("model")); + boolean slim = VanillaModels.isSlim(metadata.get("model")); // TODO use proper model metadata system metadata.put("model", MineLittlePony.getInstance().getManager() diff --git a/src/main/java/com/minelittlepony/model/player/PlayerModels.java b/src/main/java/com/minelittlepony/model/player/PlayerModels.java index c8f31782..e0516bf2 100644 --- a/src/main/java/com/minelittlepony/model/player/PlayerModels.java +++ b/src/main/java/com/minelittlepony/model/player/PlayerModels.java @@ -7,12 +7,13 @@ import com.minelittlepony.render.player.RenderSeaponyPlayer; import net.minecraft.client.renderer.entity.RenderManager; import com.minelittlepony.model.ModelWrapper; +import com.voxelmodpack.hdskins.VanillaModels; public enum PlayerModels { /** * The default non-pony model. This is typically handled my the vanilla renderer. */ - DEFAULT("default", "slim", () -> PMAPI.earthpony, () -> PMAPI.earthponySmall), + DEFAULT(VanillaModels.DEFAULT, VanillaModels.SLIM, () -> PMAPI.earthpony, () -> PMAPI.earthponySmall), EARTH("earthpony", () -> PMAPI.earthpony, () -> PMAPI.earthponySmall), PEGASUS("pegasus", () -> PMAPI.pegasus, () -> PMAPI.pegasusSmall), BATPONY("batpony", () -> PMAPI.bat, () -> PMAPI.batSmall), @@ -32,7 +33,7 @@ public enum PlayerModels { private final String normalKey, slimKey; PlayerModels(String key, ModelResolver normal, ModelResolver slim) { - this(key, "slim" + key, normal, slim); + this(key, VanillaModels.SLIM + key, normal, slim); } PlayerModels(String normalKey, String slimKey, ModelResolver normal, ModelResolver slim) {