From 704f3a410231fcf34330cc6bb0cf97dbd757f5b1 Mon Sep 17 00:00:00 2001 From: Alexander Xia Date: Mon, 4 Apr 2016 00:35:12 +0800 Subject: [PATCH] Added 1.9.2 Support --- .../client/renderer/ImageBufferDownload.java | 44 +++--- .../client/resources/SkinManager.java | 24 ++-- 1.9.2/compile.bat | 10 ++ 1.9.2/src/bnm.java | 91 ++++++++++++ 1.9.2/src/bwk.java | 135 ++++++++++++++++++ 5 files changed, 270 insertions(+), 34 deletions(-) create mode 100644 1.9.2/compile.bat create mode 100644 1.9.2/src/bnm.java create mode 100644 1.9.2/src/bwk.java diff --git a/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/renderer/ImageBufferDownload.java b/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/renderer/ImageBufferDownload.java index de2f879..ceb361c 100644 --- a/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/renderer/ImageBufferDownload.java +++ b/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/renderer/ImageBufferDownload.java @@ -19,15 +19,15 @@ public class ImageBufferDownload implements IImageBuffer } else { - int ratio = image.getWidth() / 64; - this.imageWidth = 64 * ratio; + int ratio = image.getWidth() / 64; + this.imageWidth = 64 * ratio; this.imageHeight = 64 * ratio; - BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageHeight, 2); - Graphics var3 = var2.getGraphics(); - var3.drawImage(image, 0, 0, null); - if (image.getHeight() == 32 * ratio) - { - var3.drawImage(var2, 24 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 4 * ratio, 16 * ratio, 8 * ratio, 20 * ratio, (ImageObserver)null); + BufferedImage var2 = new BufferedImage(this.imageWidth, this.imageHeight, 2); + Graphics var3 = var2.getGraphics(); + var3.drawImage(image, 0, 0, null); + if (image.getHeight() == 32 * ratio) + { + var3.drawImage(var2, 24 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 4 * ratio, 16 * ratio, 8 * ratio, 20 * ratio, (ImageObserver)null); var3.drawImage(var2, 28 * ratio, 48 * ratio, 24 * ratio, 52 * ratio, 8 * ratio, 16 * ratio, 12 * ratio, 20 * ratio, (ImageObserver)null); var3.drawImage(var2, 20 * ratio, 52 * ratio, 16 * ratio, 64 * ratio, 8 * ratio, 20 * ratio, 12 * ratio, 32 * ratio, (ImageObserver)null); var3.drawImage(var2, 24 * ratio, 52 * ratio, 20 * ratio, 64 * ratio, 4 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, (ImageObserver)null); @@ -39,21 +39,21 @@ public class ImageBufferDownload implements IImageBuffer var3.drawImage(var2, 40 * ratio, 52 * ratio, 36 * ratio, 64 * ratio, 44 * ratio, 20 * ratio, 48 * ratio, 32 * ratio, (ImageObserver)null); var3.drawImage(var2, 44 * ratio, 52 * ratio, 40 * ratio, 64 * ratio, 40 * ratio, 20 * ratio, 44 * ratio, 32 * ratio, (ImageObserver)null); var3.drawImage(var2, 48 * ratio, 52 * ratio, 44 * ratio, 64 * ratio, 52 * ratio, 20 * ratio, 56 * ratio, 32 * ratio, (ImageObserver)null); - } - var3.dispose(); - this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData(); - if(!customskinloader.CustomSkinLoader.config.enableTransparentSkin){ - this.setAreaOpaque(0, 0, 32 * ratio, 16 * ratio); - this.setAreaTransparent(32 * ratio, 0, 64 * ratio, 32 * ratio); - this.setAreaOpaque(0, 16 * ratio, 64 * ratio, 32 * ratio); - this.setAreaTransparent(0, 32 * ratio, 16 * ratio, 48 * ratio); - this.setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio); - this.setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio); - this.setAreaTransparent(0, 48 * ratio, 16 * ratio, 64 * ratio); - this.setAreaOpaque(16 * ratio, 48 * ratio, 48 * ratio, 64 * ratio); - this.setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio); } - return var2; + var3.dispose(); + this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData(); + if(!customskinloader.CustomSkinLoader.config.enableTransparentSkin){ + this.setAreaOpaque(0, 0, 32 * ratio, 16 * ratio); + this.setAreaTransparent(32 * ratio, 0, 64 * ratio, 32 * ratio); + this.setAreaOpaque(0, 16 * ratio, 64 * ratio, 32 * ratio); + this.setAreaTransparent(0, 32 * ratio, 16 * ratio, 48 * ratio); + this.setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio); + this.setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio); + this.setAreaTransparent(0, 48 * ratio, 16 * ratio, 64 * ratio); + this.setAreaOpaque(16 * ratio, 48 * ratio, 48 * ratio, 64 * ratio); + this.setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio); + } + return var2; } } diff --git a/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/resources/SkinManager.java b/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/resources/SkinManager.java index 0eb62ea..687d8ed 100644 --- a/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/resources/SkinManager.java +++ b/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/resources/SkinManager.java @@ -121,7 +121,7 @@ public class SkinManager ; } - /* + /* if (map.isEmpty() && profile.getId().equals(Minecraft.getMinecraft().getSession().getProfile().getId())) { profile.getProperties().clear(); @@ -131,11 +131,11 @@ public class SkinManager //CustomSkinLoader Begin (User Skin/Cape Part) if(customskinloader.CustomSkinLoader.config.enable){ - Map newMap=customskinloader.CustomSkinLoader.loadProfile(profile.getName(), map); - if(!newMap.isEmpty()){ - map.clear(); - map.putAll(newMap); - } + Map newMap=customskinloader.CustomSkinLoader.loadProfile(profile.getName(), map); + if(!newMap.isEmpty()){ + map.clear(); + map.putAll(newMap); + } } //CustomSkinLoader End Minecraft.getMinecraft().addScheduledTask(new Runnable() @@ -159,12 +159,12 @@ public class SkinManager public Map loadSkinFromCache(GameProfile profile) { - //CustomSkinLoader Begin (Skull Part) - //return (Map)this.skinCacheLoader.getUnchecked(profile); - return (customskinloader.CustomSkinLoader.config.enable && customskinloader.CustomSkinLoader.config.enableSkull)? - customskinloader.CustomSkinLoader.loadProfileFromCache(profile.getName()): - this.skinCacheLoader.getUnchecked(profile); - //CustomSkinLoader End + //CustomSkinLoader Begin (Skull Part) + //return (Map)this.skinCacheLoader.getUnchecked(profile); + return (customskinloader.CustomSkinLoader.config.enable && customskinloader.CustomSkinLoader.config.enableSkull)? + customskinloader.CustomSkinLoader.loadProfileFromCache(profile.getName()): + this.skinCacheLoader.getUnchecked(profile); + //CustomSkinLoader End } public interface SkinAvailableCallback diff --git a/1.9.2/compile.bat b/1.9.2/compile.bat new file mode 100644 index 0000000..dc259f2 --- /dev/null +++ b/1.9.2/compile.bat @@ -0,0 +1,10 @@ +@echo off +SET MC_VERSION=1.9.2 +SET CSL_VERSION=13.5 +cd src +javac -source 1.6 -target 1.6 -d ../bin -cp ;../lib/commons-codec-1.9.jar;../lib/commons-io-2.4.jar;../lib/gson-2.2.4.jar;../lib/guava-17.0.jar;../lib/authlib-1.5.22.jar;../%MC_VERSION%.jar *.java +javac -source 1.6 -target 1.6 -d ../bin -cp ;../lib/launchwrapper-1.7.jar customskinloader/tweaker/*.java +cd ../bin +del ../out/CustomSkinLoader_%MC_VERSION%-%CSL_VERSION%.jar +jar cfm ../out/CustomSkinLoader_%MC_VERSION%-%CSL_VERSION%.jar META-INF/MANIFEST.MF . +pause \ No newline at end of file diff --git a/1.9.2/src/bnm.java b/1.9.2/src/bnm.java new file mode 100644 index 0000000..8017186 --- /dev/null +++ b/1.9.2/src/bnm.java @@ -0,0 +1,91 @@ +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.awt.image.ImageObserver; + +public class bnm implements bng { + private int[] a;//imageData + private int b;//imageWidth + private int c;//imageHeight + + public BufferedImage a(BufferedImage image) { + if(image == null) { + return null; + } else { + int ratio = image.getWidth() / 64; + this.b = 64 * ratio; + this.c = 64 * ratio; + BufferedImage bufferedimage = new BufferedImage(this.b, this.c, 2); + Graphics graphics = bufferedimage.getGraphics(); + graphics.drawImage(image, 0, 0, (ImageObserver)null); + if(image.getHeight() == 32 * ratio) { + graphics.drawImage(bufferedimage, 24 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 4 * ratio, 16 * ratio, 8 * ratio, 20 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 28 * ratio, 48 * ratio, 24 * ratio, 52 * ratio, 8 * ratio, 16 * ratio, 12 * ratio, 20 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 20 * ratio, 52 * ratio, 16 * ratio, 64 * ratio, 8 * ratio, 20 * ratio, 12 * ratio, 32 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 24 * ratio, 52 * ratio, 20 * ratio, 64 * ratio, 4 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 28 * ratio, 52 * ratio, 24 * ratio, 64 * ratio, 0 * ratio, 20 * ratio, 4 * ratio, 32 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 32 * ratio, 52 * ratio, 28 * ratio, 64 * ratio, 12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 40 * ratio, 48 * ratio, 36 * ratio, 52 * ratio, 44 * ratio, 16 * ratio, 48 * ratio, 20 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 44 * ratio, 48 * ratio, 40 * ratio, 52 * ratio, 48 * ratio, 16 * ratio, 52 * ratio, 20 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 36 * ratio, 52 * ratio, 32 * ratio, 64 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 32 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 40 * ratio, 52 * ratio, 36 * ratio, 64 * ratio, 44 * ratio, 20 * ratio, 48 * ratio, 32 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 44 * ratio, 52 * ratio, 40 * ratio, 64 * ratio, 40 * ratio, 20 * ratio, 44 * ratio, 32 * ratio, (ImageObserver)null); + graphics.drawImage(bufferedimage, 48 * ratio, 52 * ratio, 44 * ratio, 64 * ratio, 52 * ratio, 20 * ratio, 56 * ratio, 32 * ratio, (ImageObserver)null); + } + + graphics.dispose(); + this.a = ((DataBufferInt)bufferedimage.getRaster().getDataBuffer()).getData(); + if(!customskinloader.CustomSkinLoader.config.enableTransparentSkin){ + this.b( 0 * ratio, 0 * ratio, 32 * ratio, 16 * ratio); + this.a(32 * ratio, 0 * ratio, 64 * ratio, 32 * ratio); + this.b( 0 * ratio, 16 * ratio, 64 * ratio, 32 * ratio); + this.a( 0 * ratio, 32 * ratio, 16 * ratio, 48 * ratio); + this.a(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio); + this.a(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio); + this.a( 0 * ratio, 48 * ratio, 16 * ratio, 64 * ratio); + this.b(16 * ratio, 48 * ratio, 48 * ratio, 64 * ratio); + this.a(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio); + } + return bufferedimage; + } + } + + public void a() { + } + + //setAreaTransparent + private void a(int p1, int p2, int p3, int p4) { + if(!this.c(p1, p2, p3, p4)) { + for(int i = p1; i < p3; ++i) { + for(int j = p2; j < p4; ++j) { + this.a[i + j * this.b] &= 16777215; + } + } + + } + } + + //setAreaOpaque + private void b(int p1, int p2, int p3, int p4) { + for(int i = p1; i < p3; ++i) { + for(int j = p2; j < p4; ++j) { + this.a[i + j * this.b] |= -16777216; + } + } + + } + + //hasTransparency + private boolean c(int p1, int p2, int p3, int p4) { + for(int i = p1; i < p3; ++i) { + for(int j = p2; j < p4; ++j) { + int k = this.a[i + j * this.b]; + if((k >> 24 & 255) < 128) { + return true; + } + } + } + + return false; + } +} diff --git a/1.9.2/src/bwk.java b/1.9.2/src/bwk.java new file mode 100644 index 0000000..efcbc90 --- /dev/null +++ b/1.9.2/src/bwk.java @@ -0,0 +1,135 @@ +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.Maps; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.InsecureTextureException; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import com.mojang.authlib.minecraft.MinecraftSessionService; +import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +public class bwk { + private static final ExecutorService a = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());//THREAD_POOL + private final bvf b;//textureManager + private final File c;//skinCacheDir + private final MinecraftSessionService d;//sessionServive + private final LoadingCache> e;//skinCacheLoader + + public bwk(bvf textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) { + this.b = textureManagerInstance; + this.c = skinCacheDirectory; + this.d = sessionService; + this.e = CacheBuilder.newBuilder().expireAfterAccess(15L, TimeUnit.SECONDS).build(new CacheLoader>() { + //roolback + public Map a(GameProfile p_load_1_) throws Exception { + return bcc.z().X().getTextures(p_load_1_, false); + } + public Map load(GameProfile p_load_1_) throws Exception { + return bcc.z().X().getTextures(p_load_1_, false); + } + }); + } + + public kk a(MinecraftProfileTexture profileTexture, Type textureType) { + return this.a(profileTexture, textureType, (bwk.a)null); + } + + public kk a(final MinecraftProfileTexture profileTexture, final Type textureType, final bwk.a skinAvailableCallback) { + final kk kk = new kk("skins/" + profileTexture.getHash()); + bvg bvg = this.b.b(kk); + if(bvg != null) { + if(skinAvailableCallback != null) { + skinAvailableCallback.a(textureType, kk, profileTexture); + } + } else { + File file1 = new File(this.c, profileTexture.getHash().length() > 2?profileTexture.getHash().substring(0, 2):"xx"); + File file2 = new File(file1, profileTexture.getHash()); + final bng bng = textureType == Type.SKIN?new bnm():null; + buv buv = new buv(file2, profileTexture.getUrl(), bvt.a(), new bng() { + public BufferedImage a(BufferedImage image) { + if(bng != null) { + image = bng.a(image); + } + + return image; + } + + public void a() { + if(bng != null) { + bng.a(); + } + + if(skinAvailableCallback != null) { + skinAvailableCallback.a(textureType, kk, profileTexture); + } + + } + }); + this.b.a((kk)kk, (bvg)buv); + } + + return kk; + } + + public void a(final GameProfile profile, final bwk.a skinAvailableCallback, final boolean requireSecure) { + a.submit(new Runnable() { + public void run() { + final Map map = Maps.newHashMap(); + + try { + map.putAll(bwk.this.d.getTextures(profile, requireSecure)); + } catch (InsecureTextureException var3) { + ; + } + /* + if(map.isEmpty() && profile.getId().equals(bcc.z().K().e().getId())) { + profile.getProperties().clear(); + profile.getProperties().putAll(bcc.z().L()); + map.putAll(bwk.this.d.getTextures(profile, false)); + }*/ + //CustomSkinLoader Begin (User Skin/Cape Part) + if(customskinloader.CustomSkinLoader.config.enable){ + Map newMap=customskinloader.CustomSkinLoader.loadProfile(profile.getName(), map); + if(!newMap.isEmpty()){ + map.clear(); + map.putAll(newMap); + } + } + //CustomSkinLoader End + + bcc.z().a(new Runnable() { + public void run() { + if(map.containsKey(Type.SKIN)) { + bwk.this.a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN, skinAvailableCallback); + } + + if(map.containsKey(Type.CAPE)) { + bwk.this.a((MinecraftProfileTexture)map.get(Type.CAPE), Type.CAPE, skinAvailableCallback); + } + + } + }); + } + }); + } + + public Map a(GameProfile profile) { + //CustomSkinLoader Begin (Skull Part) + //return (Map)this.e.getUnchecked(profile); + return (customskinloader.CustomSkinLoader.config.enable && customskinloader.CustomSkinLoader.config.enableSkull)? + customskinloader.CustomSkinLoader.loadProfileFromCache(profile.getName()): + this.e.getUnchecked(profile); + //CustomSkinLoader End + } + + public interface a { + void a(Type var1, kk var2, MinecraftProfileTexture var3); + } +}