From ab8ab99bd5e2226ee22686568d1912969b82a6cb Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 30 Apr 2018 11:48:35 +0200 Subject: [PATCH] Fixed rendering issues where the skin upload renders with the wrong model --- .../hdskins/gui/EntityPonyModel.java | 30 ++++++++++++++++++ .../hdskins/gui/RenderPonyModel.java | 30 +++++++++++++----- .../minelittlepony/textures/mob/noskin.png | Bin 0 -> 1944 bytes 3 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/assets/minelittlepony/textures/mob/noskin.png 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 0000000000000000000000000000000000000000..2234de1ea5444c384ac3e4f369a9d0165c831aa6 GIT binary patch literal 1944 zcmV;J2WR++P)T+4Fbtt-8iF9en>TM5_7UgK zofBE(YpU=7(CKvW?%lh{4ZiQAR4TzRjL3Dym~6LgTmH3eTlNWp0AUzLe&fVW;~RM% zQYw`I0G{VT*Y(6cuU@^1oS!;%N?MGjY4AKxwiOD6u__{K{6qzGI-SVu8-^h@sp~ol zg@U}67nWtoW6$$oS=LyUkT!mz0?OrbL|dvRIp>jw?F7|rNMO1@?o#`KoyOPl`Vr@R zK$BT$Hk*mWL*}TOCPb>H{lc^)|D5i22|&r)7oal=^AUP&-(d?U;J z(?~?u^@#tgZjxkzaWl;7zaK7;H9ni0n-dh%8Dn6K!LlrA@^q7~>*)9U;G9F#G#G{f zA%u(yx~{|XJP0A=vq*Vac|@bpU^qZTEI1} zds~`Tzu!j?1kiO|3YU~ekV(e#hyzuCVHonIHBFN<==;7Tjyremz%)%9IdTNQfByz! z42?zuj~+cjx7(FgA%uXYX$Zp*LI@de^W+f+1uX~yXqtvXp#WXirRkfd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