mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Models now work again
This commit is contained in:
parent
a99873f8e6
commit
0657a03703
12 changed files with 111 additions and 96 deletions
|
@ -3,7 +3,7 @@ package com.minelittlepony;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.minelittlepony.gui.PonySettingPanel;
|
||||
import com.minelittlepony.hdskins.gui.GuiSkinsMineLP;
|
||||
import com.minelittlepony.model.PlayerModels;
|
||||
import com.minelittlepony.model.PMAPI;
|
||||
import com.minelittlepony.renderer.RenderPonyEvoker;
|
||||
import com.minelittlepony.renderer.RenderPonyIllusionIllager;
|
||||
import com.minelittlepony.renderer.RenderPonyPigman;
|
||||
|
@ -137,8 +137,8 @@ public class MineLittlePony {
|
|||
}
|
||||
|
||||
public void initialisePlayerRenderers(RenderManager rm) {
|
||||
new RenderPonyPlayer(rm, false, PlayerModels.PONY);
|
||||
new RenderPonyPlayer(rm, true, PlayerModels.PONY);
|
||||
new RenderPonyPlayer(rm, false, "pony", PMAPI.pony);
|
||||
new RenderPonyPlayer(rm, true, "slimpony", PMAPI.ponySmall);
|
||||
}
|
||||
|
||||
public void initializeMobRenderers(RenderManager rm) {
|
||||
|
|
|
@ -107,7 +107,8 @@ public class Pony {
|
|||
}
|
||||
|
||||
public PonyRace getRace(boolean ignorePony) {
|
||||
return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getPonyLevel(ignorePony));
|
||||
return PonyRace.ALICORN;
|
||||
//return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getPonyLevel(ignorePony));
|
||||
}
|
||||
|
||||
public ResourceLocation getTexture() {
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.minelittlepony.ducks.IPlayerInfo;
|
|||
import com.minelittlepony.model.PMAPI;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
|
@ -53,46 +54,47 @@ public class PonyManager implements IResourceManagerReloadListener {
|
|||
return poniesCache.computeIfAbsent(skinResourceLocation, res -> new Pony(res, slim));
|
||||
}
|
||||
|
||||
// TODO: Slim arms
|
||||
public Pony getPony(ResourceLocation skinResourceLocation) {
|
||||
return getPony(skinResourceLocation, false);
|
||||
}
|
||||
|
||||
public Pony getPony(AbstractClientPlayer player) {
|
||||
Pony myLittlePony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms());
|
||||
Pony pony = getPony(player.getLocationSkin(), IPlayerInfo.getPlayerInfo(player).usesSlimArms());
|
||||
|
||||
if (config.getPonyLevel() == PonyLevel.PONIES && myLittlePony.getMetadata().getRace().isHuman()) {
|
||||
return this.getPonyFromBackgroundResourceRegistry(player);
|
||||
if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) {
|
||||
return getBackgroundPony(player.getUniqueID());
|
||||
}
|
||||
|
||||
return myLittlePony;
|
||||
return pony;
|
||||
}
|
||||
|
||||
public Pony getPony(ResourceLocation resource, UUID uuid) {
|
||||
Pony pony = getPony(resource, isSlimSkin(uuid));
|
||||
|
||||
if (config.getPonyLevel() == PonyLevel.PONIES && pony.getMetadata().getRace().isHuman()) {
|
||||
return getBackgroundPony(uuid);
|
||||
}
|
||||
|
||||
return pony;
|
||||
}
|
||||
|
||||
public Pony getDefaultPony(UUID uuid) {
|
||||
if (config.getPonyLevel() != PonyLevel.PONIES) {
|
||||
return getPony(DefaultPlayerSkin.getDefaultSkin(uuid), isSlimSkin(uuid));
|
||||
}
|
||||
|
||||
return getBackgroundPony(uuid);
|
||||
}
|
||||
|
||||
private Pony getBackgroundPony(UUID uuid) {
|
||||
if (getNumberOfPonies() == 0) return getPony(getDefaultSkin(uuid), isSlimSkin(uuid));
|
||||
|
||||
int bgi = uuid.hashCode() % this.getNumberOfPonies();
|
||||
while (bgi < 0) bgi += this.getNumberOfPonies();
|
||||
|
||||
return getPony(backgroundPonyList.get(bgi), false);
|
||||
}
|
||||
|
||||
public Pony removePony(ResourceLocation location) {
|
||||
return poniesCache.remove(location);
|
||||
}
|
||||
|
||||
private ResourceLocation getBackgroundPonyResource(UUID id) {
|
||||
if (getNumberOfPonies() > 0) {
|
||||
int backgroundIndex = id.hashCode() % this.getNumberOfPonies();
|
||||
if (backgroundIndex < 0) {
|
||||
backgroundIndex += this.getNumberOfPonies();
|
||||
}
|
||||
|
||||
return backgroundPonyList.get(backgroundIndex);
|
||||
}
|
||||
return STEVE;
|
||||
}
|
||||
|
||||
private Pony getPonyFromBackgroundResourceRegistry(AbstractClientPlayer player) {
|
||||
return backgroudPoniesCache.computeIfAbsent(getDefaultPonyResource(player), res -> new Pony(res, false));
|
||||
}
|
||||
|
||||
private ResourceLocation getDefaultPonyResource(AbstractClientPlayer player) {
|
||||
if (player.isUser()) return getDefaultSkin(player.getUniqueID());
|
||||
return getBackgroundPonyResource(player.getUniqueID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
this.poniesCache.clear();
|
||||
|
@ -117,7 +119,11 @@ public class PonyManager implements IResourceManagerReloadListener {
|
|||
}
|
||||
|
||||
private ResourceLocation getDefaultSkin(UUID uuid) {
|
||||
return (uuid.hashCode() & 1) == 0 ? STEVE : ALEX;
|
||||
return isSlimSkin(uuid) ? ALEX : STEVE;
|
||||
}
|
||||
|
||||
public static boolean isSlimSkin(UUID uuid) {
|
||||
return (uuid.hashCode() & 1) == 1;
|
||||
}
|
||||
|
||||
private int getNumberOfPonies() {
|
||||
|
|
|
@ -31,7 +31,7 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> {
|
|||
return super.getEntityModel(playermodel);
|
||||
}
|
||||
|
||||
Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc);
|
||||
Pony thePony = MineLittlePony.getInstance().getManager().getPony(loc, playermodel.profile.getId());
|
||||
|
||||
PlayerModel pm = thePony.getModel(true);
|
||||
pm.apply(thePony.getMetadata());
|
||||
|
|
|
@ -8,7 +8,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.Pony;
|
||||
import com.minelittlepony.PonyManager;
|
||||
import com.minelittlepony.ducks.IPlayerInfo;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -22,25 +24,26 @@ public abstract class MixinNetworkPlayerInfo implements IPlayerInfo {
|
|||
@Shadow
|
||||
public abstract ResourceLocation getLocationSkin();
|
||||
|
||||
@Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN"))
|
||||
private void getSkinType(CallbackInfoReturnable<String> info) {
|
||||
ResourceLocation skin = getLocationSkin();
|
||||
if (skin != null) {
|
||||
info.setReturnValue(getPony(skin).getRace(false).getModel().getId(usesSlimArms()));
|
||||
}
|
||||
}
|
||||
@Shadow
|
||||
public abstract GameProfile getGameProfile();
|
||||
|
||||
protected Pony getPony(ResourceLocation skin) {
|
||||
return MineLittlePony.getInstance().getManager().getPony(skin, usesSlimArms());
|
||||
@Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN"), cancellable = true)
|
||||
private void getSkinType(CallbackInfoReturnable<String> info) {
|
||||
info.setReturnValue(getPony().getRace(false).getModel().getId(usesSlimArms()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pony getPony() {
|
||||
return getPony(getLocationSkin());
|
||||
ResourceLocation skin = getLocationSkin();
|
||||
if (skin == null) {
|
||||
return MineLittlePony.getInstance().getManager().getDefaultPony(getGameProfile().getId());
|
||||
}
|
||||
return MineLittlePony.getInstance().getManager().getPony(skin, getGameProfile().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesSlimArms() {
|
||||
return skinType == "slim";
|
||||
if (skinType == null) return PonyManager.isSlimSkin(getGameProfile().getId());
|
||||
return "slim".equals(skinType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ public class ModelWing implements PonyModelConstants {
|
|||
}
|
||||
|
||||
private void init(float x, float y, float scale) {
|
||||
initFeather(folded[0], y, x, 2.0F, 6, scale);
|
||||
initFeather(folded[1], y, x, 4.0F, 8, scale);
|
||||
initFeather(folded[2], y, x, 6.0F, 6, scale);
|
||||
initFeather(folded[0], y, x, 2F, 6, scale);
|
||||
initFeather(folded[1], y, x, 4F, 8, scale);
|
||||
initFeather(folded[2], y, x, 6F, 6, scale);
|
||||
}
|
||||
|
||||
private void initFeather(ModelRenderer wing, float y, float x, float z, int h, float scale) {
|
||||
|
@ -69,16 +69,12 @@ public class ModelWing implements PonyModelConstants {
|
|||
extended[5].rotateAngleX -= 0.85F;
|
||||
}
|
||||
|
||||
private void renderWing(ModelRenderer[] wing, float scale) {
|
||||
for (ModelRenderer feather : wing) {
|
||||
public void render(boolean standing, float scale) {
|
||||
for (ModelRenderer feather : (standing ? folded : extended)) {
|
||||
feather.render(scale);
|
||||
}
|
||||
}
|
||||
|
||||
public void render(boolean standing, float scale) {
|
||||
renderWing(standing ? folded : extended, scale);
|
||||
}
|
||||
|
||||
public void rotateSneaked(float rotZ) {
|
||||
for (ModelRenderer feather : extended) {
|
||||
feather.rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
||||
|
|
|
@ -7,16 +7,16 @@ import net.minecraft.util.math.MathHelper;
|
|||
public class PegasusWings extends ModelBase implements PonyModelConstants {
|
||||
|
||||
private final AbstractPonyModel pony;
|
||||
|
||||
|
||||
public final ModelWing leftWing, rightWing;
|
||||
|
||||
|
||||
public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) {
|
||||
this.pony = pony;
|
||||
|
||||
leftWing = new ModelWing(pony, false, 4f, yOffset, stretch, 32);
|
||||
rightWing = new ModelWing(pony, true, -6f, yOffset, stretch, 16);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ticks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class PegasusWings extends ModelBase implements PonyModelConstants {
|
|||
leftWing.rotate(ROTATE_90);
|
||||
rightWing.rotate(ROTATE_90);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
|
||||
if (pony.metadata.getRace().hasWings()) {
|
||||
|
|
|
@ -1,27 +1,33 @@
|
|||
package com.minelittlepony.model;
|
||||
|
||||
public class PlayerModels {
|
||||
public static final PlayerModels
|
||||
HUMAN = new PlayerModels("default", "slim", PMAPI.human, PMAPI.humanSmall),
|
||||
PONY = new PlayerModels("pony", "slimpony", PMAPI.pony, PMAPI.ponySmall);
|
||||
|
||||
private final PlayerModel normal, slim;
|
||||
|
||||
private final String normalKey, slimKey;
|
||||
|
||||
public PlayerModels(String normalKey, String slimKey, PlayerModel normal, PlayerModel slim) {
|
||||
this.normalKey = normalKey;
|
||||
this.slimKey = slimKey;
|
||||
|
||||
this.normal = normal;
|
||||
this.slim = slim;
|
||||
}
|
||||
|
||||
public PlayerModel getModel(boolean slim) {
|
||||
return slim ? this.slim : this.normal;
|
||||
}
|
||||
|
||||
public String getId(boolean useSlimArms) {
|
||||
return useSlimArms ? slimKey : normalKey;
|
||||
}
|
||||
public enum PlayerModels {
|
||||
HUMAN("default", "slim", () -> PMAPI.human, () -> PMAPI.humanSmall),
|
||||
PONY("pony", "slimpony", () -> PMAPI.pony, () -> PMAPI.ponySmall);
|
||||
|
||||
private final ModelResolver normal, slim;
|
||||
|
||||
private final String normalKey, slimKey;
|
||||
|
||||
PlayerModels(String normalKey, String slimKey, ModelResolver normal, ModelResolver slim) {
|
||||
this.normalKey = normalKey;
|
||||
this.slimKey = slimKey;
|
||||
|
||||
this.normal = normal;
|
||||
this.slim = slim;
|
||||
}
|
||||
|
||||
public PlayerModel getModel(boolean slim) {
|
||||
return slim ? this.slim.resolve() : this.normal.resolve();
|
||||
}
|
||||
|
||||
public String getId(boolean useSlimArms) {
|
||||
return useSlimArms ? slimKey : normalKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME: PMAPI fields are null when the game starts.
|
||||
*/
|
||||
static interface ModelResolver {
|
||||
PlayerModel resolve();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
|||
this.playerModel.getModel().isSleeping = false;
|
||||
|
||||
ResourceLocation loc = getEntityTexture(entity);
|
||||
this.playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc).getMetadata());
|
||||
this.playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc, false).getMetadata());
|
||||
|
||||
if (mainModel.isChild) {
|
||||
this.shadowSize = 0.25F;
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.minelittlepony.ducks.IRenderManager;
|
|||
import com.minelittlepony.ducks.IRenderPony;
|
||||
import com.minelittlepony.model.AbstractPonyModel;
|
||||
import com.minelittlepony.model.PlayerModel;
|
||||
import com.minelittlepony.model.PlayerModels;
|
||||
import com.minelittlepony.model.pony.ModelPlayerPony;
|
||||
import com.minelittlepony.renderer.layer.LayerEntityOnPonyShoulder;
|
||||
import com.minelittlepony.renderer.layer.LayerHeldPonyItem;
|
||||
|
@ -20,6 +19,7 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerArrow;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony {
|
||||
|
||||
|
@ -30,16 +30,16 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
|
|||
|
||||
private Pony pony;
|
||||
|
||||
public RenderPonyBase(RenderManager manager, boolean useSmallArms, PlayerModels model) {
|
||||
public RenderPonyBase(RenderManager manager, boolean useSmallArms, String id, PlayerModel model) {
|
||||
super(manager, useSmallArms);
|
||||
smallArms = useSmallArms;
|
||||
|
||||
setPlayerModel(model.getModel(useSmallArms));
|
||||
setPlayerModel(model);
|
||||
|
||||
layerRenderers.clear();
|
||||
addExtraLayers();
|
||||
|
||||
((IRenderManager)manager).addPlayerSkin(model.getId(useSmallArms), this);
|
||||
((IRenderManager)manager).addPlayerSkin(id, this);
|
||||
}
|
||||
|
||||
protected void addExtraLayers() {
|
||||
|
@ -75,12 +75,14 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
|
|||
@Override
|
||||
public void renderRightArm(AbstractClientPlayer player) {
|
||||
updateModel(player);
|
||||
bindEntityTexture(player);
|
||||
super.renderRightArm(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderLeftArm(AbstractClientPlayer player) {
|
||||
updateModel(player);
|
||||
bindEntityTexture(player);
|
||||
super.renderLeftArm(player);
|
||||
}
|
||||
|
||||
|
@ -126,9 +128,9 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
|
|||
GlStateManager.rotate((float) Math.toDegrees(angle), 1, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractPonyModel getMainModel() {
|
||||
return (AbstractPonyModel)super.getMainModel();
|
||||
public ResourceLocation getEntityTexture(AbstractClientPlayer entity) {
|
||||
updateModel(entity);
|
||||
return pony.getTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package com.minelittlepony.renderer.player;
|
||||
|
||||
import com.minelittlepony.MineLittlePony;
|
||||
import com.minelittlepony.model.PlayerModels;
|
||||
import com.minelittlepony.model.PlayerModel;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
|
||||
public class RenderPonyPlayer extends RenderPonyBase {
|
||||
public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, PlayerModels model) {
|
||||
super(renderManager, useSmallArms, model);
|
||||
public RenderPonyPlayer(RenderManager renderManager, boolean useSmallArms, String id, PlayerModel model) {
|
||||
super(renderManager, useSmallArms, id, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"mixins": [
|
||||
"MixinThreadDownloadImageData",
|
||||
"MixinNetworkPlayerInfo",
|
||||
"MixinRenderItem"
|
||||
"MixinRenderItem",
|
||||
"MixinRenderManager"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue