mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-18 02:24:22 +01:00
Tidy up the codebase first
This commit is contained in:
parent
45282b147a
commit
0e530d9572
13 changed files with 38 additions and 64 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<BufferedImage> 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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ResourceLocation> ci) {
|
||||
getTextureLocation(ci, Type.SKIN);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "getLocationCape",
|
||||
@Inject(method = "getLocationCape",
|
||||
cancellable = true,
|
||||
at = @At("RETURN"))
|
||||
private void getLocationCape(CallbackInfoReturnable<ResourceLocation> ci) {
|
||||
getTextureLocation(ci, Type.CAPE);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "getLocationElytra",
|
||||
@Inject(method = "getLocationElytra",
|
||||
cancellable = true,
|
||||
at = @At("RETURN"))
|
||||
private void getLocationElytra(CallbackInfoReturnable<ResourceLocation> ci) {
|
||||
|
@ -45,24 +40,20 @@ public abstract class MixinPlayerInfo {
|
|||
}
|
||||
|
||||
private void getTextureLocation(CallbackInfoReturnable<ResourceLocation> ci, Type type) {
|
||||
Optional<ResourceLocation> 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<String> 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<ResourceLocation> 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<TileEntitySkull> {
|
||||
|
||||
@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<ResourceLocation> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class ImageLoader implements Supplier<ResourceLocation> {
|
|||
private final ResourceLocation original;
|
||||
|
||||
public ImageLoader(ResourceLocation loc) {
|
||||
this.original = loc;
|
||||
original = loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,7 +49,6 @@ public class ImageLoader implements Supplier<ResourceLocation> {
|
|||
|
||||
@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<ResourceLocation> {
|
|||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ public class NetClient {
|
|||
return this;
|
||||
}
|
||||
|
||||
// TODO: Fix this
|
||||
public MoreHttpResponses send() throws IOException {
|
||||
HttpUriRequest request = rqBuilder.build();
|
||||
|
||||
|
|
|
@ -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> T readJson(MoreHttpResponses resp, Class<T> 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);
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
package com.voxelmodpack.hdskins.upload;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
|
@ -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<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony<T> {
|
||||
|
||||
protected RenderPony<T> renderPony = new RenderPony<T>(this);
|
||||
|
|
|
@ -101,7 +101,7 @@ public class LayerPonyCustomHead<T extends EntityLivingBase> implements LayerRen
|
|||
}
|
||||
|
||||
private ModelWrapper getModel() {
|
||||
return ((IRenderPony) renderer).getModelWrapper();
|
||||
return ((IRenderPony<?>) renderer).getModelWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue