Fixed rendering issues where the skin upload renders with the wrong model

This commit is contained in:
Sollace 2018-04-30 11:48:35 +02:00
parent 51e5c9ddc5
commit ab8ab99bd5
3 changed files with 52 additions and 8 deletions

View file

@ -1,14 +1,44 @@
package com.minelittlepony.hdskins.gui; package com.minelittlepony.hdskins.gui;
import java.io.File;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.voxelmodpack.hdskins.gui.EntityPlayerModel; import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
/** /**
* Dummy model used for the skin uploading screen. * Dummy model used for the skin uploading screen.
*/ */
public class EntityPonyModel extends EntityPlayerModel { public class EntityPonyModel extends EntityPlayerModel {
public static final ResourceLocation NO_SKIN_PONY = new ResourceLocation("minelittlepony", "textures/mob/noskin.png");
public EntityPonyModel(GameProfile profile) { public EntityPonyModel(GameProfile profile) {
super(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;
}
} }

View file

@ -1,13 +1,15 @@
package com.minelittlepony.hdskins.gui; package com.minelittlepony.hdskins.gui;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.PonyManager;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.ModelWrapper; import com.minelittlepony.model.ModelWrapper;
import com.minelittlepony.model.components.PonyElytra; import com.minelittlepony.model.components.PonyElytra;
import com.minelittlepony.pony.data.Pony; import com.minelittlepony.pony.data.Pony;
import com.minelittlepony.render.layer.AbstractPonyLayer; import com.minelittlepony.render.layer.AbstractPonyLayer;
import com.voxelmodpack.hdskins.gui.RenderPlayerModel; 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.model.ModelPlayer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
@ -23,18 +25,24 @@ import net.minecraft.util.ResourceLocation;
*/ */
public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> { public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> {
boolean renderingAsHuman = false;
public RenderPonyModel(RenderManager renderer) { public RenderPonyModel(RenderManager renderer) {
super(renderer); super(renderer);
} }
@Override @Override
public ModelPlayer getEntityModel(EntityPonyModel playermodel) { public ModelPlayer getEntityModel(EntityPonyModel playermodel) {
renderingAsHuman = true;
ResourceLocation loc = getEntityTexture(playermodel); ResourceLocation loc = getEntityTexture(playermodel);
if (loc == null) { if (loc == null) {
return super.getEntityModel(playermodel); 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()) { if (thePony.getRace(false).isHuman()) {
return super.getEntityModel(playermodel); return super.getEntityModel(playermodel);
@ -43,13 +51,16 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> {
ModelWrapper pm = thePony.getModel(true); ModelWrapper pm = thePony.getModel(true);
pm.apply(thePony.getMetadata()); pm.apply(thePony.getMetadata());
renderingAsHuman = false;
return pm.getModel(); return pm.getModel();
} }
@Override @Override
protected LayerRenderer<EntityLivingBase> getElytraLayer() { protected LayerRenderer<EntityLivingBase> getElytraLayer() {
return new AbstractPonyLayer<EntityPonyModel>(this) { return new AbstractPonyLayer<EntityPonyModel>(this) {
final PonyElytra modelElytra = new PonyElytra(); final PonyElytra ponyElytra = new PonyElytra();
final ModelElytra modelElytra = new ModelElytra();
@Override @Override
public void doPonyRender(EntityPonyModel entity, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { 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<EntityPonyModel> {
bindTexture(entity.getElytraTexture()); bindTexture(entity.getElytraTexture());
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
ModelBase model = renderingAsHuman ? modelElytra : ponyElytra;
if (!renderingAsHuman) {
GlStateManager.translate(0, 0.25F, 0.125F); 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);
model.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity);
model.render(entity, swing, swingAmount, age, yaw, head, scale);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB