mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +01:00
Improve pony resolution
This commit is contained in:
parent
6f6182e331
commit
f8a0bc308c
9 changed files with 32 additions and 83 deletions
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -13,14 +13,9 @@ public class HDSkinsProxy extends SkinsProxy {
|
||||||
public Identifier getSkinTexture(GameProfile profile) {
|
public Identifier getSkinTexture(GameProfile profile) {
|
||||||
|
|
||||||
Identifier skin = HDSkins.getInstance().getTextures(profile).get(MinecraftProfileTexture.Type.SKIN);
|
Identifier skin = HDSkins.getInstance().getTextures(profile).get(MinecraftProfileTexture.Type.SKIN);
|
||||||
if (skin != null && Pony.getBufferedImage(skin) != null) {
|
if (skin != null) {
|
||||||
return skin;
|
return skin;
|
||||||
}
|
}
|
||||||
return super.getSkinTexture(profile);
|
return super.getSkinTexture(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parseSkins() {
|
|
||||||
HDSkins.getInstance().getSkinParser().execute();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,4 @@ public class MineLPHDSkins {
|
||||||
// Ponify the skins GUI.
|
// Ponify the skins GUI.
|
||||||
manager.setSkinsGui(GuiSkinsMineLP::new);
|
manager.setSkinsGui(GuiSkinsMineLP::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
protected ClientPonyConfig createConfig() {
|
|
||||||
return new ClientPonyConfigHDSkins();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.minelittlepony.client.gui.GuiPonySettings;
|
||||||
import com.minelittlepony.client.pony.PonyManager;
|
import com.minelittlepony.client.pony.PonyManager;
|
||||||
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
|
import com.minelittlepony.client.render.tileentities.skull.PonySkullRenderer;
|
||||||
import com.minelittlepony.client.settings.ClientPonyConfig;
|
import com.minelittlepony.client.settings.ClientPonyConfig;
|
||||||
import com.minelittlepony.common.event.SkinAvailableCallback;
|
|
||||||
import com.minelittlepony.common.util.GamePaths;
|
import com.minelittlepony.common.util.GamePaths;
|
||||||
import com.minelittlepony.settings.JsonConfig;
|
import com.minelittlepony.settings.JsonConfig;
|
||||||
import com.minelittlepony.settings.PonyConfig;
|
import com.minelittlepony.settings.PonyConfig;
|
||||||
|
@ -53,9 +52,6 @@ public class MineLPClient extends MineLittlePony {
|
||||||
KeyBindingRegistry.INSTANCE.register(keyBinding);
|
KeyBindingRegistry.INSTANCE.register(keyBinding);
|
||||||
|
|
||||||
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ponyManager);
|
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ponyManager);
|
||||||
|
|
||||||
// Parse trigger pixel data
|
|
||||||
SkinAvailableCallback.EVENT.register(new PonySkinParser());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ClientPonyConfig createConfig() {
|
protected ClientPonyConfig createConfig() {
|
||||||
|
|
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.minelittlepony.client;
|
package com.minelittlepony.client;
|
||||||
|
|
||||||
import com.minelittlepony.client.pony.Pony;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
@ -18,16 +17,6 @@ public class SkinsProxy {
|
||||||
PlayerSkinProvider skins = MinecraftClient.getInstance().getSkinProvider();
|
PlayerSkinProvider skins = MinecraftClient.getInstance().getSkinProvider();
|
||||||
|
|
||||||
MinecraftProfileTexture texture = skins.getTextures(profile).get(MinecraftProfileTexture.Type.SKIN);
|
MinecraftProfileTexture texture = skins.getTextures(profile).get(MinecraftProfileTexture.Type.SKIN);
|
||||||
Identifier loc = skins.loadSkin(texture, MinecraftProfileTexture.Type.SKIN);
|
return 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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -71,14 +71,14 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPony getPony(PlayerEntity player) {
|
public IPony getPony(PlayerEntity player) {
|
||||||
if (player == null || player.getGameProfile() == null) {
|
if (player.getGameProfile() == null) {
|
||||||
return getDefaultPony(player.getUuid());
|
return getDefaultPony(player.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier skin = getSkin(player);
|
Identifier skin = getSkin(player);
|
||||||
UUID uuid = player.getGameProfile().getId();
|
UUID uuid = player.getGameProfile().getId();
|
||||||
|
|
||||||
if (Pony.getBufferedImage(skin) == null) {
|
if (skin == null) {
|
||||||
return getDefaultPony(uuid);
|
return getDefaultPony(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class PonyManager implements IPonyManager, IdentifiableResourceReloadList
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
Identifier getSkin(PlayerEntity player) {
|
private Identifier getSkin(PlayerEntity player) {
|
||||||
if (player instanceof AbstractClientPlayerEntity) {
|
if (player instanceof AbstractClientPlayerEntity) {
|
||||||
return ((AbstractClientPlayerEntity)player).getSkinTexture();
|
return ((AbstractClientPlayerEntity)player).getSkinTexture();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"IResizeable",
|
"IResizeable",
|
||||||
"MixinCamera",
|
"MixinCamera",
|
||||||
"MixinDefaultPlayerSkin",
|
"MixinDefaultPlayerSkin",
|
||||||
|
"MixinEntityRenderDispatcher",
|
||||||
"MixinFirstPersonRenderer",
|
"MixinFirstPersonRenderer",
|
||||||
"MixinGlStateManager",
|
"MixinGlStateManager",
|
||||||
"MixinItemRenderer",
|
"MixinItemRenderer",
|
||||||
|
|
Loading…
Reference in a new issue