mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-21 20:03:10 +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) {
|
public DynamicTextureImage(BufferedImage bufferedImage) {
|
||||||
super(bufferedImage);
|
super(bufferedImage);
|
||||||
this.image = bufferedImage;
|
image = bufferedImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage getImage() {
|
public BufferedImage getImage() {
|
||||||
|
@ -20,7 +20,7 @@ public class DynamicTextureImage extends DynamicTexture {
|
||||||
@Override
|
@Override
|
||||||
public void deleteGlTexture() {
|
public void deleteGlTexture() {
|
||||||
super.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 skinUploadExecutor = Executors.newSingleThreadExecutor();
|
||||||
public static final ExecutorService skinDownloadExecutor = Executors.newFixedThreadPool(8);
|
public static final ExecutorService skinDownloadExecutor = Executors.newFixedThreadPool(8);
|
||||||
|
// TODO: This doesn't belong here
|
||||||
public static final CloseableHttpClient httpClient = HttpClients.createSystem();
|
public static final CloseableHttpClient httpClient = HttpClients.createSystem();
|
||||||
|
|
||||||
private static final ResourceLocation LOADING = new ResourceLocation("LOADING");
|
private static final ResourceLocation LOADING = new ResourceLocation("LOADING");
|
||||||
|
@ -254,6 +255,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
this.skinServers.add(skinServer);
|
this.skinServers.add(skinServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Why is this deprecated?
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public SkinServer getGatewayServer() {
|
public SkinServer getGatewayServer() {
|
||||||
return this.skinServers.get(0);
|
return this.skinServers.get(0);
|
||||||
|
|
|
@ -6,9 +6,11 @@ import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public class TextureLoader {
|
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) {
|
public static void loadTexture(ResourceLocation textureLocation, ITextureObject textureObj) {
|
||||||
mc.addScheduledTask((Runnable) () -> mc.getTextureManager().loadTexture(textureLocation, 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.Minecraft;
|
||||||
import net.minecraft.client.resources.DefaultResourcePack;
|
import net.minecraft.client.resources.DefaultResourcePack;
|
||||||
import net.minecraft.launchwrapper.injector.VanillaTweakInjector;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
|
@ -21,7 +20,6 @@ import java.awt.event.ComponentAdapter;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.TooManyListenersException;
|
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.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
@Mixin(ImageBufferDownload.class)
|
@Mixin(ImageBufferDownload.class)
|
||||||
public abstract class MixinImageBufferDownload implements IImageBuffer {
|
public abstract class MixinImageBufferDownload implements IImageBuffer {
|
||||||
|
|
||||||
@Inject(
|
@Inject(method = "parseUserSkin(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;",
|
||||||
method = "parseUserSkin(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;",
|
|
||||||
at = @At("RETURN"),
|
at = @At("RETURN"),
|
||||||
cancellable = true)
|
cancellable = true)
|
||||||
private void update(BufferedImage image, CallbackInfoReturnable<BufferedImage> ci) {
|
private void update(BufferedImage image, CallbackInfoReturnable<BufferedImage> ci) {
|
||||||
// convert skins from mojang server
|
// convert skins from mojang server
|
||||||
BufferedImage image2 = ci.getReturnValue();
|
if (image.getHeight() == 32) {
|
||||||
boolean isLegacy = image.getHeight() == 32;
|
HDSkinManager.INSTANCE.convertSkin(ci.getReturnValue());
|
||||||
if (isLegacy) {
|
|
||||||
Graphics graphics = image2.getGraphics();
|
|
||||||
HDSkinManager.INSTANCE.convertSkin(image2, graphics);
|
|
||||||
graphics.dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,32 +12,27 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Mixin(NetworkPlayerInfo.class)
|
@Mixin(NetworkPlayerInfo.class)
|
||||||
public abstract class MixinPlayerInfo {
|
public abstract class MixinPlayerInfo {
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract GameProfile getGameProfile();
|
public abstract GameProfile getGameProfile();
|
||||||
|
|
||||||
@Inject(
|
@Inject(method = "getLocationSkin",
|
||||||
method = "getLocationSkin",
|
|
||||||
cancellable = true,
|
cancellable = true,
|
||||||
at = @At("RETURN"))
|
at = @At("RETURN"))
|
||||||
private void getLocationSkin(CallbackInfoReturnable<ResourceLocation> ci) {
|
private void getLocationSkin(CallbackInfoReturnable<ResourceLocation> ci) {
|
||||||
getTextureLocation(ci, Type.SKIN);
|
getTextureLocation(ci, Type.SKIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(method = "getLocationCape",
|
||||||
method = "getLocationCape",
|
|
||||||
cancellable = true,
|
cancellable = true,
|
||||||
at = @At("RETURN"))
|
at = @At("RETURN"))
|
||||||
private void getLocationCape(CallbackInfoReturnable<ResourceLocation> ci) {
|
private void getLocationCape(CallbackInfoReturnable<ResourceLocation> ci) {
|
||||||
getTextureLocation(ci, Type.CAPE);
|
getTextureLocation(ci, Type.CAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(method = "getLocationElytra",
|
||||||
method = "getLocationElytra",
|
|
||||||
cancellable = true,
|
cancellable = true,
|
||||||
at = @At("RETURN"))
|
at = @At("RETURN"))
|
||||||
private void getLocationElytra(CallbackInfoReturnable<ResourceLocation> ci) {
|
private void getLocationElytra(CallbackInfoReturnable<ResourceLocation> ci) {
|
||||||
|
@ -45,24 +40,20 @@ public abstract class MixinPlayerInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getTextureLocation(CallbackInfoReturnable<ResourceLocation> ci, Type type) {
|
private void getTextureLocation(CallbackInfoReturnable<ResourceLocation> ci, Type type) {
|
||||||
Optional<ResourceLocation> texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), type, true);
|
HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), type, true).ifPresent(ci::setReturnValue);
|
||||||
texture.ifPresent(ci::setReturnValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(method = "getSkinType",
|
||||||
method = "getSkinType",
|
|
||||||
cancellable = true,
|
cancellable = true,
|
||||||
at = @At("RETURN"))
|
at = @At("RETURN"))
|
||||||
private void getSkinType(CallbackInfoReturnable<String> ci) {
|
private void getSkinType(CallbackInfoReturnable<String> ci) {
|
||||||
MinecraftProfileTexture skin = HDSkinManager.INSTANCE.getProfileData(getGameProfile()).get(Type.SKIN);
|
MinecraftProfileTexture skin = HDSkinManager.INSTANCE.getProfileData(getGameProfile()).get(Type.SKIN);
|
||||||
if (skin != null) {
|
if (skin != null) {
|
||||||
|
HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false).ifPresent(res -> {
|
||||||
String type = skin.getMetadata("model");
|
String type = skin.getMetadata("model");
|
||||||
if (type == null)
|
|
||||||
type = "default";
|
|
||||||
String type1 = type;
|
|
||||||
Optional<ResourceLocation> texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false);
|
|
||||||
|
|
||||||
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.GameProfile;
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.tileentity.TileEntitySkull;
|
import net.minecraft.tileentity.TileEntitySkull;
|
||||||
|
@ -13,27 +14,20 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Mixin(TileEntitySkullRenderer.class)
|
@Mixin(TileEntitySkullRenderer.class)
|
||||||
public abstract class MixinSkullRenderer extends TileEntitySpecialRenderer<TileEntitySkull> {
|
public abstract class MixinSkullRenderer extends TileEntitySpecialRenderer<TileEntitySkull> {
|
||||||
|
|
||||||
@Redirect(
|
@Redirect(method = "renderSkull",
|
||||||
method = "renderSkull",
|
at = @At(value = "INVOKE",
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;bindTexture(Lnet/minecraft/util/ResourceLocation;)V",
|
target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;bindTexture(Lnet/minecraft/util/ResourceLocation;)V",
|
||||||
ordinal = 4))
|
ordinal = 4))
|
||||||
private void onBindTexture(TileEntitySkullRenderer tesr, ResourceLocation rl, float x, float y, float z, EnumFacing facing, float rotation, int meta,
|
private void onBindTexture(TileEntitySkullRenderer tesr, ResourceLocation rl, float x, float y, float z, // ow my back
|
||||||
@Nullable GameProfile profile, int p_180543_8_, float ticks) {
|
EnumFacing facing, float rotation, int meta, @Nullable GameProfile profile, int a, float ticks) {
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
Optional<ResourceLocation> skin = HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true);
|
bindTexture(HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true).orElse(rl));
|
||||||
if (skin.isPresent())
|
} else {
|
||||||
// rebind
|
|
||||||
bindTexture(skin.get());
|
|
||||||
else
|
|
||||||
bindTexture(rl);
|
|
||||||
} else
|
|
||||||
bindTexture(rl);
|
bindTexture(rl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class ImageLoader implements Supplier<ResourceLocation> {
|
||||||
private final ResourceLocation original;
|
private final ResourceLocation original;
|
||||||
|
|
||||||
public ImageLoader(ResourceLocation loc) {
|
public ImageLoader(ResourceLocation loc) {
|
||||||
this.original = loc;
|
original = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,7 +49,6 @@ public class ImageLoader implements Supplier<ResourceLocation> {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static BufferedImage getImage(ResourceLocation res) {
|
private static BufferedImage getImage(ResourceLocation res) {
|
||||||
|
|
||||||
try (InputStream in = mc.getResourceManager().getResource(res).getInputStream()) {
|
try (InputStream in = mc.getResourceManager().getResource(res).getInputStream()) {
|
||||||
return TextureUtil.readBufferedImage(in);
|
return TextureUtil.readBufferedImage(in);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -59,9 +58,9 @@ public class ImageLoader implements Supplier<ResourceLocation> {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private ResourceLocation loadSkin(BufferedImage image) {
|
private ResourceLocation loadSkin(BufferedImage image) {
|
||||||
|
|
||||||
ResourceLocation conv = new ResourceLocation(original.getResourceDomain() + "-converted", original.getResourcePath());
|
ResourceLocation conv = new ResourceLocation(original.getResourceDomain() + "-converted", original.getResourcePath());
|
||||||
boolean success = mc.getTextureManager().loadTexture(conv, new DynamicTextureImage(image));
|
boolean success = mc.getTextureManager().loadTexture(conv, new DynamicTextureImage(image));
|
||||||
|
|
||||||
return success ? conv : null;
|
return success ? conv : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class NetClient {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Fix this
|
||||||
public MoreHttpResponses send() throws IOException {
|
public MoreHttpResponses send() throws IOException {
|
||||||
HttpUriRequest request = rqBuilder.build();
|
HttpUriRequest request = rqBuilder.build();
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class ValhallaSkinServer implements SkinServer {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MinecraftTexturesPayload loadProfileData(GameProfile profile) throws IOException {
|
public MinecraftTexturesPayload loadProfileData(GameProfile profile) throws IOException {
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ public class ValhallaSkinServer implements SkinServer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GameProfile profile = session.getProfile();
|
GameProfile profile = session.getProfile();
|
||||||
String token = session.getToken();
|
|
||||||
AuthHandshake handshake = authHandshake(profile.getName());
|
AuthHandshake handshake = authHandshake(profile.getName());
|
||||||
|
|
||||||
if (handshake.offline) {
|
if (handshake.offline) {
|
||||||
|
@ -146,7 +147,7 @@ public class ValhallaSkinServer implements SkinServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// join the session server
|
// 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);
|
AuthResponse response = authResponse(profile.getName(), handshake.verifyToken);
|
||||||
if (!response.userId.equals(profile.getId())) {
|
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 {
|
private <T> T readJson(MoreHttpResponses resp, Class<T> cl) throws IOException {
|
||||||
String type = resp.getResponse().getEntity().getContentType().getValue();
|
String type = resp.getResponse().getEntity().getContentType().getValue();
|
||||||
|
|
||||||
if (!"application/json".equals(type)) {
|
if (!"application/json".equals(type)) {
|
||||||
throw new IOException("Server returned a non-json response!");
|
throw new IOException("Server returned a non-json response!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resp.ok()) {
|
if (resp.ok()) {
|
||||||
return resp.json(cl);
|
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;
|
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> {
|
public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony<T> {
|
||||||
|
|
||||||
protected RenderPony<T> renderPony = new RenderPony<T>(this);
|
protected RenderPony<T> renderPony = new RenderPony<T>(this);
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class LayerPonyCustomHead<T extends EntityLivingBase> implements LayerRen
|
||||||
}
|
}
|
||||||
|
|
||||||
private ModelWrapper getModel() {
|
private ModelWrapper getModel() {
|
||||||
return ((IRenderPony) renderer).getModelWrapper();
|
return ((IRenderPony<?>) renderer).getModelWrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue