From 517dc368a35b4e57538a2b67da2f3085fb86d7f6 Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 28 May 2019 19:02:07 +0200 Subject: [PATCH] Pony models should now work a little btter in the skins gui. Also name changes, because sanity. RenderPonyModel -> RenderDummyPony EntityPonyModel -> DummyPony --- .../client/PonyRenderManager.java | 6 +-- .../client/gui/hdskins/DummyPony.java | 32 ++++++++++++++ .../client/gui/hdskins/EntityPonyModel.java | 42 ------------------- .../client/gui/hdskins/GuiSkinsMineLP.java | 6 +-- .../client/gui/hdskins/PonyPreview.java | 36 ++++++++++------ ...derPonyModel.java => RenderDummyPony.java} | 36 ++++++++-------- 6 files changed, 80 insertions(+), 78 deletions(-) create mode 100644 src/main/java/com/minelittlepony/client/gui/hdskins/DummyPony.java delete mode 100644 src/main/java/com/minelittlepony/client/gui/hdskins/EntityPonyModel.java rename src/main/java/com/minelittlepony/client/gui/hdskins/{RenderPonyModel.java => RenderDummyPony.java} (55%) diff --git a/src/main/java/com/minelittlepony/client/PonyRenderManager.java b/src/main/java/com/minelittlepony/client/PonyRenderManager.java index 9f85c18f..ff07ebe0 100644 --- a/src/main/java/com/minelittlepony/client/PonyRenderManager.java +++ b/src/main/java/com/minelittlepony/client/PonyRenderManager.java @@ -4,8 +4,8 @@ import java.util.Map; import java.util.function.Function; import com.google.common.collect.Maps; -import com.minelittlepony.client.gui.hdskins.EntityPonyModel; -import com.minelittlepony.client.gui.hdskins.RenderPonyModel; +import com.minelittlepony.client.gui.hdskins.DummyPony; +import com.minelittlepony.client.gui.hdskins.RenderDummyPony; import com.minelittlepony.client.mixin.MixinRenderManager; import com.minelittlepony.client.model.races.PlayerModels; import com.minelittlepony.client.render.LevitatingItemRenderer; @@ -49,7 +49,7 @@ public class PonyRenderManager { */ public void initialiseRenderers(EntityRenderDispatcher manager) { // Preview on the select skin gui - MineLPClient.getInstance().getModUtilities().addRenderer(EntityPonyModel.class, RenderPonyModel::new); + MineLPClient.getInstance().getModUtilities().addRenderer(DummyPony.class, RenderDummyPony::new); PlayerModels[] models = PlayerModels.values(); diff --git a/src/main/java/com/minelittlepony/client/gui/hdskins/DummyPony.java b/src/main/java/com/minelittlepony/client/gui/hdskins/DummyPony.java new file mode 100644 index 00000000..7d35ab58 --- /dev/null +++ b/src/main/java/com/minelittlepony/client/gui/hdskins/DummyPony.java @@ -0,0 +1,32 @@ +package com.minelittlepony.client.gui.hdskins; + +import com.minelittlepony.hdskins.dummy.DummyPlayer; +import com.minelittlepony.hdskins.dummy.TextureProxy; +import com.minelittlepony.hdskins.resources.LocalTexture; +import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; + +/** + * Dummy model used for the skin uploading screen. + */ +public class DummyPony extends DummyPlayer { + + public boolean wet = false; + + public DummyPony(TextureProxy textures) { + super(textures); + } + + public void setWet(boolean wet) { + this.wet = wet; + + LocalTexture skin = getTextures().get(Type.SKIN); + + if (wet && skin.getId() == PonyPreview.NO_SKIN_PONY) { + skin.reset(); + } + + if (!wet && skin.getId() == PonyPreview.NO_SKIN_SEAPONY) { + skin.reset(); + } + } +} diff --git a/src/main/java/com/minelittlepony/client/gui/hdskins/EntityPonyModel.java b/src/main/java/com/minelittlepony/client/gui/hdskins/EntityPonyModel.java deleted file mode 100644 index 2f476513..00000000 --- a/src/main/java/com/minelittlepony/client/gui/hdskins/EntityPonyModel.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.minelittlepony.client.gui.hdskins; - -import com.minelittlepony.hdskins.gui.EntityPlayerModel; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; - -import net.minecraft.util.Identifier; - -/** - * Dummy model used for the skin uploading screen. - */ -public class EntityPonyModel extends EntityPlayerModel { - - public static final Identifier NO_SKIN_PONY = new Identifier("minelittlepony", "textures/mob/noskin.png"); - public static final Identifier NO_SKIN_SEAPONY = new Identifier("minelittlepony", "textures/mob/noskin_seapony.png"); - - public boolean wet = false; - - public EntityPonyModel(GameProfile profile) { - super(profile); - } - - @Override - public Identifier getBlankSkin(Type type) { - if (type == Type.SKIN) { - return wet ? NO_SKIN_SEAPONY : NO_SKIN_PONY; - } - return super.getBlankSkin(type); - } - - public void setWet(boolean wet) { - this.wet = wet; - - if (wet && skin.getTexture() == NO_SKIN_PONY) { - skin.reset(); - } - - if (!wet && skin.getTexture() == NO_SKIN_SEAPONY) { - skin.reset(); - } - } -} diff --git a/src/main/java/com/minelittlepony/client/gui/hdskins/GuiSkinsMineLP.java b/src/main/java/com/minelittlepony/client/gui/hdskins/GuiSkinsMineLP.java index 00f7e3a7..7bf50c8e 100644 --- a/src/main/java/com/minelittlepony/client/gui/hdskins/GuiSkinsMineLP.java +++ b/src/main/java/com/minelittlepony/client/gui/hdskins/GuiSkinsMineLP.java @@ -3,8 +3,8 @@ 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.dummy.PlayerPreview; 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.minecraft.MinecraftProfileTexture; @@ -66,7 +66,7 @@ public class GuiSkinsMineLP extends GuiSkins { isWet = wet == 1; - previewer.getLocal().releaseTextures(); + previewer.getLocal().getTextures().release();; if (previewer instanceof PonyPreview) { ((PonyPreview)previewer).setWet(isWet); @@ -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(previewer.getLocal().getTexture(Type.SKIN).getTexture()); + ponyManager.removePony(previewer.getLocal().getTextures().get(Type.SKIN).getId()); } } diff --git a/src/main/java/com/minelittlepony/client/gui/hdskins/PonyPreview.java b/src/main/java/com/minelittlepony/client/gui/hdskins/PonyPreview.java index 5313ea2c..2507b3fd 100644 --- a/src/main/java/com/minelittlepony/client/gui/hdskins/PonyPreview.java +++ b/src/main/java/com/minelittlepony/client/gui/hdskins/PonyPreview.java @@ -4,26 +4,38 @@ 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.hdskins.dummy.DummyPlayer; +import com.minelittlepony.hdskins.dummy.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 static final Identifier NO_SKIN_PONY = new Identifier("minelittlepony", "textures/mob/noskin.png"); + public static final Identifier NO_SKIN_SEAPONY = new Identifier("minelittlepony", "textures/mob/noskin_seapony.png"); + + private final DummyPony localPlayer = new DummyPony(localTextures); + private final DummyPony remotePlayer = new DummyPony(remoteTextures); public void setWet(boolean isWet) { - ((EntityPonyModel)localPlayer).setWet(isWet); - ((EntityPonyModel)remotePlayer).setWet(isWet); + localPlayer.setWet(isWet); + remotePlayer.setWet(isWet); } - protected EntityPlayerModel ponify(EntityPlayerModel entity, EntityPlayerModel pony) { - Identifier loc = entity.getTexture(Type.SKIN).getTexture(); + @Override + public Identifier getBlankSkin(Type type) { + if (type == Type.SKIN) { + return localPlayer.wet ? NO_SKIN_SEAPONY : NO_SKIN_PONY; + } + return super.getBlankSkin(type); + } + + protected DummyPlayer ponify(DummyPlayer human, DummyPlayer pony) { + Identifier loc = human.getTextures().get(Type.SKIN).getId(); + if (loc == null || Pony.getBufferedImage(loc) == null) { - return entity; + return pony; } IPony thePony = MineLittlePony.getInstance().getManager().getPony(loc); @@ -31,20 +43,20 @@ public class PonyPreview extends PlayerPreview { Race race = thePony.getRace(false); if (race.isHuman()) { - return entity; + return human; } return pony; } @Override - public EntityPlayerModel getRemote() { + public DummyPlayer getRemote() { return ponify(super.getRemote(), remotePlayer); } @Override - public EntityPlayerModel getLocal() { + public DummyPlayer getLocal() { return ponify(super.getLocal(), localPlayer); } } diff --git a/src/main/java/com/minelittlepony/client/gui/hdskins/RenderPonyModel.java b/src/main/java/com/minelittlepony/client/gui/hdskins/RenderDummyPony.java similarity index 55% rename from src/main/java/com/minelittlepony/client/gui/hdskins/RenderPonyModel.java rename to src/main/java/com/minelittlepony/client/gui/hdskins/RenderDummyPony.java index f5ac0dbb..150fdc77 100644 --- a/src/main/java/com/minelittlepony/client/gui/hdskins/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/client/gui/hdskins/RenderDummyPony.java @@ -8,7 +8,7 @@ import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.client.render.RenderPony; import com.minelittlepony.client.render.layer.LayerGear; import com.minelittlepony.client.render.layer.LayerPonyElytra; -import com.minelittlepony.hdskins.gui.RenderPlayerModel; +import com.minelittlepony.hdskins.dummy.RenderDummyPlayer; import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.meta.Race; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; @@ -21,29 +21,29 @@ import net.minecraft.util.Identifier; /** * Renderer used for the dummy pony model when selecting a skin. */ -public class RenderPonyModel extends RenderPlayerModel> implements IPonyRender> { +public class RenderDummyPony extends RenderDummyPlayer> implements IPonyRender> { - protected final RenderPony> renderPony = new RenderPony<>(this); + protected final RenderPony> renderPony = new RenderPony<>(this); - public RenderPonyModel(EntityRenderDispatcher manager) { + public RenderDummyPony(EntityRenderDispatcher manager) { super(manager); addFeature(new LayerGear<>(this)); } - private ModelWrapper> playerModel; + private ModelWrapper> playerModel; @Override - public ModelWrapper> getModelWrapper() { + public ModelWrapper> getModelWrapper() { return playerModel; } @Override - public IPony getEntityPony(EntityPonyModel entity) { + public IPony getEntityPony(DummyPony entity) { return MineLittlePony.getInstance().getManager().getPony(getTexture(entity)); } @Override - protected void scale(EntityPonyModel entity, float ticks) { + protected void scale(DummyPony entity, float ticks) { renderPony.preRenderCallback(entity, ticks); GlStateManager.translatef(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow @@ -51,18 +51,18 @@ public class RenderPonyModel extends RenderPlayerModel getEntityModel(EntityPonyModel playermodel) { + public ClientPonyModel getEntityModel(DummyPony playermodel) { Identifier loc = getTexture(playermodel); - boolean slim = playermodel.usesThinSkin(); + boolean slim = playermodel.getTextures().usesThinSkin(); IPony thePony = MineLittlePony.getInstance().getManager().getPony(loc); Race race = thePony.getRace(false); - boolean canWet = playermodel.wet && (loc == playermodel.getBlankSkin(Type.SKIN) || race == Race.SEAPONY); + boolean canWet = playermodel.wet && (loc == playermodel.getTextures().getBlankSkin(Type.SKIN) || race == Race.SEAPONY); - playerModel = canWet ? PlayerModels.SEAPONY.getModel(slim) : PlayerModels.forRace(thePony.getRace(true)).getModel(slim); + playerModel = new ModelWrapper<>(canWet ? PlayerModels.SEAPONY.getModel(slim) : PlayerModels.forRace(thePony.getRace(true)).getModel(slim)); playerModel.apply(thePony.getMetadata()); renderPony.setPonyModel(playerModel); @@ -71,22 +71,22 @@ public class RenderPonyModel extends RenderPlayerModel> getElytraLayer() { - return new LayerPonyElytra>(this) { + protected FeatureRenderer> getElytraLayer() { + return new LayerPonyElytra>(this) { @Override - protected Identifier getElytraTexture(EntityPonyModel entity) { - return entity.getTexture(Type.ELYTRA).getTexture(); + protected Identifier getElytraTexture(DummyPony entity) { + return entity.getTextures().get(Type.ELYTRA).getId(); } }; } @Override - public RenderPony> getInternalRenderer() { + public RenderPony> getInternalRenderer() { return renderPony; } @Override - public Identifier findTexture(EntityPonyModel entity) { + public Identifier findTexture(DummyPony entity) { return getTexture(entity); } }