mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 20:47:59 +01:00
Update for HDSkins (should fix crash when opening the skins gui)
This commit is contained in:
parent
f59520aca8
commit
6d203d07b1
3 changed files with 61 additions and 45 deletions
|
@ -3,11 +3,10 @@ package com.minelittlepony.client.gui.hdskins;
|
|||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.common.client.gui.element.IconicToggle;
|
||||
import com.minelittlepony.common.client.gui.style.Style;
|
||||
import com.minelittlepony.hdskins.gui.EntityPlayerModel;
|
||||
import com.minelittlepony.hdskins.gui.GuiSkins;
|
||||
import com.minelittlepony.hdskins.gui.PlayerPreview;
|
||||
import com.minelittlepony.hdskins.net.SkinServer;
|
||||
import com.minelittlepony.pony.IPonyManager;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
|
||||
|
@ -38,8 +37,8 @@ public class GuiSkinsMineLP extends GuiSkins {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected EntityPlayerModel getModel(GameProfile profile) {
|
||||
return new EntityPonyModel(profile);
|
||||
public PlayerPreview createPreviewer() {
|
||||
return new PonyPreview();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,11 +65,12 @@ public class GuiSkinsMineLP extends GuiSkins {
|
|||
playSound(SoundEvents.BLOCK_BREWING_STAND_BREW);
|
||||
|
||||
isWet = wet == 1;
|
||||
localPlayer.releaseTextures();
|
||||
|
||||
((EntityPonyModel)localPlayer).setWet(isWet);
|
||||
((EntityPonyModel)remotePlayer).setWet(isWet);
|
||||
previewer.getLocal().releaseTextures();
|
||||
|
||||
if (previewer instanceof PonyPreview) {
|
||||
((PonyPreview)previewer).setWet(isWet);
|
||||
}
|
||||
return wet;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class GuiSkinsMineLP extends GuiSkins {
|
|||
|
||||
MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin");
|
||||
if (type == Type.SKIN) {
|
||||
ponyManager.removePony(localPlayer.getLocal(Type.SKIN).getTexture());
|
||||
ponyManager.removePony(previewer.getLocal().getTexture(Type.SKIN).getTexture());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package com.minelittlepony.client.gui.hdskins;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.client.pony.Pony;
|
||||
import com.minelittlepony.hdskins.gui.EntityPlayerModel;
|
||||
import com.minelittlepony.hdskins.gui.PlayerPreview;
|
||||
import com.minelittlepony.pony.IPony;
|
||||
import com.minelittlepony.pony.meta.Race;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
|
||||
public class PonyPreview extends PlayerPreview {
|
||||
|
||||
private final EntityPonyModel localPlayer = new EntityPonyModel(minecraft.getSession().getProfile());
|
||||
private final EntityPonyModel remotePlayer = new EntityPonyModel(minecraft.getSession().getProfile());
|
||||
|
||||
public void setWet(boolean isWet) {
|
||||
((EntityPonyModel)localPlayer).setWet(isWet);
|
||||
((EntityPonyModel)remotePlayer).setWet(isWet);
|
||||
}
|
||||
|
||||
protected EntityPlayerModel ponify(EntityPlayerModel entity, EntityPlayerModel pony) {
|
||||
Identifier loc = entity.getTexture(Type.SKIN).getTexture();
|
||||
if (loc == null || Pony.getBufferedImage(loc) == null) {
|
||||
return entity;
|
||||
}
|
||||
|
||||
IPony thePony = MineLittlePony.getInstance().getManager().getPony(loc);
|
||||
|
||||
Race race = thePony.getRace(false);
|
||||
|
||||
if (race.isHuman()) {
|
||||
return entity;
|
||||
}
|
||||
|
||||
return pony;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayerModel getRemote() {
|
||||
return ponify(super.getRemote(), remotePlayer);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityPlayerModel getLocal() {
|
||||
return ponify(super.getLocal(), localPlayer);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import com.minelittlepony.MineLittlePony;
|
|||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.model.races.PlayerModels;
|
||||
import com.minelittlepony.client.pony.Pony;
|
||||
import com.minelittlepony.client.render.IPonyRender;
|
||||
import com.minelittlepony.client.render.RenderPony;
|
||||
import com.minelittlepony.client.render.layer.LayerGear;
|
||||
|
@ -17,8 +16,6 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
|||
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||
import net.minecraft.client.render.entity.model.ElytraEntityModel;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
|
@ -26,8 +23,6 @@ import net.minecraft.util.Identifier;
|
|||
*/
|
||||
public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel, ClientPonyModel<EntityPonyModel>> implements IPonyRender<EntityPonyModel, ClientPonyModel<EntityPonyModel>> {
|
||||
|
||||
boolean renderingAsHuman = false;
|
||||
|
||||
protected final RenderPony<EntityPonyModel, ClientPonyModel<EntityPonyModel>> renderPony = new RenderPony<>(this);
|
||||
|
||||
public RenderPonyModel(EntityRenderDispatcher manager) {
|
||||
|
@ -49,24 +44,15 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel, ClientPo
|
|||
|
||||
@Override
|
||||
protected void scale(EntityPonyModel entity, float ticks) {
|
||||
if (renderingAsHuman) {
|
||||
super.scale(entity, ticks);
|
||||
} else {
|
||||
renderPony.preRenderCallback(entity, ticks);
|
||||
renderPony.preRenderCallback(entity, ticks);
|
||||
|
||||
GlStateManager.translatef(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
|
||||
}
|
||||
GlStateManager.translatef(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ClientPonyModel<EntityPonyModel> getEntityModel(EntityPonyModel playermodel) {
|
||||
renderingAsHuman = true;
|
||||
|
||||
Identifier loc = getTexture(playermodel);
|
||||
if (loc == null || Pony.getBufferedImage(loc) == null) {
|
||||
return super.getEntityModel(playermodel);
|
||||
}
|
||||
|
||||
boolean slim = playermodel.usesThinSkin();
|
||||
|
||||
|
@ -74,10 +60,6 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel, ClientPo
|
|||
|
||||
Race race = thePony.getRace(false);
|
||||
|
||||
if (race.isHuman()) {
|
||||
return super.getEntityModel(playermodel);
|
||||
}
|
||||
|
||||
boolean canWet = playermodel.wet && (loc == playermodel.getBlankSkin(Type.SKIN) || race == Race.SEAPONY);
|
||||
|
||||
playerModel = canWet ? PlayerModels.SEAPONY.getModel(slim) : PlayerModels.forRace(thePony.getRace(true)).getModel(slim);
|
||||
|
@ -85,31 +67,15 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel, ClientPo
|
|||
|
||||
renderPony.setPonyModel(playerModel);
|
||||
|
||||
renderingAsHuman = false;
|
||||
|
||||
return playerModel.getBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FeatureRenderer<EntityPonyModel, ClientPonyModel<EntityPonyModel>> getElytraLayer() {
|
||||
return new LayerPonyElytra<EntityPonyModel, ClientPonyModel<EntityPonyModel>>(this) {
|
||||
private final ElytraEntityModel<EntityPonyModel> modelElytra = new ElytraEntityModel<>();
|
||||
|
||||
@Override
|
||||
protected void preRenderCallback() {
|
||||
if (!renderingAsHuman) {
|
||||
super.preRenderCallback();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityModel<EntityPonyModel> getElytraModel() {
|
||||
return renderingAsHuman ? modelElytra : super.getElytraModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Identifier getElytraTexture(EntityPonyModel entity) {
|
||||
return entity.getLocal(Type.ELYTRA).getTexture();
|
||||
return entity.getTexture(Type.ELYTRA).getTexture();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue