mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Fixed rendering issues where the skin upload renders with the wrong model
This commit is contained in:
parent
51e5c9ddc5
commit
ab8ab99bd5
3 changed files with 52 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<EntityPonyModel> {
|
||||
|
||||
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<EntityPonyModel> {
|
|||
ModelWrapper pm = thePony.getModel(true);
|
||||
pm.apply(thePony.getMetadata());
|
||||
|
||||
renderingAsHuman = false;
|
||||
|
||||
return pm.getModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LayerRenderer<EntityLivingBase> getElytraLayer() {
|
||||
return new AbstractPonyLayer<EntityPonyModel>(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<EntityPonyModel> {
|
|||
bindTexture(entity.getElytraTexture());
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
ModelBase model = renderingAsHuman ? modelElytra : ponyElytra;
|
||||
|
||||
if (!renderingAsHuman) {
|
||||
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();
|
||||
}
|
||||
|
|
BIN
src/main/resources/assets/minelittlepony/textures/mob/noskin.png
Normal file
BIN
src/main/resources/assets/minelittlepony/textures/mob/noskin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in a new issue