Added 1.10 support

This commit is contained in:
Alexander Xia committed 2016-06-09 01:12:08 +08:00
1 parent 11d7d53684
commit e27c3ecd68
4 files changed
+319

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
@echo off
SET MC_VERSION=1.10
SET CSL_VERSION=13.9
title CustomSkinLoader_%MC_VERSION%-%CSL_VERSION%
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;../lib/jsr305-3.0.1.jar;../%MC_VERSION%.jar *.java
javac -source 1.6 -target 1.6 -d ../bin -cp ;../lib/launchwrapper-1.7.jar;../lib/commons-io-2.4.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
+91
View File
@@ -0,0 +1,91 @@
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.image.ImageObserver;
//ImageBufferDownload implements IImageBuffer
public class boi implements boc {
private int[] a;//imageData
private int b;//imageWidth
private int c;//imageHeight
//BufferedImage parseUserSkin(BufferedImage image)
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);
boolean flag = image.getHeight() == 32 * ratio;
if(flag) {
if(!customskinloader.CustomSkinLoader.config.enableTransparentSkin){
graphics.setColor(new Color(0, 0, 0, 0));
graphics.fillRect(0, 32 * ratio, 64 * ratio, 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, 0, 32 * ratio, 16 * ratio);
if(flag) {
this.a(32 * ratio, 0, 64 * ratio, 32 * ratio);
}
this.b( 0 * ratio, 16 * ratio, 64 * ratio, 32 * ratio);
this.b(16 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);
}
return bufferedimage;
}
}
//skinAvailable
public void a() {
}
//doTransparencyHack(int p_189559_1_, int p_189559_2_, int p_189559_3_, int p_189559_4_)
private void a(int x0, int y0, int x, int y) {
for(int i = x0; i < x; ++i) {
for(int j = y0; j < y; ++j) {
int k = this.a[i + j * this.b];
if((k >> 24 & 255) < 128) {
return;
}
}
}
for(int i = x0; i < x; ++i) {
for(int j = y0; j < y; ++j) {
this.a[i + j * this.b] &= 16777215;
}
}
}
//setAreaOpaque(int x, int y, int width, int height)
private void b(int x0, int y0, int x, int y) {
for(int i = x0; i < x; ++i) {
for(int j = y0; j < y; ++j) {
this.a[i + j * this.b] |= -16777216;
}
}
}
}
+146
View File
@@ -0,0 +1,146 @@
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;
import javax.annotation.Nullable;
//SkinManager
public class bxk {
private static final ExecutorService a = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());//THREAD_POOL
private final bwf b;//textureManager
private final File c;//skinCacheDir
private final MinecraftSessionService d;//sessionService
private final LoadingCache e;//skinCacheLoader
//SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService)
public bxk(bwf 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() {
public Map a(GameProfile p_load_1_) throws Exception {
return bcx.z().X().getTextures(p_load_1_, false);
}
// $FF: synthetic method
public Object load(Object p_load_1_) throws Exception {
return this.a((GameProfile)p_load_1_);
}
});
}
//ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType)
public kn a(MinecraftProfileTexture profileTexture, Type textureType) {
return this.a(profileTexture, textureType, (bxk.a)null);
}
//ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, @Nullable final SkinManager.SkinAvailableCallback skinAvailableCallback)
public kn a(final MinecraftProfileTexture profileTexture, final Type textureType, @Nullable final bxk.a skinAvailableCallback) {
final kn resourcelocation = new kn("skins/" + profileTexture.getHash());
bwg itextureobject = this.b.b(resourcelocation);
if(itextureobject != null) {
if(skinAvailableCallback != null) {
skinAvailableCallback.a(textureType, resourcelocation, 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 boc iimagebuffer = textureType == Type.SKIN?new boi():null;
bvv threaddownloadimagedata = new bvv(file2, profileTexture.getUrl(), bwt.a(), new boc() {
public BufferedImage a(BufferedImage image) {
if(iimagebuffer != null) {
image = iimagebuffer.a(image);
}
return image;
}
public void a() {
if(iimagebuffer != null) {
iimagebuffer.a();
}
if(skinAvailableCallback != null) {
skinAvailableCallback.a(textureType, resourcelocation, profileTexture);
}
}
});
this.b.a((kn)resourcelocation, (bwg)threaddownloadimagedata);
}
return resourcelocation;
}
//loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure)
public void a(final GameProfile profile, final bxk.a skinAvailableCallback, final boolean requireSecure) {
a.submit(new Runnable() {
public void run() {
final Map<Type, MinecraftProfileTexture> map = Maps.newHashMap();
try {
map.putAll(bxk.this.d.getTextures(profile, requireSecure));
} catch (InsecureTextureException var3) {
;
}
/*
if(map.isEmpty() && profile.getId().equals(bcx.z().K().e().getId())) {
profile.getProperties().clear();
profile.getProperties().putAll(bcx.z().L());
map.putAll(bxk.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
bcx.z().a(new Runnable() {
public void run() {
if(map.containsKey(Type.SKIN)) {
bxk.this.a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN, skinAvailableCallback);
}
if(map.containsKey(Type.CAPE)) {
bxk.this.a((MinecraftProfileTexture)map.get(Type.CAPE), Type.CAPE, skinAvailableCallback);
}
}
});
}
});
}
//Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile)
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(),(Map)this.e.getUnchecked(profile)):
(Map)this.e.getUnchecked(profile);
//CustomSkinLoader End
}
//SkinAvailableCallback
public interface a {
//skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture)
void a(Type var1, kn var2, MinecraftProfileTexture var3);
}
}
@@ -0,0 +1,71 @@
package customskinloader.utils;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* MinecraftUtil for non-mcp version.
* It is the only class in package 'customskinloader' which has differences in mcp/non-mcp version.
*
* @author Alexander Xia
* @since 13.6
*
*/
public class MinecraftUtil {
public static File getMinecraftDataDir0(){
return getMinecraftDataDir();
}
public static File minecraftDataFolder=null;
private static final String MINECRAFT_DATA_FOLDER=".minecraft";
public static File getMinecraftDataDir(){
if(minecraftDataFolder!=null)
return minecraftDataFolder;
testProbe();
if(minecraftDataFolder!=null)
return minecraftDataFolder;
File temp=new File("");
if(temp.getAbsolutePath().endsWith(MINECRAFT_DATA_FOLDER))
return temp;
File temp0=new File(MINECRAFT_DATA_FOLDER);
if(temp0.exists())
return temp0;
return temp;
}
private static String minecraftVersion=null;
public static String getMinecraftVersion(){
if(minecraftVersion!=null)
return minecraftVersion;
testProbe();
return minecraftVersion;
}
private final static Pattern MINECRAFT_CORE_FILE_PATTERN = Pattern.compile("^(.*?)/versions/(.*?)/(.*?).jar$");
private static void testProbe(){
URLClassLoader ucl = (URLClassLoader)new MinecraftUtil().getClass().getClassLoader();
URL urls[] = ucl.getURLs();
for(URL url:urls){
Matcher m = null;
try{
m=MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
}catch(Exception e){
e.printStackTrace();
}
if(m==null)
continue;
if(!m.matches())
continue;
if(minecraftDataFolder==null)
minecraftDataFolder=new File(m.group(1));
//System.out.println(url.getPath()+" "+minecraftDataFolder.getAbsolutePath());
if(minecraftVersion==null)
minecraftVersion=m.group(2);
break;
}
}
}