diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/DynamicTextureImage.java b/src/hdskins/java/com/voxelmodpack/hdskins/DynamicTextureImage.java index d7598b08..87d7c945 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/DynamicTextureImage.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/DynamicTextureImage.java @@ -10,7 +10,7 @@ public class DynamicTextureImage extends DynamicTexture { public DynamicTextureImage(BufferedImage bufferedImage) { super(bufferedImage); - this.image = bufferedImage; + image = bufferedImage; } public BufferedImage getImage() { @@ -20,7 +20,7 @@ public class DynamicTextureImage extends DynamicTexture { @Override public void deleteGlTexture() { super.deleteGlTexture(); - this.image = null; + image = null; } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java index 4daeaf5d..d60f0203 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java @@ -63,6 +63,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener { public static final ExecutorService skinUploadExecutor = Executors.newSingleThreadExecutor(); public static final ExecutorService skinDownloadExecutor = Executors.newFixedThreadPool(8); + // TODO: This doesn't belong here public static final CloseableHttpClient httpClient = HttpClients.createSystem(); private static final ResourceLocation LOADING = new ResourceLocation("LOADING"); @@ -254,6 +255,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener { this.skinServers.add(skinServer); } + // TODO: Why is this deprecated? @Deprecated public SkinServer getGatewayServer() { return this.skinServers.get(0); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/TextureLoader.java b/src/hdskins/java/com/voxelmodpack/hdskins/TextureLoader.java index 959e0131..92dbd8db 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/TextureLoader.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/TextureLoader.java @@ -6,9 +6,11 @@ import net.minecraft.util.ResourceLocation; public class TextureLoader { - private static Minecraft mc = Minecraft.getMinecraft(); + private static final Minecraft mc = Minecraft.getMinecraft(); - public static void loadTexture(final ResourceLocation textureLocation, final ITextureObject textureObj) { - mc.addScheduledTask((Runnable) () -> mc.getTextureManager().loadTexture(textureLocation, textureObj)); + public static void loadTexture(ResourceLocation textureLocation, ITextureObject textureObj) { + mc.addScheduledTask(() -> { + mc.getTextureManager().loadTexture(textureLocation, textureObj); + }); } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GLWindow.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GLWindow.java index d6ef280b..9df285cb 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GLWindow.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GLWindow.java @@ -5,7 +5,6 @@ import com.voxelmodpack.hdskins.upload.awt.FileDropper; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.DefaultResourcePack; -import net.minecraft.launchwrapper.injector.VanillaTweakInjector; import net.minecraft.util.ResourceLocation; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; @@ -21,7 +20,6 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; import java.io.IOException; import java.util.ArrayList; import java.util.TooManyListenersException; diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java index 58be43b9..1640eadd 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java @@ -8,25 +8,18 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.awt.Graphics; import java.awt.image.BufferedImage; @Mixin(ImageBufferDownload.class) public abstract class MixinImageBufferDownload implements IImageBuffer { - @Inject( - method = "parseUserSkin(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;", + @Inject(method = "parseUserSkin(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;", at = @At("RETURN"), cancellable = true) private void update(BufferedImage image, CallbackInfoReturnable ci) { // convert skins from mojang server - BufferedImage image2 = ci.getReturnValue(); - boolean isLegacy = image.getHeight() == 32; - if (isLegacy) { - Graphics graphics = image2.getGraphics(); - HDSkinManager.INSTANCE.convertSkin(image2, graphics); - graphics.dispose(); + if (image.getHeight() == 32) { + HDSkinManager.INSTANCE.convertSkin(ci.getReturnValue()); } } - } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java index 432c383d..8575b7f3 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java @@ -12,32 +12,27 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.Optional; - @Mixin(NetworkPlayerInfo.class) public abstract class MixinPlayerInfo { @Shadow public abstract GameProfile getGameProfile(); - @Inject( - method = "getLocationSkin", + @Inject(method = "getLocationSkin", cancellable = true, at = @At("RETURN")) private void getLocationSkin(CallbackInfoReturnable ci) { getTextureLocation(ci, Type.SKIN); } - @Inject( - method = "getLocationCape", + @Inject(method = "getLocationCape", cancellable = true, at = @At("RETURN")) private void getLocationCape(CallbackInfoReturnable ci) { getTextureLocation(ci, Type.CAPE); } - @Inject( - method = "getLocationElytra", + @Inject(method = "getLocationElytra", cancellable = true, at = @At("RETURN")) private void getLocationElytra(CallbackInfoReturnable ci) { @@ -45,24 +40,20 @@ public abstract class MixinPlayerInfo { } private void getTextureLocation(CallbackInfoReturnable ci, Type type) { - Optional texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), type, true); - texture.ifPresent(ci::setReturnValue); + HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), type, true).ifPresent(ci::setReturnValue); } - @Inject( - method = "getSkinType", + @Inject(method = "getSkinType", cancellable = true, at = @At("RETURN")) private void getSkinType(CallbackInfoReturnable ci) { MinecraftProfileTexture skin = HDSkinManager.INSTANCE.getProfileData(getGameProfile()).get(Type.SKIN); if (skin != null) { - String type = skin.getMetadata("model"); - if (type == null) - type = "default"; - String type1 = type; - Optional texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false); + HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false).ifPresent(res -> { + String type = skin.getMetadata("model"); - texture.ifPresent((res) -> ci.setReturnValue(type1)); + ci.setReturnValue(type == null ? "default" : type); + }); } } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java index dda9662c..cf49650c 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java @@ -3,6 +3,7 @@ package com.voxelmodpack.hdskins.mixin; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.voxelmodpack.hdskins.HDSkinManager; + import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntitySkull; @@ -13,27 +14,20 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import javax.annotation.Nullable; -import java.util.Optional; @Mixin(TileEntitySkullRenderer.class) public abstract class MixinSkullRenderer extends TileEntitySpecialRenderer { - @Redirect( - method = "renderSkull", - at = @At( - value = "INVOKE", + @Redirect(method = "renderSkull", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;bindTexture(Lnet/minecraft/util/ResourceLocation;)V", ordinal = 4)) - private void onBindTexture(TileEntitySkullRenderer tesr, ResourceLocation rl, float x, float y, float z, EnumFacing facing, float rotation, int meta, - @Nullable GameProfile profile, int p_180543_8_, float ticks) { + private void onBindTexture(TileEntitySkullRenderer tesr, ResourceLocation rl, float x, float y, float z, // ow my back + EnumFacing facing, float rotation, int meta, @Nullable GameProfile profile, int a, float ticks) { if (profile != null) { - Optional skin = HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true); - if (skin.isPresent()) - // rebind - bindTexture(skin.get()); - else - bindTexture(rl); - } else + bindTexture(HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true).orElse(rl)); + } else { bindTexture(rl); + } } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java b/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java index 6a4ff50f..59bbd11a 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/resource/ImageLoader.java @@ -21,7 +21,7 @@ public class ImageLoader implements Supplier { private final ResourceLocation original; public ImageLoader(ResourceLocation loc) { - this.original = loc; + original = loc; } @Override @@ -49,7 +49,6 @@ public class ImageLoader implements Supplier { @Nullable private static BufferedImage getImage(ResourceLocation res) { - try (InputStream in = mc.getResourceManager().getResource(res).getInputStream()) { return TextureUtil.readBufferedImage(in); } catch (IOException e) { @@ -59,9 +58,9 @@ public class ImageLoader implements Supplier { @Nullable private ResourceLocation loadSkin(BufferedImage image) { - ResourceLocation conv = new ResourceLocation(original.getResourceDomain() + "-converted", original.getResourcePath()); boolean success = mc.getTextureManager().loadTexture(conv, new DynamicTextureImage(image)); + return success ? conv : null; } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/NetClient.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/NetClient.java index 8f7a54c1..8f9ce406 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/NetClient.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/NetClient.java @@ -40,6 +40,7 @@ public class NetClient { return this; } + // TODO: Fix this public MoreHttpResponses send() throws IOException { HttpUriRequest request = rqBuilder.build(); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java index 4271d36f..074d5acc 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/ValhallaSkinServer.java @@ -42,6 +42,7 @@ public class ValhallaSkinServer implements SkinServer { this.address = address; } + @Override public MinecraftTexturesPayload loadProfileData(GameProfile profile) throws IOException { @@ -138,7 +139,7 @@ public class ValhallaSkinServer implements SkinServer { return; } GameProfile profile = session.getProfile(); - String token = session.getToken(); + AuthHandshake handshake = authHandshake(profile.getName()); if (handshake.offline) { @@ -146,7 +147,7 @@ public class ValhallaSkinServer implements SkinServer { } // join the session server - Minecraft.getMinecraft().getSessionService().joinServer(profile, token, handshake.serverId); + Minecraft.getMinecraft().getSessionService().joinServer(profile, session.getToken(), handshake.serverId); AuthResponse response = authResponse(profile.getName(), handshake.verifyToken); if (!response.userId.equals(profile.getId())) { @@ -157,9 +158,11 @@ public class ValhallaSkinServer implements SkinServer { private T readJson(MoreHttpResponses resp, Class cl) throws IOException { String type = resp.getResponse().getEntity().getContentType().getValue(); + if (!"application/json".equals(type)) { throw new IOException("Server returned a non-json response!"); } + if (resp.ok()) { return resp.json(cl); } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/upload/package-info.java b/src/hdskins/java/com/voxelmodpack/hdskins/upload/package-info.java deleted file mode 100644 index 188351cf..00000000 --- a/src/hdskins/java/com/voxelmodpack/hdskins/upload/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault -package com.voxelmodpack.hdskins.upload; - -import mcp.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/minelittlepony/render/RenderPonyMob.java b/src/main/java/com/minelittlepony/render/RenderPonyMob.java index e07ddf75..5b7bad04 100644 --- a/src/main/java/com/minelittlepony/render/RenderPonyMob.java +++ b/src/main/java/com/minelittlepony/render/RenderPonyMob.java @@ -20,8 +20,6 @@ import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; -// TODO: A lot of this duplicates RenderPonyPlayer -// and is the whole reason we had this scaling bug in the first place. public abstract class RenderPonyMob extends RenderLiving implements IRenderPony { protected RenderPony renderPony = new RenderPony(this); diff --git a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java index f5900193..9b906e47 100644 --- a/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java +++ b/src/main/java/com/minelittlepony/render/layer/LayerPonyCustomHead.java @@ -101,7 +101,7 @@ public class LayerPonyCustomHead implements LayerRen } private ModelWrapper getModel() { - return ((IRenderPony) renderer).getModelWrapper(); + return ((IRenderPony) renderer).getModelWrapper(); } @Override