Added 1.10 forge support

This commit is contained in:
Alexander Xia committed 2016-06-24 20:29:55 +08:00
1 parent fccacc6f98
commit ffbe66193d
6 files changed
+285 -319

No files matched your search

@@ -0,0 +1,109 @@
package net.minecraft.client.renderer;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.image.ImageObserver;
public class ImageBufferDownload implements IImageBuffer
{
private int[] imageData;
private int imageWidth;
private int imageHeight;
public BufferedImage parseUserSkin(BufferedImage image)
{
if (image == null)
{
return null;
}
else
{
int ratio = image.getWidth() / 64;
this.imageWidth = 64 * ratio;
this.imageHeight = 64 * ratio;
BufferedImage bufferedimage = new BufferedImage(this.imageWidth, this.imageHeight, 2);
Graphics graphics = bufferedimage.getGraphics();
graphics.drawImage(image, 0, 0, (ImageObserver)null);
boolean flag = image.getHeight() == 32;
if (flag)
{
if(!customskinloader.CustomSkinLoader.config.enableTransparentSkin){
graphics.setColor(new Color(0, 0, 0, 0));
graphics.fillRect(0, 32, 64, 32);
}
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.imageData = ((DataBufferInt)bufferedimage.getRaster().getDataBuffer()).getData();
if(!customskinloader.CustomSkinLoader.config.enableTransparentSkin){
this.setAreaOpaque(0, 0, 32, 16);
if (flag)
{
this.func_189559_a(32, 0, 64, 32);
}
this.setAreaOpaque(0, 16, 64, 32);
this.setAreaOpaque(16, 48, 48, 64);
}
return bufferedimage;
}
}
public void skinAvailable()
{
}
private void func_189559_a(int p_189559_1_, int p_189559_2_, int p_189559_3_, int p_189559_4_)
{
for (int i = p_189559_1_; i < p_189559_3_; ++i)
{
for (int j = p_189559_2_; j < p_189559_4_; ++j)
{
int k = this.imageData[i + j * this.imageWidth];
if ((k >> 24 & 255) < 128)
{
return;
}
}
}
for (int l = p_189559_1_; l < p_189559_3_; ++l)
{
for (int i1 = p_189559_2_; i1 < p_189559_4_; ++i1)
{
this.imageData[l + i1 * this.imageWidth] &= 16777215;
}
}
}
/**
* Makes the given area of the image opaque
*/
private void setAreaOpaque(int x, int y, int width, int height)
{
for (int i = x; i < width; ++i)
{
for (int j = y; j < height; ++j)
{
this.imageData[i + j * this.imageWidth] |= -16777216;
}
}
}
}
@@ -0,0 +1,176 @@
package net.minecraft.client.resources;
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;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IImageBuffer;
import net.minecraft.client.renderer.ImageBufferDownload;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
public class SkinManager
{
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
private final TextureManager textureManager;
private final File skinCacheDir;
private final MinecraftSessionService sessionService;
private final LoadingCache<GameProfile, Map<Type, MinecraftProfileTexture>> skinCacheLoader;
public SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService)
{
this.textureManager = textureManagerInstance;
this.skinCacheDir = skinCacheDirectory;
this.sessionService = sessionService;
this.skinCacheLoader = CacheBuilder.newBuilder().expireAfterAccess(15L, TimeUnit.SECONDS).<GameProfile, Map<Type, MinecraftProfileTexture>>build(new CacheLoader<GameProfile, Map<Type, MinecraftProfileTexture>>()
{
public Map<Type, MinecraftProfileTexture> load(GameProfile p_load_1_) throws Exception
{
return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_, false);
}
});
}
/**
* Used in the Skull renderer to fetch a skin. May download the skin if it's not in the cache
*/
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType)
{
return this.loadSkin(profileTexture, textureType, (SkinManager.SkinAvailableCallback)null);
}
/**
* May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling
*/
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, @Nullable final SkinManager.SkinAvailableCallback skinAvailableCallback)
{
final ResourceLocation resourcelocation = new ResourceLocation("skins/" + profileTexture.getHash());
ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation);
if (itextureobject != null)
{
if (skinAvailableCallback != null)
{
skinAvailableCallback.skinAvailable(textureType, resourcelocation, profileTexture);
}
}
else
{
File file1 = new File(this.skinCacheDir, profileTexture.getHash().length() > 2 ? profileTexture.getHash().substring(0, 2) : "xx");
File file2 = new File(file1, profileTexture.getHash());
final IImageBuffer iimagebuffer = textureType == Type.SKIN ? new ImageBufferDownload() : null;
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, profileTexture.getUrl(), DefaultPlayerSkin.getDefaultSkinLegacy(), new IImageBuffer()
{
public BufferedImage parseUserSkin(BufferedImage image)
{
if (iimagebuffer != null)
{
image = iimagebuffer.parseUserSkin(image);
}
return image;
}
public void skinAvailable()
{
if (iimagebuffer != null)
{
iimagebuffer.skinAvailable();
}
if (skinAvailableCallback != null)
{
skinAvailableCallback.skinAvailable(textureType, resourcelocation, profileTexture);
}
}
});
this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
}
return resourcelocation;
}
public void loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure)
{
THREAD_POOL.submit(new Runnable()
{
public void run()
{
final Map<Type, MinecraftProfileTexture> map = Maps.<Type, MinecraftProfileTexture>newHashMap();
try
{
map.putAll(SkinManager.this.sessionService.getTextures(profile, requireSecure));
}
catch (InsecureTextureException var3)
{
;
}
/*
if (map.isEmpty() && profile.getId().equals(Minecraft.getMinecraft().getSession().getProfile().getId()))
{
profile.getProperties().clear();
profile.getProperties().putAll(Minecraft.getMinecraft().getProfileProperties());
map.putAll(SkinManager.this.sessionService.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
Minecraft.getMinecraft().addScheduledTask(new Runnable()
{
public void run()
{
if (map.containsKey(Type.SKIN))
{
SkinManager.this.loadSkin((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN, skinAvailableCallback);
}
if (map.containsKey(Type.CAPE))
{
SkinManager.this.loadSkin((MinecraftProfileTexture)map.get(Type.CAPE), Type.CAPE, skinAvailableCallback);
}
}
});
}
});
}
public Map<Type, MinecraftProfileTexture> 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)):
this.skinCacheLoader.getUnchecked(profile);
//CustomSkinLoader End
}
public interface SkinAvailableCallback
{
void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture);
}
}
-11
View File
@@ -1,11 +0,0 @@
@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
@@ -1,91 +0,0 @@
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
@@ -1,146 +0,0 @@
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);
}
}
@@ -1,71 +0,0 @@
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;
}
}
}