Improve pony resolution

This commit is contained in:
Matthew Messinger 2019-07-03 22:06:00 -04:00
parent 6f6182e331
commit f8a0bc308c
9 changed files with 32 additions and 83 deletions

View file

@ -1,18 +0,0 @@
package com.minelittlepony.client.hdskins;
import com.minelittlepony.client.settings.ClientPonyConfig;
import com.minelittlepony.hdskins.HDSkins;
import com.minelittlepony.settings.PonyLevel;
class ClientPonyConfigHDSkins extends ClientPonyConfig {
@Override
public void setPonyLevel(PonyLevel ponylevel) {
// only trigger reloads when the value actually changes
if (ponylevel != getPonyLevel()) {
HDSkins.getInstance().getSkinParser().execute();
}
super.setPonyLevel(ponylevel);
}
}

View file

@ -13,14 +13,9 @@ public class HDSkinsProxy extends SkinsProxy {
public Identifier getSkinTexture(GameProfile profile) {
Identifier skin = HDSkins.getInstance().getTextures(profile).get(MinecraftProfileTexture.Type.SKIN);
if (skin != null && Pony.getBufferedImage(skin) != null) {
if (skin != null) {
return skin;
}
return super.getSkinTexture(profile);
}
@Override
public void parseSkins() {
HDSkins.getInstance().getSkinParser().execute();
}
}

View file

@ -57,9 +57,4 @@ public class MineLPHDSkins {
// Ponify the skins GUI.
manager.setSkinsGui(GuiSkinsMineLP::new);
}
// @Override
protected ClientPonyConfig createConfig() {
return new ClientPonyConfigHDSkins();
}
}

View file

@ -5,7 +5,6 @@ import com.minelittlepony.client.gui.GuiPonySettings;
import com.minelittlepony.client.pony.PonyManager;
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
import com.minelittlepony.client.settings.ClientPonyConfig;
import com.minelittlepony.common.event.SkinAvailableCallback;
import com.minelittlepony.common.util.GamePaths;
import com.minelittlepony.settings.JsonConfig;
import com.minelittlepony.settings.PonyConfig;
@ -53,9 +52,6 @@ public class MineLPClient extends MineLittlePony {
KeyBindingRegistry.INSTANCE.register(keyBinding);
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ponyManager);
// Parse trigger pixel data
SkinAvailableCallback.EVENT.register(new PonySkinParser());
}
protected ClientPonyConfig createConfig() {

View file

@ -1,35 +0,0 @@
package com.minelittlepony.client;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.model.races.PlayerModels;
import com.minelittlepony.common.event.SkinAvailableCallback;
import com.minelittlepony.common.util.ProfileTextureUtil;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.util.Identifier;
import java.util.HashMap;
import java.util.Map;
public class PonySkinParser implements SkinAvailableCallback {
@Override
public void onSkinAvailable(MinecraftProfileTexture.Type type, Identifier id, MinecraftProfileTexture texture) {
if (type == MinecraftProfileTexture.Type.SKIN) {
Map<String, String> metadata = ProfileTextureUtil.getMetadata(texture);
if (metadata == null) {
metadata = new HashMap<>();
ProfileTextureUtil.setMetadata(texture, metadata);
}
boolean slim = "slim".equals(metadata.get("model"));
// TODO use proper model metadata system
metadata.put("model", PlayerModels.forRace(MineLittlePony.getInstance().getManager()
.getPony(id)
.getRace(false))
.getId(slim));
}
}
}

View file

@ -1,6 +1,5 @@
package com.minelittlepony.client;
import com.minelittlepony.client.pony.Pony;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.client.MinecraftClient;
@ -18,16 +17,6 @@ public class SkinsProxy {
PlayerSkinProvider skins = MinecraftClient.getInstance().getSkinProvider();
MinecraftProfileTexture texture = skins.getTextures(profile).get(MinecraftProfileTexture.Type.SKIN);
Identifier loc = skins.loadSkin(texture, MinecraftProfileTexture.Type.SKIN);
if (Pony.getBufferedImage(loc) != null) {
return loc;
}
return null;
}
public void parseSkins() {
// TODO probably doesn't work without hdskins installed.
// Find a way to re-parse skins without help of hdskins
return skins.loadSkin(texture, MinecraftProfileTexture.Type.SKIN);
}
}

View file

@ -0,0 +1,26 @@
package com.minelittlepony.client.mixin;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.client.model.races.PlayerModels;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(EntityRenderDispatcher.class)
public class MixinEntityRenderDispatcher {
@Redirect(
method = "getRenderer(Lnet/minecraft/entity/Entity;)Lnet/minecraft/client/render/entity/EntityRenderer;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getModel()Ljava/lang/String;"))
private String getPlayerModel(AbstractClientPlayerEntity player, Entity entity) {
return PlayerModels.forRace(MineLittlePony.getInstance().getManager()
.getPony(player)
.getRace(false))
.getId(player.getModel().contains("slim"));
}
}

View file

@ -71,14 +71,14 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
@Override
public IPony getPony(PlayerEntity player) {
if (player == null || player.getGameProfile() == null) {
if (player.getGameProfile() == null) {
return getDefaultPony(player.getUuid());
}
Identifier skin = getSkin(player);
UUID uuid = player.getGameProfile().getId();
if (Pony.getBufferedImage(skin) == null) {
if (skin == null) {
return getDefaultPony(uuid);
}
@ -86,7 +86,7 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
}
@Nullable
Identifier getSkin(PlayerEntity player) {
private Identifier getSkin(PlayerEntity player) {
if (player instanceof AbstractClientPlayerEntity) {
return ((AbstractClientPlayerEntity)player).getSkinTexture();
}

View file

@ -8,6 +8,7 @@
"IResizeable",
"MixinCamera",
"MixinDefaultPlayerSkin",
"MixinEntityRenderDispatcher",
"MixinFirstPersonRenderer",
"MixinGlStateManager",
"MixinItemRenderer",