diff --git a/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java index 1c93e6f8..55754c12 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/EntityPonyModel.java @@ -1,14 +1,44 @@ package com.minelittlepony.hdskins.gui; +import java.io.File; + import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.voxelmodpack.hdskins.gui.EntityPlayerModel; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; + /** * Dummy model used for the skin uploading screen. */ public class EntityPonyModel extends EntityPlayerModel { + public static final ResourceLocation NO_SKIN_PONY = new ResourceLocation("minelittlepony", "textures/mob/noskin.png"); + public EntityPonyModel(GameProfile profile) { super(profile); } + + public void setLocalTexture(File skinTextureFile, Type type) { + super.setLocalTexture(skinTextureFile, type); + } + + public ResourceLocation getSkinTexture() { + ResourceLocation skin = super.getSkinTexture(); + if (skin == NO_SKIN) { + // We're a pony, might as well look like one. + return NO_SKIN_PONY; + } + + return skin; + } + + public void swingArm() { + super.swingArm(); + + // Fixes the preview model swinging the wrong arm. + // Who's maintaining HDSkins anyway? + this.swingingHand = EnumHand.MAIN_HAND; + } } diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 936611aa..cf26ab0c 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -1,13 +1,15 @@ package com.minelittlepony.hdskins.gui; import com.minelittlepony.MineLittlePony; -import com.minelittlepony.model.AbstractPonyModel; -import com.minelittlepony.model.BodyPart; +import com.minelittlepony.PonyManager; import com.minelittlepony.model.ModelWrapper; import com.minelittlepony.model.components.PonyElytra; import com.minelittlepony.pony.data.Pony; import com.minelittlepony.render.layer.AbstractPonyLayer; import com.voxelmodpack.hdskins.gui.RenderPlayerModel; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelElytra; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderManager; @@ -23,18 +25,24 @@ import net.minecraft.util.ResourceLocation; */ public class RenderPonyModel extends RenderPlayerModel { + boolean renderingAsHuman = false; + public RenderPonyModel(RenderManager renderer) { super(renderer); } @Override public ModelPlayer getEntityModel(EntityPonyModel playermodel) { + renderingAsHuman = true; + ResourceLocation loc = getEntityTexture(playermodel); if (loc == null) { return super.getEntityModel(playermodel); } - Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc, playermodel.profile.getId()); + // TODO: We can't find out whether to use thin arms just by the texture. + // Maybe a trigger pixel for thin arms? #FutureThoughts + Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc, PonyManager.isSlimSkin(playermodel.profile.getId())); if (thePony.getRace(false).isHuman()) { return super.getEntityModel(playermodel); @@ -43,13 +51,16 @@ public class RenderPonyModel extends RenderPlayerModel { ModelWrapper pm = thePony.getModel(true); pm.apply(thePony.getMetadata()); + renderingAsHuman = false; + return pm.getModel(); } @Override protected LayerRenderer getElytraLayer() { return new AbstractPonyLayer(this) { - final PonyElytra modelElytra = new PonyElytra(); + final PonyElytra ponyElytra = new PonyElytra(); + final ModelElytra modelElytra = new ModelElytra(); @Override public void doPonyRender(EntityPonyModel entity, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { @@ -61,12 +72,15 @@ public class RenderPonyModel extends RenderPlayerModel { bindTexture(entity.getElytraTexture()); GlStateManager.pushMatrix(); - GlStateManager.translate(0, 0.25F, 0.125F); - ((AbstractPonyModel) mainModel).transform(BodyPart.BODY); - modelElytra.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); - modelElytra.render(entity, swing, swingAmount, age, yaw, head, scale); + ModelBase model = renderingAsHuman ? modelElytra : ponyElytra; + if (!renderingAsHuman) { + GlStateManager.translate(0, 0.25F, 0.125F); + } + + model.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); + model.render(entity, swing, swingAmount, age, yaw, head, scale); GlStateManager.popMatrix(); } diff --git a/src/main/resources/assets/minelittlepony/textures/mob/noskin.png b/src/main/resources/assets/minelittlepony/textures/mob/noskin.png new file mode 100644 index 00000000..2234de1e Binary files /dev/null and b/src/main/resources/assets/minelittlepony/textures/mob/noskin.png differ