From d9ddd3f842488c90b64d413f1711227458cc4fae Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Sun, 26 Aug 2018 15:32:17 -0400 Subject: [PATCH] Remove slim from Pony class. --- .../java/com/minelittlepony/PonyManager.java | 19 ++++++------------- .../com/minelittlepony/PonySkinParser.java | 2 +- .../hdskins/gui/RenderPonyModel.java | 6 +++--- .../com/minelittlepony/pony/data/Pony.java | 15 +-------------- .../render/PonySkullRenderer.java | 2 +- .../minelittlepony/render/RenderPonyMob.java | 6 ++---- 6 files changed, 14 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/minelittlepony/PonyManager.java b/src/main/java/com/minelittlepony/PonyManager.java index 1807f108..0c90bf5e 100644 --- a/src/main/java/com/minelittlepony/PonyManager.java +++ b/src/main/java/com/minelittlepony/PonyManager.java @@ -54,15 +54,8 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl * * @param resource A texture resource */ - public Pony getPony(ResourceLocation resource, boolean slim) { - Pony pony = poniesCache.computeIfAbsent(resource, res -> new Pony(res, slim)); - - if (pony.usesThinArms() != slim) { - pony = new Pony(resource, slim); - poniesCache.put(resource, pony); - } - - return pony; + public Pony getPony(ResourceLocation resource) { + return poniesCache.computeIfAbsent(resource, Pony::new); } /** @@ -101,7 +94,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl * @param uuid id of a player or entity */ public Pony getPony(ResourceLocation resource, UUID uuid) { - Pony pony = getPony(resource, isSlimSkin(uuid)); + Pony pony = getPony(resource); if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) { return getBackgroundPony(uuid); @@ -117,7 +110,7 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl */ public Pony getDefaultPony(UUID uuid) { if (config.getPonyLevel() != PonyLevel.PONIES) { - return getPony(DefaultPlayerSkin.getDefaultSkin(uuid), isSlimSkin(uuid)); + return getPony(DefaultPlayerSkin.getDefaultSkin(uuid)); } return getBackgroundPony(uuid); @@ -125,13 +118,13 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl private Pony getBackgroundPony(UUID uuid) { if (getNumberOfPonies() == 0 || isUser(uuid)) { - return getPony(getDefaultSkin(uuid), isSlimSkin(uuid)); + return getPony(getDefaultSkin(uuid)); } int bgi = uuid.hashCode() % getNumberOfPonies(); while (bgi < 0) bgi += getNumberOfPonies(); - return getPony(backgroundPonyList.get(bgi), false); + return getPony(backgroundPonyList.get(bgi)); } private boolean isUser(UUID uuid) { diff --git a/src/main/java/com/minelittlepony/PonySkinParser.java b/src/main/java/com/minelittlepony/PonySkinParser.java index 85116387..18e8930a 100644 --- a/src/main/java/com/minelittlepony/PonySkinParser.java +++ b/src/main/java/com/minelittlepony/PonySkinParser.java @@ -15,7 +15,7 @@ public class PonySkinParser implements ISkinParser { // TODO use proper model metadata system metadata.put("model", MineLittlePony.getInstance().getManager() - .getPony(resource, slim) + .getPony(resource) .getRace(false) .getModel() .getId(slim)); diff --git a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java index 618fac89..02779d8a 100644 --- a/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java +++ b/src/main/java/com/minelittlepony/hdskins/gui/RenderPonyModel.java @@ -45,7 +45,7 @@ public class RenderPonyModel extends RenderPlayerModel implemen boolean slim = entity.usesThinSkin(); ResourceLocation loc = getEntityTexture(entity); - return MineLittlePony.getInstance().getManager().getPony(loc, slim); + return MineLittlePony.getInstance().getManager().getPony(loc); } @Override @@ -70,7 +70,7 @@ public class RenderPonyModel extends RenderPlayerModel implemen boolean slim = playermodel.usesThinSkin(); - Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc, slim); + Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc); PonyRace race = thePony.getRace(false); @@ -80,7 +80,7 @@ public class RenderPonyModel extends RenderPlayerModel implemen boolean canWet = playermodel.wet && (loc == playermodel.getBlankSkin(Type.SKIN) || race == PonyRace.SEAPONY); - playerModel = canWet ? PlayerModels.SEAPONY.getModel(slim) : thePony.getModel(true); + playerModel = canWet ? PlayerModels.SEAPONY.getModel(slim) : thePony.getRace(true).getModel().getModel(slim); playerModel.apply(thePony.getMetadata()); renderPony.setPonyModel(playerModel); diff --git a/src/main/java/com/minelittlepony/pony/data/Pony.java b/src/main/java/com/minelittlepony/pony/data/Pony.java index b3b92297..656f1a6a 100644 --- a/src/main/java/com/minelittlepony/pony/data/Pony.java +++ b/src/main/java/com/minelittlepony/pony/data/Pony.java @@ -3,10 +3,8 @@ package com.minelittlepony.pony.data; import com.google.common.base.MoreObjects; import com.minelittlepony.MineLittlePony; import com.minelittlepony.mixin.MixinThreadDownloadImageData; -import com.minelittlepony.model.ModelWrapper; import com.voxelmodpack.hdskins.DynamicTextureImage; import com.voxelmodpack.hdskins.ThreadDownloadImageETag; - import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.ITextureObject; @@ -39,12 +37,9 @@ public class Pony { private final ResourceLocation texture; private final IPonyData metadata; - private final boolean smallArms; - - public Pony(ResourceLocation resource, boolean slim) { + public Pony(ResourceLocation resource) { texture = resource; metadata = checkSkin(texture); - smallArms = slim; } private IPonyData checkSkin(ResourceLocation resource) { @@ -135,18 +130,10 @@ public class Pony { return !(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD; } - public ModelWrapper getModel(boolean ignorePony) { - return getRace(ignorePony).getModel().getModel(smallArms); - } - public PonyRace getRace(boolean ignorePony) { return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getEffectivePonyLevel(ignorePony)); } - public boolean usesThinArms() { - return smallArms; - } - public ResourceLocation getTexture() { return texture; } diff --git a/src/main/java/com/minelittlepony/render/PonySkullRenderer.java b/src/main/java/com/minelittlepony/render/PonySkullRenderer.java index b2e4f945..b61e08b3 100644 --- a/src/main/java/com/minelittlepony/render/PonySkullRenderer.java +++ b/src/main/java/com/minelittlepony/render/PonySkullRenderer.java @@ -101,7 +101,7 @@ public class PonySkullRenderer extends TileEntitySkullRenderer implements IRende } else { ResourceLocation skin = skull.getSkinResource(profile); - skull.bindPony(MineLittlePony.getInstance().getManager().getPony(skin, false)); + skull.bindPony(MineLittlePony.getInstance().getManager().getPony(skin)); bindTexture(skin); } diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index 2b4fe37f..a7aa742c 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -10,7 +10,6 @@ import com.minelittlepony.render.layer.LayerPonyArmor; import com.minelittlepony.render.layer.LayerPonyCustomHead; import com.minelittlepony.render.layer.LayerPonyElytra; import com.voxelmodpack.hdskins.HDSkinManager; - import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; @@ -19,9 +18,8 @@ import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; -import javax.annotation.Nonnull; - import java.util.List; +import javax.annotation.Nonnull; public abstract class RenderPonyMob extends RenderLiving implements IRenderPony { @@ -78,7 +76,7 @@ public abstract class RenderPonyMob extends RenderLiving @Override public Pony getEntityPony(T entity) { - return MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity), false); + return MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity)); } @Override