Remove slim from Pony class.

This commit is contained in:
Matthew Messinger 2018-08-26 15:32:17 -04:00
parent dfcae69ab7
commit d9ddd3f842
6 changed files with 14 additions and 36 deletions

View file

@ -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) {

View file

@ -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));

View file

@ -45,7 +45,7 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> 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<EntityPonyModel> 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<EntityPonyModel> 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);

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony<T> {
@ -78,7 +76,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
@Override
public Pony getEntityPony(T entity) {
return MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity), false);
return MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity));
}
@Override