mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-26 14:27: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.MineLittlePony;
|
||||||
import com.minelittlepony.common.client.gui.element.IconicToggle;
|
import com.minelittlepony.common.client.gui.element.IconicToggle;
|
||||||
import com.minelittlepony.common.client.gui.style.Style;
|
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.GuiSkins;
|
||||||
|
import com.minelittlepony.hdskins.gui.PlayerPreview;
|
||||||
import com.minelittlepony.hdskins.net.SkinServer;
|
import com.minelittlepony.hdskins.net.SkinServer;
|
||||||
import com.minelittlepony.pony.IPonyManager;
|
import com.minelittlepony.pony.IPonyManager;
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
|
|
||||||
|
@ -38,8 +37,8 @@ public class GuiSkinsMineLP extends GuiSkins {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected EntityPlayerModel getModel(GameProfile profile) {
|
public PlayerPreview createPreviewer() {
|
||||||
return new EntityPonyModel(profile);
|
return new PonyPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,11 +65,12 @@ public class GuiSkinsMineLP extends GuiSkins {
|
||||||
playSound(SoundEvents.BLOCK_BREWING_STAND_BREW);
|
playSound(SoundEvents.BLOCK_BREWING_STAND_BREW);
|
||||||
|
|
||||||
isWet = wet == 1;
|
isWet = wet == 1;
|
||||||
localPlayer.releaseTextures();
|
|
||||||
|
|
||||||
((EntityPonyModel)localPlayer).setWet(isWet);
|
previewer.getLocal().releaseTextures();
|
||||||
((EntityPonyModel)remotePlayer).setWet(isWet);
|
|
||||||
|
|
||||||
|
if (previewer instanceof PonyPreview) {
|
||||||
|
((PonyPreview)previewer).setWet(isWet);
|
||||||
|
}
|
||||||
return wet;
|
return wet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class GuiSkinsMineLP extends GuiSkins {
|
||||||
|
|
||||||
MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin");
|
MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin");
|
||||||
if (type == Type.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.ClientPonyModel;
|
||||||
import com.minelittlepony.client.model.ModelWrapper;
|
import com.minelittlepony.client.model.ModelWrapper;
|
||||||
import com.minelittlepony.client.model.races.PlayerModels;
|
import com.minelittlepony.client.model.races.PlayerModels;
|
||||||
import com.minelittlepony.client.pony.Pony;
|
|
||||||
import com.minelittlepony.client.render.IPonyRender;
|
import com.minelittlepony.client.render.IPonyRender;
|
||||||
import com.minelittlepony.client.render.RenderPony;
|
import com.minelittlepony.client.render.RenderPony;
|
||||||
import com.minelittlepony.client.render.layer.LayerGear;
|
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.EntityRenderDispatcher;
|
||||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
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;
|
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>> {
|
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);
|
protected final RenderPony<EntityPonyModel, ClientPonyModel<EntityPonyModel>> renderPony = new RenderPony<>(this);
|
||||||
|
|
||||||
public RenderPonyModel(EntityRenderDispatcher manager) {
|
public RenderPonyModel(EntityRenderDispatcher manager) {
|
||||||
|
@ -49,24 +44,15 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel, ClientPo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void scale(EntityPonyModel entity, float ticks) {
|
protected void scale(EntityPonyModel entity, float ticks) {
|
||||||
if (renderingAsHuman) {
|
renderPony.preRenderCallback(entity, ticks);
|
||||||
super.scale(entity, ticks);
|
|
||||||
} else {
|
|
||||||
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")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public ClientPonyModel<EntityPonyModel> getEntityModel(EntityPonyModel playermodel) {
|
public ClientPonyModel<EntityPonyModel> getEntityModel(EntityPonyModel playermodel) {
|
||||||
renderingAsHuman = true;
|
|
||||||
|
|
||||||
Identifier loc = getTexture(playermodel);
|
Identifier loc = getTexture(playermodel);
|
||||||
if (loc == null || Pony.getBufferedImage(loc) == null) {
|
|
||||||
return super.getEntityModel(playermodel);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean slim = playermodel.usesThinSkin();
|
boolean slim = playermodel.usesThinSkin();
|
||||||
|
|
||||||
|
@ -74,10 +60,6 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel, ClientPo
|
||||||
|
|
||||||
Race race = thePony.getRace(false);
|
Race race = thePony.getRace(false);
|
||||||
|
|
||||||
if (race.isHuman()) {
|
|
||||||
return super.getEntityModel(playermodel);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean canWet = playermodel.wet && (loc == playermodel.getBlankSkin(Type.SKIN) || race == Race.SEAPONY);
|
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);
|
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);
|
renderPony.setPonyModel(playerModel);
|
||||||
|
|
||||||
renderingAsHuman = false;
|
|
||||||
|
|
||||||
return playerModel.getBody();
|
return playerModel.getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FeatureRenderer<EntityPonyModel, ClientPonyModel<EntityPonyModel>> getElytraLayer() {
|
protected FeatureRenderer<EntityPonyModel, ClientPonyModel<EntityPonyModel>> getElytraLayer() {
|
||||||
return new LayerPonyElytra<EntityPonyModel, ClientPonyModel<EntityPonyModel>>(this) {
|
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
|
@Override
|
||||||
protected Identifier getElytraTexture(EntityPonyModel entity) {
|
protected Identifier getElytraTexture(EntityPonyModel entity) {
|
||||||
return entity.getLocal(Type.ELYTRA).getTexture();
|
return entity.getTexture(Type.ELYTRA).getTexture();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue