mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-12 08:17:42 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
b45ef7230d
commit
955a875d42
59 files changed
+561
-438
No files matched your search
@@ -1,10 +1,5 @@
|
||||
package codechicken.core;
|
||||
|
||||
import codechicken.core.launch.CodeChickenCorePlugin;
|
||||
import com.google.common.base.Function;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.versioning.ComparableVersion;
|
||||
import cpw.mods.fml.relauncher.FMLInjectionData;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -14,14 +9,25 @@ import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import codechicken.core.launch.CodeChickenCorePlugin;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.versioning.ComparableVersion;
|
||||
import cpw.mods.fml.relauncher.FMLInjectionData;
|
||||
|
||||
public class CCUpdateChecker {
|
||||
|
||||
private static final ArrayList<String> updates = new ArrayList<String>();
|
||||
|
||||
private static class ThreadUpdateCheck extends Thread {
|
||||
|
||||
private final URL url;
|
||||
private final Function<String, Void> handler;
|
||||
|
||||
@@ -44,9 +50,7 @@ public class CCUpdateChecker {
|
||||
read.close();
|
||||
if (ret == null) ret = "";
|
||||
handler.apply(ret);
|
||||
} catch (SocketTimeoutException ignored) {
|
||||
} catch (UnknownHostException ignored) {
|
||||
} catch (IOException iox) {
|
||||
} catch (SocketTimeoutException ignored) {} catch (UnknownHostException ignored) {} catch (IOException iox) {
|
||||
iox.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -75,20 +79,22 @@ public class CCUpdateChecker {
|
||||
public static void updateCheck(final String mod, final String version) {
|
||||
updateCheck(
|
||||
"http://www.chickenbones.net/Files/notification/version.php?" + "version="
|
||||
+ mcVersion() + "&" + "file="
|
||||
+ mcVersion()
|
||||
+ "&"
|
||||
+ "file="
|
||||
+ mod,
|
||||
new Function<String, Void>() {
|
||||
|
||||
@Override
|
||||
public Void apply(String ret) {
|
||||
if (!ret.startsWith("Ret: ")) {
|
||||
CodeChickenCorePlugin.logger.error(
|
||||
"Failed to check update for " + mod + " returned: " + ret);
|
||||
CodeChickenCorePlugin.logger
|
||||
.error("Failed to check update for " + mod + " returned: " + ret);
|
||||
return null;
|
||||
}
|
||||
ComparableVersion newversion = new ComparableVersion(ret.substring(5));
|
||||
if (newversion.compareTo(new ComparableVersion(version)) > 0)
|
||||
addUpdateMessage(
|
||||
StatCollector.translateToLocalFormatted("codechickencore.update", newversion, mod));
|
||||
if (newversion.compareTo(new ComparableVersion(version)) > 0) addUpdateMessage(
|
||||
StatCollector.translateToLocalFormatted("codechickencore.update", newversion, mod));
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
package codechicken.core;
|
||||
|
||||
import codechicken.core.launch.CodeChickenCorePlugin;
|
||||
import codechicken.lib.asm.ASMHelper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModClassLoader;
|
||||
import cpw.mods.fml.relauncher.CoreModManager;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -15,10 +8,23 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import codechicken.core.launch.CodeChickenCorePlugin;
|
||||
import codechicken.lib.asm.ASMHelper;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModClassLoader;
|
||||
import cpw.mods.fml.relauncher.CoreModManager;
|
||||
|
||||
public class ClassDiscoverer {
|
||||
|
||||
public IStringMatcher matcher;
|
||||
public String[] superclasses;
|
||||
public ArrayList<Class<?>> classes;
|
||||
@@ -35,13 +41,12 @@ public class ClassDiscoverer {
|
||||
}
|
||||
|
||||
public ClassDiscoverer(Class<?>... superclasses) {
|
||||
this(
|
||||
new IStringMatcher() {
|
||||
public boolean matches(String test) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
superclasses);
|
||||
this(new IStringMatcher() {
|
||||
|
||||
public boolean matches(String test) {
|
||||
return true;
|
||||
}
|
||||
}, superclasses);
|
||||
}
|
||||
|
||||
public ArrayList<Class<?>> findClasses() {
|
||||
@@ -79,10 +84,8 @@ public class ClassDiscoverer {
|
||||
}
|
||||
|
||||
private void findClasspathMods() {
|
||||
List<String> knownLibraries = ImmutableList.<String>builder()
|
||||
.addAll(modClassLoader.getDefaultLibraries())
|
||||
.addAll(CoreModManager.getLoadedCoremods())
|
||||
.build();
|
||||
List<String> knownLibraries = ImmutableList.<String>builder().addAll(modClassLoader.getDefaultLibraries())
|
||||
.addAll(CoreModManager.getLoadedCoremods()).build();
|
||||
File[] minecraftSources = modClassLoader.getParentSources();
|
||||
HashSet<String> searchedSources = new HashSet<String>();
|
||||
for (File minecraftSource : minecraftSources) {
|
||||
@@ -98,7 +101,8 @@ public class ClassDiscoverer {
|
||||
readFromZipFile(minecraftSource);
|
||||
} catch (Exception e) {
|
||||
CodeChickenCorePlugin.logger.error(
|
||||
"Failed to scan " + minecraftSource.getAbsolutePath() + ", the zip file is invalid", e);
|
||||
"Failed to scan " + minecraftSource.getAbsolutePath() + ", the zip file is invalid",
|
||||
e);
|
||||
}
|
||||
}
|
||||
} else if (minecraftSource.isDirectory()) {
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package codechicken.core;
|
||||
|
||||
import codechicken.core.internal.CCCEventHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
@@ -12,7 +7,14 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import codechicken.core.internal.CCCEventHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ClientUtils extends CommonUtils {
|
||||
|
||||
private static Minecraft mc() {
|
||||
return Minecraft.getMinecraft();
|
||||
}
|
||||
@@ -22,7 +24,7 @@ public class ClientUtils extends CommonUtils {
|
||||
}
|
||||
|
||||
public static boolean inWorld() // TODO unused
|
||||
{
|
||||
{
|
||||
return mc().getNetHandler() != null;
|
||||
}
|
||||
|
||||
@@ -59,8 +61,8 @@ public class ClientUtils extends CommonUtils {
|
||||
|
||||
public static void enhanceSupportersList(Object mod) {
|
||||
ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
|
||||
mc.getMetadata().description =
|
||||
mc.getMetadata().description.replace("Supporters:", EnumChatFormatting.AQUA + "Supporters:");
|
||||
mc.getMetadata().description = mc.getMetadata().description
|
||||
.replace("Supporters:", EnumChatFormatting.AQUA + "Supporters:");
|
||||
GuiModListScroll.register(mod);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
package codechicken.core;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.FMLInjectionData;
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.FMLInjectionData;
|
||||
|
||||
public class CommonUtils {
|
||||
|
||||
public static boolean isClient() {
|
||||
return FMLCommonHandler.instance().getSide().isClient();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,23 @@ package codechicken.core;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL11.glReadPixels;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.core.launch.CodeChickenCorePlugin;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
@@ -10,21 +27,9 @@ import cpw.mods.fml.client.GuiModList;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiModListScroll {
|
||||
|
||||
private static List<ModContainer> scrollMods = new LinkedList<ModContainer>();
|
||||
|
||||
public static void register(Object mod) {
|
||||
@@ -45,9 +50,8 @@ public class GuiModListScroll {
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glReadPixels(0, 0, d.width, d.height, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf);
|
||||
for (int i = 0; i < d.width; i++)
|
||||
for (int j = 0; j < d.height; j++)
|
||||
img.setRGB(i, d.height - j - 1, buf.get(j * d.width + i) == 0 ? 0 : 0xFFFFFF);
|
||||
for (int i = 0; i < d.width; i++) for (int j = 0; j < d.height; j++)
|
||||
img.setRGB(i, d.height - j - 1, buf.get(j * d.width + i) == 0 ? 0 : 0xFFFFFF);
|
||||
try {
|
||||
ImageIO.write(img, "png", new File("stencil" + x + ".png"));
|
||||
} catch (IOException e) {
|
||||
@@ -109,9 +113,7 @@ public class GuiModListScroll {
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
|
||||
String description = selectedMod.getMetadata().description;
|
||||
int height = GuiDraw.fontRenderer
|
||||
.listFormattedStringToWidth(description, x2 - x1)
|
||||
.size()
|
||||
int height = GuiDraw.fontRenderer.listFormattedStringToWidth(description, x2 - x1).size()
|
||||
* GuiDraw.fontRenderer.FONT_HEIGHT;
|
||||
|
||||
boolean needsScroll = height > y2 - y1draw;
|
||||
@@ -142,8 +144,8 @@ public class GuiModListScroll {
|
||||
}
|
||||
|
||||
/**
|
||||
* Does not add the last 10 px space before the description normally starts
|
||||
* Ignores empty child mods expecting a background draw overwrite
|
||||
* Does not add the last 10 px space before the description normally starts Ignores empty child mods expecting a
|
||||
* background draw overwrite
|
||||
*/
|
||||
private static int calcDescY(GuiModList gui, ModContainer mod) {
|
||||
ModMetadata meta = mod.getMetadata();
|
||||
|
||||
@@ -3,5 +3,6 @@ package codechicken.core;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
public interface IGuiPacketSender {
|
||||
|
||||
void sendPacket(EntityPlayerMP player, int windowId);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package codechicken.core;
|
||||
|
||||
public interface IStringMatcher {
|
||||
|
||||
public boolean matches(String test);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package codechicken.core;
|
||||
import codechicken.core.launch.CodeChickenCorePlugin;
|
||||
|
||||
public class ProfileTimer {
|
||||
|
||||
public double decay;
|
||||
public long startTime;
|
||||
public long nanoTime;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package codechicken.core;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
|
||||
public class ReflectionManager {
|
||||
|
||||
public static HashMap<Class<?>, Class<?>> primitiveWrappers = new HashMap<Class<?>, Class<?>>();
|
||||
|
||||
static {
|
||||
@@ -27,12 +29,12 @@ public class ReflectionManager {
|
||||
if (primitive == Long.class && Long.class.isInstance(obj)) return true;
|
||||
if ((primitive == Long.class || primitive == Integer.class) && Integer.class.isInstance(obj)) return true;
|
||||
if ((primitive == Long.class || primitive == Integer.class || primitive == Short.class)
|
||||
&& Short.class.isInstance(obj)) return true;
|
||||
if ((primitive == Long.class
|
||||
|| primitive == Integer.class
|
||||
|| primitive == Short.class
|
||||
|| primitive == Byte.class)
|
||||
&& Integer.class.isInstance(obj)) return true;
|
||||
&& Short.class.isInstance(obj))
|
||||
return true;
|
||||
if ((primitive == Long.class || primitive == Integer.class
|
||||
|| primitive == Short.class
|
||||
|| primitive == Byte.class) && Integer.class.isInstance(obj))
|
||||
return true;
|
||||
|
||||
if (primitive == Double.class && Double.class.isInstance(obj)) return true;
|
||||
if ((primitive == Double.class || primitive == Float.class) && Float.class.isInstance(obj)) return true;
|
||||
@@ -64,7 +66,7 @@ public class ReflectionManager {
|
||||
|
||||
public static void setField(Class<?> class1, Object instance, String name, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException {
|
||||
setField(class1, instance, new String[] {name}, value);
|
||||
setField(class1, instance, new String[] { name }, value);
|
||||
}
|
||||
|
||||
public static void setField(Class<?> class1, Object instance, String[] names, Object value)
|
||||
@@ -95,19 +97,15 @@ public class ReflectionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Static function
|
||||
* void return type
|
||||
* single name
|
||||
* Static function void return type single name
|
||||
*/
|
||||
public static void callMethod(Class<?> class1, String name, Object... params)
|
||||
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||
callMethod(class1, null, new String[] {name}, params);
|
||||
callMethod(class1, null, new String[] { name }, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static function
|
||||
* void return type
|
||||
* single name
|
||||
* Static function void return type single name
|
||||
*/
|
||||
public static void callMethod(Class<?> class1, String[] names, Object... params)
|
||||
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||
@@ -115,12 +113,11 @@ public class ReflectionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* void return type
|
||||
* single name
|
||||
* void return type single name
|
||||
*/
|
||||
public static void callMethod(Class<?> class1, Object instance, String name, Object... params)
|
||||
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||
callMethod(class1, null, instance, new String[] {name}, params);
|
||||
callMethod(class1, null, instance, new String[] { name }, params);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,12 +129,11 @@ public class ReflectionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Static method
|
||||
* single name
|
||||
* Static method single name
|
||||
*/
|
||||
public static <R> R callMethod(Class<?> class1, Class<R> returntype, String name, Object... params)
|
||||
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||
return callMethod(class1, returntype, null, new String[] {name}, params);
|
||||
return callMethod(class1, returntype, null, new String[] { name }, params);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,14 +149,12 @@ public class ReflectionManager {
|
||||
*/
|
||||
public static <R> R callMethod(Class<?> class1, Class<R> returntype, Object instance, String name, Object... params)
|
||||
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||
return callMethod(class1, returntype, instance, new String[] {name}, params);
|
||||
return callMethod(class1, returntype, instance, new String[] { name }, params);
|
||||
}
|
||||
|
||||
public static <R> R callMethod(
|
||||
Class<?> class1, Class<R> returntype, Object instance, String[] names, Object... params)
|
||||
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||
nextMethod:
|
||||
for (Method method : class1.getDeclaredMethods()) {
|
||||
public static <R> R callMethod(Class<?> class1, Class<R> returntype, Object instance, String[] names,
|
||||
Object... params) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||
nextMethod: for (Method method : class1.getDeclaredMethods()) {
|
||||
boolean match = false;
|
||||
for (String name : names) {
|
||||
if (method.getName().equals(name)) {
|
||||
@@ -204,8 +198,7 @@ public class ReflectionManager {
|
||||
|
||||
public static <T> T newInstance(Class<T> class1, Object... params)
|
||||
throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
|
||||
nextMethod:
|
||||
for (Constructor<?> constructor : class1.getDeclaredConstructors()) {
|
||||
nextMethod: for (Constructor<?> constructor : class1.getDeclaredConstructors()) {
|
||||
Class<?>[] paramtypes = constructor.getParameterTypes();
|
||||
if (paramtypes.length != params.length) continue;
|
||||
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
package codechicken.core;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public class ServerUtils extends CommonUtils {
|
||||
|
||||
public static MinecraftServer mc() {
|
||||
return MinecraftServer.getServer();
|
||||
}
|
||||
@@ -49,17 +53,18 @@ public class ServerUtils extends CommonUtils {
|
||||
|
||||
static {
|
||||
try {
|
||||
field_152661_c = ReflectionManager.getField(new ObfMapping(
|
||||
"net/minecraft/server/management/PlayerProfileCache", "field_152661_c", "[Ljava/util/Map;"));
|
||||
c_ProfileEntry = ServerUtils.class
|
||||
.getClassLoader()
|
||||
field_152661_c = ReflectionManager.getField(
|
||||
new ObfMapping(
|
||||
"net/minecraft/server/management/PlayerProfileCache",
|
||||
"field_152661_c",
|
||||
"[Ljava/util/Map;"));
|
||||
c_ProfileEntry = ServerUtils.class.getClassLoader()
|
||||
.loadClass("net.minecraft.server.management.PlayerProfileCache$ProfileEntry");
|
||||
func_152668_a = c_ProfileEntry.getDeclaredMethod(new ObfMapping(
|
||||
func_152668_a = c_ProfileEntry.getDeclaredMethod(
|
||||
new ObfMapping(
|
||||
"net/minecraft/server/management/PlayerProfileCache$ProfileEntry",
|
||||
"func_152668_a",
|
||||
"()Lcom/mojang/authlib/GameProfile;")
|
||||
.toRuntime()
|
||||
.s_name);
|
||||
"()Lcom/mojang/authlib/GameProfile;").toRuntime().s_name);
|
||||
func_152668_a.setAccessible(true);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -6,7 +6,9 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class TaskProfiler {
|
||||
|
||||
public static class ProfilerResult {
|
||||
|
||||
public final String name;
|
||||
public final long time;
|
||||
public final double fraction;
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package codechicken.core.asm;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
|
||||
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
|
||||
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
|
||||
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
|
||||
public class CodeChickenAccessTransformer extends AccessTransformer {
|
||||
|
||||
private static boolean makeAllPublic;
|
||||
private static Field f_classNameBiMap;
|
||||
private static Object emptyMap = ImmutableBiMap.of();
|
||||
@@ -20,12 +24,10 @@ public class CodeChickenAccessTransformer extends AccessTransformer {
|
||||
private void loadPublicConfig() {
|
||||
if (ObfMapping.obfuscated) return;
|
||||
|
||||
makeAllPublic = CodeChickenCoreModContainer.config
|
||||
.getTag("dev.runtimePublic")
|
||||
.setComment(
|
||||
"Enabling this setting will make all minecraft classes public at runtime in MCP just as they are in modloader."
|
||||
+ "\nYou should ONLY use this when you are testing with a mod that relies on runtime publicity and doesn't include access transformers."
|
||||
+ "\nSuch mods are doing the wrong thing and should be fixed.")
|
||||
makeAllPublic = CodeChickenCoreModContainer.config.getTag("dev.runtimePublic").setComment(
|
||||
"Enabling this setting will make all minecraft classes public at runtime in MCP just as they are in modloader."
|
||||
+ "\nYou should ONLY use this when you are testing with a mod that relies on runtime publicity and doesn't include access transformers."
|
||||
+ "\nSuch mods are doing the wrong thing and should be fixed.")
|
||||
.getBooleanValue(false);
|
||||
|
||||
if (!makeAllPublic) return;
|
||||
|
||||
@@ -1,25 +1,30 @@
|
||||
package codechicken.core.asm;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import codechicken.core.CCUpdateChecker;
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.core.featurehack.LiquidTextures;
|
||||
import codechicken.core.internal.CCCEventHandler;
|
||||
import codechicken.core.launch.CodeChickenCorePlugin;
|
||||
import codechicken.lib.config.ConfigFile;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import cpw.mods.fml.common.*;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.VersionParser;
|
||||
import cpw.mods.fml.common.versioning.VersionRange;
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class CodeChickenCoreModContainer extends DummyModContainer {
|
||||
|
||||
public static ConfigFile config;
|
||||
|
||||
public static void loadConfig() {
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
package codechicken.core.asm;
|
||||
|
||||
import codechicken.lib.asm.ASMHelper;
|
||||
import codechicken.lib.asm.ClassHeirachyManager;
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import codechicken.lib.asm.ASMHelper;
|
||||
import codechicken.lib.asm.ClassHeirachyManager;
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
|
||||
public class DefaultImplementationTransformer implements IClassTransformer {
|
||||
|
||||
private static LaunchClassLoader cl = (LaunchClassLoader) ClassHeirachyManager.class.getClassLoader();
|
||||
|
||||
private static ClassNode getClassNode(String name) {
|
||||
@@ -25,6 +29,7 @@ public class DefaultImplementationTransformer implements IClassTransformer {
|
||||
}
|
||||
|
||||
static class InterfaceImpl {
|
||||
|
||||
public final String iname;
|
||||
public ArrayList<MethodNode> impls = new ArrayList<MethodNode>();
|
||||
|
||||
@@ -35,11 +40,10 @@ public class DefaultImplementationTransformer implements IClassTransformer {
|
||||
for (MethodNode method : inode.methods) names.add(method.name + method.desc);
|
||||
|
||||
ClassNode cnode = getClassNode(cname);
|
||||
for (MethodNode method : cnode.methods)
|
||||
if (names.contains(method.name + method.desc)) {
|
||||
impls.add(method);
|
||||
method.desc = new ObfMapping(cnode.name, method.name, method.desc).toRuntime().s_desc;
|
||||
}
|
||||
for (MethodNode method : cnode.methods) if (names.contains(method.name + method.desc)) {
|
||||
impls.add(method);
|
||||
method.desc = new ObfMapping(cnode.name, method.name, method.desc).toRuntime().s_desc;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean patch(ClassNode cnode) {
|
||||
|
||||
@@ -13,13 +13,16 @@ import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
public class DelegatedTransformer implements IClassTransformer {
|
||||
|
||||
private static ArrayList<IClassTransformer> delegatedTransformers;
|
||||
private static Method m_defineClass;
|
||||
private static Field f_cachedClasses;
|
||||
@@ -27,8 +30,8 @@ public class DelegatedTransformer implements IClassTransformer {
|
||||
public DelegatedTransformer() {
|
||||
delegatedTransformers = new ArrayList<IClassTransformer>();
|
||||
try {
|
||||
m_defineClass = ClassLoader.class.getDeclaredMethod(
|
||||
"defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE);
|
||||
m_defineClass = ClassLoader.class
|
||||
.getDeclaredMethod("defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE);
|
||||
m_defineClass.setAccessible(true);
|
||||
f_cachedClasses = LaunchClassLoader.class.getDeclaredField("cachedClasses");
|
||||
f_cachedClasses.setAccessible(true);
|
||||
@@ -53,9 +56,10 @@ public class DelegatedTransformer implements IClassTransformer {
|
||||
if (bytes == null) {
|
||||
String resourceName = transformer.replace('.', '/') + ".class";
|
||||
ZipEntry entry = jar.getEntry(resourceName);
|
||||
if (entry == null)
|
||||
throw new Exception("Failed to add transformer: " + transformer + ". Entry not found in jar file "
|
||||
+ jarFile.getName());
|
||||
if (entry == null) throw new Exception(
|
||||
"Failed to add transformer: " + transformer
|
||||
+ ". Entry not found in jar file "
|
||||
+ jarFile.getName());
|
||||
|
||||
bytes = readFully(jar.getInputStream(entry));
|
||||
}
|
||||
@@ -63,14 +67,12 @@ public class DelegatedTransformer implements IClassTransformer {
|
||||
defineDependancies(bytes, jar, jarFile);
|
||||
Class<?> clazz = defineClass(transformer, bytes);
|
||||
|
||||
if (!IClassTransformer.class.isAssignableFrom(clazz))
|
||||
throw new Exception(
|
||||
"Failed to add transformer: " + transformer + " is not an instance of IClassTransformer");
|
||||
if (!IClassTransformer.class.isAssignableFrom(clazz)) throw new Exception(
|
||||
"Failed to add transformer: " + transformer + " is not an instance of IClassTransformer");
|
||||
|
||||
IClassTransformer classTransformer;
|
||||
try {
|
||||
classTransformer = (IClassTransformer)
|
||||
clazz.getDeclaredConstructor(File.class).newInstance(jarFile);
|
||||
classTransformer = (IClassTransformer) clazz.getDeclaredConstructor(File.class).newInstance(jarFile);
|
||||
} catch (NoSuchMethodException nsme) {
|
||||
classTransformer = (IClassTransformer) clazz.newInstance();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
import org.objectweb.asm.Label;
|
||||
@@ -12,9 +13,11 @@ import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
public class DependancyLister extends ClassVisitor {
|
||||
|
||||
private static Pattern classdesc = Pattern.compile("L(.+?);");
|
||||
|
||||
private class DependancyMethodLister extends MethodVisitor {
|
||||
|
||||
public DependancyMethodLister(int api) {
|
||||
super(api);
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
@Target({ ElementType.TYPE })
|
||||
public @interface InterfaceDependancies {}
|
||||
@@ -1,5 +1,21 @@
|
||||
package codechicken.core.asm;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import codechicken.lib.asm.ASMHelper;
|
||||
import codechicken.lib.asm.ASMInit;
|
||||
import codechicken.lib.asm.CC_ClassWriter;
|
||||
@@ -7,30 +23,21 @@ import codechicken.lib.asm.ObfMapping;
|
||||
import codechicken.obfuscator.IHeirachyEvaluator;
|
||||
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
|
||||
import codechicken.obfuscator.ObfuscationRun;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes, IHeirachyEvaluator {
|
||||
|
||||
static {
|
||||
ASMInit.init();
|
||||
}
|
||||
|
||||
public static class LoadPlugin implements IFMLLoadingPlugin {
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return new String[0];
|
||||
@@ -72,8 +79,8 @@ public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes,
|
||||
try {
|
||||
f_transformers = LaunchClassLoader.class.getDeclaredField("transformers");
|
||||
f_modifiers = AccessTransformer.class.getDeclaredField("modifiers");
|
||||
Class<?> c_Modifier =
|
||||
Class.forName(AccessTransformer.class.getName() + "$Modifier", false, Launch.classLoader);
|
||||
Class<?> c_Modifier = Class
|
||||
.forName(AccessTransformer.class.getName() + "$Modifier", false, Launch.classLoader);
|
||||
f_Modifier_name = c_Modifier.getDeclaredField("name");
|
||||
f_Modifier_desc = c_Modifier.getDeclaredField("desc");
|
||||
|
||||
@@ -110,8 +117,7 @@ public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes,
|
||||
public static void load() {
|
||||
CodeChickenCoreModContainer.loadConfig();
|
||||
|
||||
if (CodeChickenCoreModContainer.config
|
||||
.getTag("dev.deobfuscate")
|
||||
if (CodeChickenCoreModContainer.config.getTag("dev.deobfuscate")
|
||||
.setComment("set to true to completely deobfuscate mcp names")
|
||||
.getBooleanValue(!ObfMapping.obfuscated)) {
|
||||
run = new ObfuscationRun(
|
||||
@@ -120,8 +126,7 @@ public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes,
|
||||
ObfuscationRun.fillDefaults(new HashMap<String, String>()));
|
||||
run.obf.setHeirachyEvaluator(instance);
|
||||
run.setQuiet().parseMappings();
|
||||
Collections.addAll(
|
||||
excludedPackages, run.config.get("excludedPackages").split(";"));
|
||||
Collections.addAll(excludedPackages, run.config.get("excludedPackages").split(";"));
|
||||
|
||||
if (ObfMapping.obfuscated) {
|
||||
ObfMapping.loadMCPRemapper();
|
||||
@@ -151,8 +156,12 @@ public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes,
|
||||
private byte[] injectCallback(byte[] bytes) {
|
||||
ClassNode cnode = ASMHelper.createClassNode(bytes);
|
||||
MethodNode mnode = ASMHelper.findMethod(new ObfMapping(cnode.name, "<clinit>", "()V"), cnode);
|
||||
mnode.instructions.insert(new MethodInsnNode(
|
||||
INVOKESTATIC, "codechicken/core/asm/MCPDeobfuscationTransformer", "loadCallback", "()V"));
|
||||
mnode.instructions.insert(
|
||||
new MethodInsnNode(
|
||||
INVOKESTATIC,
|
||||
"codechicken/core/asm/MCPDeobfuscationTransformer",
|
||||
"loadCallback",
|
||||
"()V"));
|
||||
return ASMHelper.createBytes(cnode, 0);
|
||||
}
|
||||
|
||||
@@ -205,8 +214,7 @@ public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes,
|
||||
try {
|
||||
byte[] bytes = Launch.classLoader.getClassBytes(name);
|
||||
if (bytes != null) return ObfuscationRun.getParents(ASMHelper.createClassNode(bytes));
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
} catch (IOException ignored) {}
|
||||
// clear the miss cache because the library containing it might be loaded later
|
||||
Launch.classLoader.clearNegativeEntries(Collections.singleton(name));
|
||||
return null;
|
||||
|
||||
@@ -2,17 +2,21 @@ package codechicken.core.asm;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.util.Printer;
|
||||
import org.objectweb.asm.util.TraceMethodVisitor;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
|
||||
public class MethodASMifier extends ClassVisitor {
|
||||
|
||||
PrintWriter printWriter;
|
||||
ObfMapping method;
|
||||
Printer asmifier;
|
||||
|
||||
@@ -2,19 +2,23 @@ package codechicken.core.asm;
|
||||
|
||||
import static codechicken.lib.asm.InsnComparator.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.JumpInsnNode;
|
||||
import org.objectweb.asm.tree.LabelNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import codechicken.lib.asm.*;
|
||||
import codechicken.lib.asm.ModularASMTransformer.MethodReplacer;
|
||||
import codechicken.lib.asm.ModularASMTransformer.MethodTransformer;
|
||||
import codechicken.lib.asm.ModularASMTransformer.MethodWriter;
|
||||
import codechicken.lib.config.ConfigTag;
|
||||
import java.util.Map;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.JumpInsnNode;
|
||||
import org.objectweb.asm.tree.LabelNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
public class TweakTransformer implements IClassTransformer, Opcodes {
|
||||
|
||||
static {
|
||||
ASMInit.init();
|
||||
}
|
||||
@@ -25,43 +29,42 @@ public class TweakTransformer implements IClassTransformer, Opcodes {
|
||||
|
||||
public static void load() {
|
||||
CodeChickenCoreModContainer.loadConfig();
|
||||
tweaks = CodeChickenCoreModContainer.config
|
||||
.getTag("tweaks")
|
||||
.setComment("Various tweaks that can be applied to game mechanics.")
|
||||
.useBraces();
|
||||
tweaks = CodeChickenCoreModContainer.config.getTag("tweaks")
|
||||
.setComment("Various tweaks that can be applied to game mechanics.").useBraces();
|
||||
tweaks.removeTag("persistantLava");
|
||||
|
||||
if (tweaks.getTag("environmentallyFriendlyCreepers")
|
||||
.setComment(
|
||||
"If set to true, creepers will not destroy landscape. (A version of mobGriefing setting just for creepers)")
|
||||
if (tweaks.getTag("environmentallyFriendlyCreepers").setComment(
|
||||
"If set to true, creepers will not destroy landscape. (A version of mobGriefing setting just for creepers)")
|
||||
.getBooleanValue(false)) {
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping("net/minecraft/entity/monster/EntityCreeper", "func_146077_cc", "()V"),
|
||||
blocks.get("d_environmentallyFriendlyCreepers"),
|
||||
blocks.get("environmentallyFriendlyCreepers")));
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping("net/minecraft/entity/monster/EntityCreeper", "func_146077_cc", "()V"),
|
||||
blocks.get("d_environmentallyFriendlyCreepers"),
|
||||
blocks.get("environmentallyFriendlyCreepers")));
|
||||
}
|
||||
|
||||
if (!tweaks.getTag("softLeafReplace")
|
||||
.setComment("If set to false, leaves will only replace air when growing")
|
||||
if (!tweaks.getTag("softLeafReplace").setComment("If set to false, leaves will only replace air when growing")
|
||||
.getBooleanValue(false)) {
|
||||
transformer.add(new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(
|
||||
"net/minecraft/block/Block",
|
||||
"canBeReplacedByLeaves",
|
||||
"(Lnet/minecraft/world/IBlockAccess;III)Z"),
|
||||
blocks.get("softLeafReplace")));
|
||||
transformer.add(
|
||||
new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(
|
||||
"net/minecraft/block/Block",
|
||||
"canBeReplacedByLeaves",
|
||||
"(Lnet/minecraft/world/IBlockAccess;III)Z"),
|
||||
blocks.get("softLeafReplace")));
|
||||
}
|
||||
|
||||
if (tweaks.getTag("doFireTickOut")
|
||||
.setComment(
|
||||
"If set to true and doFireTick is disabled in the game rules, fire will still dissipate if it's not over a fire source")
|
||||
if (tweaks.getTag("doFireTickOut").setComment(
|
||||
"If set to true and doFireTick is disabled in the game rules, fire will still dissipate if it's not over a fire source")
|
||||
.getBooleanValue(true)) {
|
||||
transformer.add(
|
||||
new MethodTransformer(new ObfMapping(
|
||||
"net/minecraft/block/BlockFire",
|
||||
"func_149674_a",
|
||||
"(Lnet/minecraft/world/World;IIILjava/util/Random;)V")) {
|
||||
new MethodTransformer(
|
||||
new ObfMapping(
|
||||
"net/minecraft/block/BlockFire",
|
||||
"func_149674_a",
|
||||
"(Lnet/minecraft/world/World;IIILjava/util/Random;)V")) {
|
||||
|
||||
@Override
|
||||
public void transform(MethodNode mv) {
|
||||
ASMBlock needle = blocks.get("n_doFireTick");
|
||||
@@ -79,10 +82,12 @@ public class TweakTransformer implements IClassTransformer, Opcodes {
|
||||
.setComment("If set to true two adjacent water source blocks will not generate a third.")
|
||||
.getBooleanValue(false)) {
|
||||
transformer.add(
|
||||
new MethodTransformer(new ObfMapping(
|
||||
"net/minecraft/block/BlockDynamicLiquid",
|
||||
"func_149674_a",
|
||||
"(Lnet/minecraft/world/World;IIILjava/util/Random;)V")) {
|
||||
new MethodTransformer(
|
||||
new ObfMapping(
|
||||
"net/minecraft/block/BlockDynamicLiquid",
|
||||
"func_149674_a",
|
||||
"(Lnet/minecraft/world/World;IIILjava/util/Random;)V")) {
|
||||
|
||||
@Override
|
||||
public void transform(MethodNode mv) {
|
||||
ASMBlock needle = blocks.get("finiteWater");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package codechicken.core.commands;
|
||||
|
||||
import codechicken.core.ServerUtils;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -15,8 +15,12 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import codechicken.core.ServerUtils;
|
||||
|
||||
public abstract class CoreCommand implements ICommand {
|
||||
|
||||
public class WCommandSender implements ICommandSender {
|
||||
|
||||
public ICommandSender wrapped;
|
||||
|
||||
public WCommandSender(ICommandSender sender) {
|
||||
@@ -125,10 +129,8 @@ public abstract class CoreCommand implements ICommand {
|
||||
@Override
|
||||
public boolean canCommandSenderUseCommand(ICommandSender var1) {
|
||||
if (OPOnly()) {
|
||||
if (var1 instanceof EntityPlayer)
|
||||
return MinecraftServer.getServer()
|
||||
.getConfigurationManager()
|
||||
.func_152596_g(((EntityPlayer) var1).getGameProfile());
|
||||
if (var1 instanceof EntityPlayer) return MinecraftServer.getServer().getConfigurationManager()
|
||||
.func_152596_g(((EntityPlayer) var1).getGameProfile());
|
||||
else if (var1 instanceof MinecraftServer) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public abstract class PlayerCommand extends CoreCommand {
|
||||
|
||||
@Override
|
||||
public boolean canCommandSenderUseCommand(ICommandSender var1) {
|
||||
if (!super.canCommandSenderUseCommand(var1)) return false;
|
||||
@@ -26,8 +27,8 @@ public abstract class PlayerCommand extends CoreCommand {
|
||||
public abstract void handleCommand(WorldServer world, EntityPlayerMP player, String[] args);
|
||||
|
||||
public ChunkPosition getPlayerLookingAtBlock(EntityPlayerMP player, float reach) {
|
||||
Vec3 vec3d =
|
||||
Vec3.createVectorHelper(player.posX, (player.posY + 1.6200000000000001D) - player.yOffset, player.posZ);
|
||||
Vec3 vec3d = Vec3
|
||||
.createVectorHelper(player.posX, (player.posY + 1.6200000000000001D) - player.yOffset, player.posZ);
|
||||
Vec3 vec3d1 = player.getLook(1.0F);
|
||||
Vec3 vec3d2 = vec3d.addVector(vec3d1.xCoord * reach, vec3d1.yCoord * reach, vec3d1.zCoord * reach);
|
||||
MovingObjectPosition hit = player.worldObj.rayTraceBlocks(vec3d, vec3d2);
|
||||
@@ -39,8 +40,8 @@ public abstract class PlayerCommand extends CoreCommand {
|
||||
}
|
||||
|
||||
public Entity getPlayerLookingAtEntity(EntityPlayerMP player, float reach) {
|
||||
Vec3 vec3d =
|
||||
Vec3.createVectorHelper(player.posX, (player.posY + 1.6200000000000001D) - player.yOffset, player.posZ);
|
||||
Vec3 vec3d = Vec3
|
||||
.createVectorHelper(player.posX, (player.posY + 1.6200000000000001D) - player.yOffset, player.posZ);
|
||||
Vec3 vec3d1 = player.getLook(1.0F);
|
||||
Vec3 vec3d2 = vec3d.addVector(vec3d1.xCoord * reach, vec3d1.yCoord * reach, vec3d1.zCoord * reach);
|
||||
MovingObjectPosition hit = player.worldObj.rayTraceBlocks(vec3d, vec3d2);
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public abstract class ServerCommand extends CoreCommand {
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender var1, String[] var2) {
|
||||
handleCommand(var2, (MinecraftServer) var1);
|
||||
|
||||
@@ -5,7 +5,9 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityRenderHook extends Entity {
|
||||
|
||||
public static interface IRenderCallback {
|
||||
|
||||
public void render(float frame, int pass);
|
||||
|
||||
public boolean shouldRenderInPass(int pass);
|
||||
|
||||
@@ -5,7 +5,9 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityUpdateHook extends Entity {
|
||||
|
||||
public static interface IUpdateCallback {
|
||||
|
||||
public void onUpdate();
|
||||
|
||||
public boolean isValid();
|
||||
|
||||
@@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class FeatureHack {
|
||||
|
||||
private static boolean updateHookEnabled = false;
|
||||
private static boolean renderHookEnabled = false;
|
||||
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package codechicken.core.featurehack;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ObjectIntIdentityMap;
|
||||
import net.minecraft.util.RegistryNamespaced;
|
||||
import net.minecraft.util.RegistrySimple;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
|
||||
public class GameDataManipulator {
|
||||
|
||||
public static Field f_registryObjects;
|
||||
public static Field f_underlyingIntegerMap;
|
||||
|
||||
@@ -16,15 +19,13 @@ public class GameDataManipulator {
|
||||
try {
|
||||
f_registryObjects = RegistrySimple.class.getDeclaredField(
|
||||
new ObfMapping("net/minecraft/util/RegistrySimple", "field_82596_a", "Ljava/util/Map;")
|
||||
.toRuntime()
|
||||
.s_name);
|
||||
.toRuntime().s_name);
|
||||
f_registryObjects.setAccessible(true);
|
||||
f_underlyingIntegerMap = RegistryNamespaced.class.getDeclaredField(new ObfMapping(
|
||||
f_underlyingIntegerMap = RegistryNamespaced.class.getDeclaredField(
|
||||
new ObfMapping(
|
||||
"net/minecraft/util/RegistryNamespaced",
|
||||
"field_148759_a",
|
||||
"Lnet/minecraft/util/ObjectIntIdentityMap;")
|
||||
.toRuntime()
|
||||
.s_name);
|
||||
"Lnet/minecraft/util/ObjectIntIdentityMap;").toRuntime().s_name);
|
||||
f_underlyingIntegerMap.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package codechicken.core.featurehack;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import codechicken.core.ReflectionManager;
|
||||
import codechicken.core.asm.TweakTransformer;
|
||||
import codechicken.core.featurehack.mc.TextureLavaFX;
|
||||
@@ -8,13 +15,9 @@ import codechicken.core.featurehack.mc.TextureWaterFX;
|
||||
import codechicken.core.featurehack.mc.TextureWaterFlowFX;
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import java.lang.reflect.Field;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class LiquidTextures {
|
||||
|
||||
public static IIcon[] newTextures = new IIcon[4];
|
||||
|
||||
public static boolean replaceLava;
|
||||
@@ -23,14 +26,10 @@ public class LiquidTextures {
|
||||
private static Field field_tex;
|
||||
|
||||
public static void init() {
|
||||
replaceWater = TweakTransformer.tweaks
|
||||
.getTag("replaceWaterFX")
|
||||
.setComment("Set this to true to use the pre1.5 water textures")
|
||||
.getBooleanValue(false);
|
||||
replaceLava = TweakTransformer.tweaks
|
||||
.getTag("replaceLavaFX")
|
||||
.setComment("Set this to true to use the pre1.5 lava textures")
|
||||
.getBooleanValue(false);
|
||||
replaceWater = TweakTransformer.tweaks.getTag("replaceWaterFX")
|
||||
.setComment("Set this to true to use the pre1.5 water textures").getBooleanValue(false);
|
||||
replaceLava = TweakTransformer.tweaks.getTag("replaceLavaFX")
|
||||
.setComment("Set this to true to use the pre1.5 lava textures").getBooleanValue(false);
|
||||
if (replaceWater) {
|
||||
newTextures[0] = new TextureWaterFX().texture;
|
||||
newTextures[1] = new TextureWaterFlowFX().texture;
|
||||
|
||||
@@ -4,9 +4,11 @@ import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderEntityRenderHook extends Render {
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float f, float frame) {
|
||||
EntityRenderHook hook = (EntityRenderHook) entity;
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class RenderNull extends Render {
|
||||
|
||||
@Override
|
||||
public void doRender(Entity var1, double var2, double var4, double var6, float var8, float var9) {}
|
||||
|
||||
|
||||
@@ -3,23 +3,23 @@ package codechicken.core.featurehack;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TweakTransformerHelper {
|
||||
|
||||
public static void quenchFireTick(World world, int x, int y, int z, Random rand) {
|
||||
Block base = world.getBlock(x, y - 1, z);
|
||||
boolean supported = (base != null && base.isFireSource(world, x, y - 1, z, UP));
|
||||
|
||||
if (!Blocks.fire.canPlaceBlockAt(world, x, y, z)
|
||||
|| !supported
|
||||
&& world.isRaining()
|
||||
&& (world.canLightningStrikeAt(x, y, z)
|
||||
|| world.canLightningStrikeAt(x - 1, y, z)
|
||||
|| world.canLightningStrikeAt(x + 1, y, z)
|
||||
|| world.canLightningStrikeAt(x, y, z - 1)
|
||||
|| world.canLightningStrikeAt(x, y, z + 1))) world.setBlockToAir(x, y, z);
|
||||
if (!Blocks.fire.canPlaceBlockAt(world, x, y, z) || !supported && world.isRaining()
|
||||
&& (world.canLightningStrikeAt(x, y, z) || world.canLightningStrikeAt(x - 1, y, z)
|
||||
|| world.canLightningStrikeAt(x + 1, y, z)
|
||||
|| world.canLightningStrikeAt(x, y, z - 1)
|
||||
|| world.canLightningStrikeAt(x, y, z + 1)))
|
||||
world.setBlockToAir(x, y, z);
|
||||
else {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta < 15) world.setBlockMetadataWithNotify(x, y, z, meta + rand.nextInt(3) / 2, 0);
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package codechicken.core.featurehack.mc;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import codechicken.lib.colour.ColourRGBA;
|
||||
import codechicken.lib.render.TextureFX;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TextureLavaFX extends TextureFX {
|
||||
|
||||
protected float[] field_76876_g = new float[256];
|
||||
protected float[] field_76878_h = new float[256];
|
||||
protected float[] field_76879_i = new float[256];
|
||||
@@ -52,16 +54,16 @@ public class TextureLavaFX extends TextureFX {
|
||||
|
||||
this.field_76878_h[var1 + var2 * tileSizeBase] = var3 / 10.0F
|
||||
+ (this.field_76879_i[(var1 + 0 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase]
|
||||
+ this.field_76879_i[
|
||||
(var1 + 1 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase]
|
||||
+ this.field_76879_i[
|
||||
(var1 + 1 & tileSizeMask) + (var2 + 1 & tileSizeMask) * tileSizeBase]
|
||||
+ this.field_76879_i[
|
||||
(var1 + 0 & tileSizeMask) + (var2 + 1 & tileSizeMask) * tileSizeBase])
|
||||
+ this.field_76879_i[(var1 + 1 & tileSizeMask)
|
||||
+ (var2 + 0 & tileSizeMask) * tileSizeBase]
|
||||
+ this.field_76879_i[(var1 + 1 & tileSizeMask)
|
||||
+ (var2 + 1 & tileSizeMask) * tileSizeBase]
|
||||
+ this.field_76879_i[(var1 + 0 & tileSizeMask)
|
||||
+ (var2 + 1 & tileSizeMask) * tileSizeBase])
|
||||
/ 4.0F
|
||||
* 0.8F;
|
||||
this.field_76879_i[var1 + var2 * tileSizeBase] +=
|
||||
this.field_76877_j[var1 + var2 * tileSizeBase] * 0.01F;
|
||||
this.field_76879_i[var1 + var2 * tileSizeBase] += this.field_76877_j[var1 + var2 * tileSizeBase]
|
||||
* 0.01F;
|
||||
|
||||
if (this.field_76879_i[var1 + var2 * tileSizeBase] < 0.0F) {
|
||||
this.field_76879_i[var1 + var2 * tileSizeBase] = 0.0F;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package codechicken.core.featurehack.mc;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import codechicken.lib.colour.ColourRGBA;
|
||||
import codechicken.lib.render.TextureFX;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TextureLavaFlowFX extends TextureFX {
|
||||
|
||||
protected float[] field_76871_g = new float[256];
|
||||
protected float[] field_76874_h = new float[256];
|
||||
protected float[] field_76875_i = new float[256];
|
||||
@@ -60,16 +62,16 @@ public class TextureLavaFlowFX extends TextureFX {
|
||||
|
||||
this.field_76874_h[var1 + var2 * tileSizeBase] = var3 / 10.0F
|
||||
+ (this.field_76875_i[(var1 + 0 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase]
|
||||
+ this.field_76875_i[
|
||||
(var1 + 1 & tileSizeMask) + (var2 + 0 & tileSizeMask) * tileSizeBase]
|
||||
+ this.field_76875_i[
|
||||
(var1 + 1 & tileSizeMask) + (var2 + 1 & tileSizeMask) * tileSizeBase]
|
||||
+ this.field_76875_i[
|
||||
(var1 + 0 & tileSizeMask) + (var2 + 1 & tileSizeMask) * tileSizeBase])
|
||||
+ this.field_76875_i[(var1 + 1 & tileSizeMask)
|
||||
+ (var2 + 0 & tileSizeMask) * tileSizeBase]
|
||||
+ this.field_76875_i[(var1 + 1 & tileSizeMask)
|
||||
+ (var2 + 1 & tileSizeMask) * tileSizeBase]
|
||||
+ this.field_76875_i[(var1 + 0 & tileSizeMask)
|
||||
+ (var2 + 1 & tileSizeMask) * tileSizeBase])
|
||||
/ 4.0F
|
||||
* 0.8F;
|
||||
this.field_76875_i[var1 + var2 * tileSizeBase] +=
|
||||
this.field_76872_j[var1 + var2 * tileSizeBase] * 0.01F;
|
||||
this.field_76875_i[var1 + var2 * tileSizeBase] += this.field_76872_j[var1 + var2 * tileSizeBase]
|
||||
* 0.01F;
|
||||
|
||||
if (this.field_76875_i[var1 + var2 * tileSizeBase] < 0.0F) {
|
||||
this.field_76875_i[var1 + var2 * tileSizeBase] = 0.0F;
|
||||
|
||||
@@ -7,6 +7,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TextureWaterFX extends TextureFX {
|
||||
|
||||
/** red RGB value for water texture */
|
||||
protected float[] red = new float[256];
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TextureWaterFlowFX extends TextureFX {
|
||||
|
||||
protected float[] field_76880_g = new float[256];
|
||||
protected float[] field_76883_h = new float[256];
|
||||
protected float[] field_76884_i = new float[256];
|
||||
@@ -51,15 +52,15 @@ public class TextureWaterFlowFX extends TextureFX {
|
||||
var3 += this.field_76880_g[var5 + var6 * tileSizeBase];
|
||||
}
|
||||
|
||||
this.field_76883_h[var1 + var2 * tileSizeBase] =
|
||||
var3 / 3.2F + this.field_76884_i[var1 + var2 * tileSizeBase] * 0.8F;
|
||||
this.field_76883_h[var1 + var2 * tileSizeBase] = var3 / 3.2F
|
||||
+ this.field_76884_i[var1 + var2 * tileSizeBase] * 0.8F;
|
||||
}
|
||||
}
|
||||
|
||||
for (var1 = 0; var1 < tileSizeBase; ++var1) {
|
||||
for (var2 = 0; var2 < tileSizeBase; ++var2) {
|
||||
this.field_76884_i[var1 + var2 * tileSizeBase] +=
|
||||
this.field_76881_j[var1 + var2 * tileSizeBase] * 0.05F;
|
||||
this.field_76884_i[var1 + var2 * tileSizeBase] += this.field_76881_j[var1 + var2 * tileSizeBase]
|
||||
* 0.05F;
|
||||
|
||||
if (this.field_76884_i[var1 + var2 * tileSizeBase] < 0.0F) {
|
||||
this.field_76884_i[var1 + var2 * tileSizeBase] = 0.0F;
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
public class ExtendedFluidTank implements IFluidTank {
|
||||
|
||||
private FluidStack fluid;
|
||||
private boolean changeType;
|
||||
private int capacity;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package codechicken.core.fluid;
|
||||
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -11,7 +10,10 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
|
||||
public class FluidUtils {
|
||||
|
||||
public static int B = FluidContainerRegistry.BUCKET_VOLUME;
|
||||
public static FluidStack water = new FluidStack(FluidRegistry.WATER, 1000);
|
||||
public static FluidStack lava = new FluidStack(FluidRegistry.LAVA, 1000);
|
||||
@@ -68,8 +70,7 @@ public class FluidUtils {
|
||||
}
|
||||
|
||||
public static NBTTagCompound write(FluidStack fluid, NBTTagCompound tag) {
|
||||
return fluid == null || fluid.getFluid() == null
|
||||
? new NBTTagCompound()
|
||||
return fluid == null || fluid.getFluid() == null ? new NBTTagCompound()
|
||||
: fluid.writeToNBT(new NBTTagCompound());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class TankAccess {
|
||||
|
||||
public IFluidHandler tank;
|
||||
public ForgeDirection side;
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package codechicken.core.gui;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class ClickCounter<T> {
|
||||
|
||||
public class ClickCount {
|
||||
|
||||
public T clicked;
|
||||
public long time;
|
||||
public int count;
|
||||
|
||||
@@ -3,9 +3,11 @@ package codechicken.core.gui;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiCCButton extends GuiWidget {
|
||||
|
||||
public String text;
|
||||
public String actionCommand;
|
||||
private boolean isEnabled = true;
|
||||
@@ -32,8 +34,7 @@ public class GuiCCButton extends GuiWidget {
|
||||
public void mouseClicked(int x, int y, int button) {
|
||||
if (isEnabled && pointInside(x, y) && actionCommand != null) {
|
||||
sendAction(actionCommand, button);
|
||||
Minecraft.getMinecraft()
|
||||
.getSoundHandler()
|
||||
Minecraft.getMinecraft().getSoundHandler()
|
||||
.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
}
|
||||
@@ -52,8 +53,8 @@ public class GuiCCButton extends GuiWidget {
|
||||
int state = getButtonTex(mousex, mousey);
|
||||
drawTexturedModalRect(x, y, 0, 46 + state * 20, width / 2, height / 2); // top left
|
||||
drawTexturedModalRect(x + width / 2, y, 200 - width / 2, 46 + state * 20, width / 2, height / 2); // top right
|
||||
drawTexturedModalRect(
|
||||
x, y + height / 2, 0, 46 + state * 20 + 20 - height / 2, width / 2, height / 2); // bottom left
|
||||
drawTexturedModalRect(x, y + height / 2, 0, 46 + state * 20 + 20 - height / 2, width / 2, height / 2); // bottom
|
||||
// left
|
||||
drawTexturedModalRect(
|
||||
x + width / 2,
|
||||
y + height / 2,
|
||||
|
||||
@@ -2,9 +2,11 @@ package codechicken.core.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.ChatAllowedCharacters;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class GuiCCTextField extends GuiWidget {
|
||||
|
||||
private String text;
|
||||
private boolean isFocused;
|
||||
private boolean isEnabled;
|
||||
@@ -63,10 +65,9 @@ public class GuiCCTextField extends GuiWidget {
|
||||
public void keyTyped(char c, int keycode) {
|
||||
if (!isEnabled || !isFocused) return;
|
||||
|
||||
/*if(c == '\t')//tab
|
||||
{
|
||||
parentGuiScreen.selectNextField();
|
||||
}*/
|
||||
/*
|
||||
* if(c == '\t')//tab { parentGuiScreen.selectNextField(); }
|
||||
*/
|
||||
if (c == '\026') // paste
|
||||
{
|
||||
String s = GuiScreen.getClipboardString();
|
||||
@@ -90,8 +91,7 @@ public class GuiCCTextField extends GuiWidget {
|
||||
}
|
||||
|
||||
public boolean canAddChar(char c) {
|
||||
return allowedCharacters == null
|
||||
? ChatAllowedCharacters.isAllowedCharacter(c)
|
||||
return allowedCharacters == null ? ChatAllowedCharacters.isAllowedCharacter(c)
|
||||
: allowedCharacters.indexOf(c) >= 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package codechicken.core.gui;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
|
||||
public class GuiScreenWidget extends GuiScreen implements IGuiActionListener {
|
||||
|
||||
public ArrayList<GuiWidget> widgets = new ArrayList<GuiWidget>();
|
||||
public int xSize, ySize, guiTop, guiLeft;
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package codechicken.core.gui;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import codechicken.lib.math.MathHelper;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import java.awt.*;
|
||||
|
||||
public abstract class GuiScrollPane extends GuiWidget {
|
||||
|
||||
protected int scrollclicky = -1;
|
||||
protected float scrollpercent;
|
||||
protected int scrollmousey;
|
||||
@@ -28,7 +30,10 @@ public abstract class GuiScrollPane extends GuiWidget {
|
||||
|
||||
public Rectangle windowBounds() {
|
||||
return new Rectangle(
|
||||
x + marginleft, y + margintop, width - marginleft - marginright, height - margintop - marginbottom);
|
||||
x + marginleft,
|
||||
y + margintop,
|
||||
width - marginleft - marginright,
|
||||
height - margintop - marginbottom);
|
||||
}
|
||||
|
||||
public abstract int contentHeight();
|
||||
@@ -103,13 +108,8 @@ public abstract class GuiScrollPane extends GuiWidget {
|
||||
Rectangle w = windowBounds();
|
||||
int barempty = height - sbar.height;
|
||||
|
||||
if (button == 0
|
||||
&& sbar.height < height
|
||||
&& // the scroll bar can move (not full length)
|
||||
mx >= sbar.x
|
||||
&& mx <= sbar.x + sbar.width
|
||||
&& my >= y
|
||||
&& my <= y + height) // in the scroll pane
|
||||
if (button == 0 && sbar.height < height && // the scroll bar can move (not full length)
|
||||
mx >= sbar.x && mx <= sbar.x + sbar.width && my >= y && my <= y + height) // in the scroll pane
|
||||
{
|
||||
if (my < sbar.y) {
|
||||
percentscrolled = (my - y) / (float) barempty;
|
||||
@@ -126,14 +126,12 @@ public abstract class GuiScrollPane extends GuiWidget {
|
||||
}
|
||||
|
||||
/**
|
||||
* Mouse down on slot area
|
||||
* Coordinates relative to slot content area
|
||||
* Mouse down on slot area Coordinates relative to slot content area
|
||||
*/
|
||||
public void slotDown(int mx, int my, int button) {}
|
||||
|
||||
/**
|
||||
* Mouse up on slot area
|
||||
* Coordinates relative to slot content area
|
||||
* Mouse up on slot area Coordinates relative to slot content area
|
||||
*/
|
||||
public void slotUp(int mx, int my, int button) {}
|
||||
|
||||
@@ -141,7 +139,7 @@ public abstract class GuiScrollPane extends GuiWidget {
|
||||
public void mouseMovedOrUp(int mx, int my, int button) {
|
||||
Rectangle w = windowBounds();
|
||||
if (isScrolling() && button == 0) // we were scrolling and we released mouse
|
||||
scrollclicky = -1;
|
||||
scrollclicky = -1;
|
||||
else if (w.contains(mx, my)) slotUp(mx - w.x, my - w.y + scrolledPixels(), button);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package codechicken.core.gui;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public abstract class GuiScrollSlot extends GuiScrollPane {
|
||||
|
||||
protected String actionCommand;
|
||||
public boolean focused;
|
||||
protected ClickCounter<Integer> click = new ClickCounter<Integer>();
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GuiWidget extends Gui {
|
||||
|
||||
protected static final ResourceLocation guiTex = new ResourceLocation("textures/gui/widgets.png");
|
||||
|
||||
public GuiScreen parentScreen;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package codechicken.core.gui;
|
||||
|
||||
public interface IGuiActionListener {
|
||||
|
||||
public void actionPerformed(String actionCommand, Object... params);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package codechicken.core.internal;
|
||||
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
|
||||
import codechicken.core.CCUpdateChecker;
|
||||
import codechicken.core.GuiModListScroll;
|
||||
import cpw.mods.fml.client.GuiModList;
|
||||
@@ -8,9 +10,9 @@ import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
|
||||
public class CCCEventHandler {
|
||||
|
||||
public static int renderTime;
|
||||
public static float renderFrame;
|
||||
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
package codechicken.core.inventory;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.core.gui.GuiWidget;
|
||||
import codechicken.core.gui.IGuiActionListener;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiContainerWidget extends GuiContainer implements IGuiActionListener {
|
||||
|
||||
public ArrayList<GuiWidget> widgets = new ArrayList<GuiWidget>();
|
||||
|
||||
public GuiContainerWidget(Container inventorySlots) {
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
package codechicken.core.launch;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.CharacterIterator;
|
||||
import java.text.StringCharacterIterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import codechicken.core.asm.*;
|
||||
import codechicken.lib.config.ConfigTag;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
@@ -11,27 +31,11 @@ import cpw.mods.fml.relauncher.IFMLCallHook;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.CharacterIterator;
|
||||
import java.text.StringCharacterIterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@TransformerExclusions(value = {"codechicken.core.asm", "codechicken.obfuscator"})
|
||||
@TransformerExclusions(value = { "codechicken.core.asm", "codechicken.obfuscator" })
|
||||
@MCVersion("1.7.10")
|
||||
public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
|
||||
public static final String mcVersion = "[1.7.10]";
|
||||
|
||||
@Deprecated
|
||||
@@ -54,20 +58,19 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
private void injectDeobfPlugin() {
|
||||
try {
|
||||
Class<?> wrapperClass = Class.forName("cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper");
|
||||
Constructor wrapperConstructor = wrapperClass.getConstructor(
|
||||
String.class, IFMLLoadingPlugin.class, File.class, Integer.TYPE, String[].class);
|
||||
Constructor wrapperConstructor = wrapperClass
|
||||
.getConstructor(String.class, IFMLLoadingPlugin.class, File.class, Integer.TYPE, String[].class);
|
||||
Field f_loadPlugins = CoreModManager.class.getDeclaredField("loadPlugins");
|
||||
wrapperConstructor.setAccessible(true);
|
||||
f_loadPlugins.setAccessible(true);
|
||||
((List) f_loadPlugins.get(null))
|
||||
.add(
|
||||
2,
|
||||
wrapperConstructor.newInstance(
|
||||
"CCCDeobfPlugin",
|
||||
new MCPDeobfuscationTransformer.LoadPlugin(),
|
||||
null,
|
||||
0,
|
||||
new String[0]));
|
||||
((List) f_loadPlugins.get(null)).add(
|
||||
2,
|
||||
wrapperConstructor.newInstance(
|
||||
"CCCDeobfPlugin",
|
||||
new MCPDeobfuscationTransformer.LoadPlugin(),
|
||||
null,
|
||||
0,
|
||||
new String[0]));
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to inject MCPDeobfuscation Transformer", e);
|
||||
}
|
||||
@@ -88,13 +91,13 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
ep.setEditable(false);
|
||||
ep.setOpaque(false);
|
||||
ep.addHyperlinkListener(new HyperlinkListener() {
|
||||
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent event) {
|
||||
try {
|
||||
if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
|
||||
Desktop.getDesktop().browse(event.getURL().toURI());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -134,45 +137,43 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
}
|
||||
|
||||
public static void systemCheck(ConfigTag checkRAM) {
|
||||
long minBytes = parseSize(checkRAM.getTag("minRAM")
|
||||
.setComment("Amount of RAM minimum this modpack needs to load")
|
||||
.getValue("3GB"));
|
||||
long minBytes = parseSize(
|
||||
checkRAM.getTag("minRAM").setComment("Amount of RAM minimum this modpack needs to load")
|
||||
.getValue("3GB"));
|
||||
if (Runtime.getRuntime().maxMemory() < minBytes) {
|
||||
String err = "You should have at least " + humanReadableByteCountBin(minBytes)
|
||||
+ " of RAM but you have only allocated "
|
||||
+ humanReadableByteCountBin(Runtime.getRuntime().maxMemory()) + ".";
|
||||
+ humanReadableByteCountBin(Runtime.getRuntime().maxMemory())
|
||||
+ ".";
|
||||
logger.error(err);
|
||||
|
||||
JEditorPane ep = new JEditorPane(
|
||||
"text/html",
|
||||
"<html>" + err + "<br>"
|
||||
+ checkRAM.getTag("modPack")
|
||||
.setComment("Name of the modpack")
|
||||
"<html>" + err
|
||||
+ "<br>"
|
||||
+ checkRAM.getTag("modPack").setComment("Name of the modpack")
|
||||
.getValue("Unidentified ModPack")
|
||||
+ " seriously won't run without enough RAM. "
|
||||
+ checkRAM.getTag("wiki")
|
||||
.setComment("Webpage describing RAM settings")
|
||||
.getValue(
|
||||
"See <a href=\"https://downloadmoreram.com\">DownloadMoreRam.com</a> for details.")
|
||||
+ checkRAM.getTag("wiki").setComment("Webpage describing RAM settings").getValue(
|
||||
"See <a href=\"https://downloadmoreram.com\">DownloadMoreRam.com</a> for details.")
|
||||
+ "<br>Recommended values are between "
|
||||
+ checkRAM.getTag("recRAM")
|
||||
.setComment("Lower bound of recommended RAM")
|
||||
.getValue("4GB") + " and "
|
||||
+ checkRAM.getTag("recRAMUpper")
|
||||
.setComment("Upper bound of recommended RAM")
|
||||
+ checkRAM.getTag("recRAM").setComment("Lower bound of recommended RAM").getValue("4GB")
|
||||
+ " and "
|
||||
+ checkRAM.getTag("recRAMUpper").setComment("Upper bound of recommended RAM")
|
||||
.getValue("6GB")
|
||||
+ ". Check your launcher's JVM arguments." + "</html>");
|
||||
+ ". Check your launcher's JVM arguments."
|
||||
+ "</html>");
|
||||
|
||||
ep.setEditable(false);
|
||||
ep.setOpaque(false);
|
||||
ep.addHyperlinkListener(new HyperlinkListener() {
|
||||
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent event) {
|
||||
try {
|
||||
if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
|
||||
Desktop.getDesktop().browse(event.getURL().toURI());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -185,12 +186,8 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
versionCheck(mcVersion, "CodeChickenCore");
|
||||
return new String[] {
|
||||
"codechicken.lib.asm.ClassHeirachyManager",
|
||||
"codechicken.core.asm.TweakTransformer",
|
||||
"codechicken.core.asm.DelegatedTransformer",
|
||||
"codechicken.core.asm.DefaultImplementationTransformer"
|
||||
};
|
||||
return new String[] { "codechicken.lib.asm.ClassHeirachyManager", "codechicken.core.asm.TweakTransformer",
|
||||
"codechicken.core.asm.DelegatedTransformer", "codechicken.core.asm.DefaultImplementationTransformer" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,13 +212,12 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
public Void call() {
|
||||
CodeChickenCoreModContainer.loadConfig();
|
||||
ConfigTag checkRAM;
|
||||
checkRAM = CodeChickenCoreModContainer.config
|
||||
.getTag("checks")
|
||||
.setComment("Configuration options for checking various requirements for a modpack.")
|
||||
.useBraces();
|
||||
checkRAM = CodeChickenCoreModContainer.config.getTag("checks")
|
||||
.setComment("Configuration options for checking various requirements for a modpack.").useBraces();
|
||||
if (checkRAM.getTag("checkRAM")
|
||||
.setComment("If set to true, check RAM available for Minecraft before continuing to load")
|
||||
.getBooleanValue(false)) systemCheck(checkRAM);
|
||||
.getBooleanValue(false))
|
||||
systemCheck(checkRAM);
|
||||
TweakTransformer.load();
|
||||
scanCodeChickenMods();
|
||||
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
package codechicken.core.launch;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import cpw.mods.fml.common.versioning.ComparableVersion;
|
||||
import cpw.mods.fml.relauncher.FMLInjectionData;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import cpw.mods.fml.relauncher.IFMLCallHook;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
import java.awt.*;
|
||||
import java.awt.Dialog.ModalityType;
|
||||
import java.awt.event.WindowAdapter;
|
||||
@@ -29,24 +20,39 @@ import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import sun.misc.URLClassPath;
|
||||
import sun.net.util.URLUtil;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import cpw.mods.fml.common.versioning.ComparableVersion;
|
||||
import cpw.mods.fml.relauncher.FMLInjectionData;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import cpw.mods.fml.relauncher.IFMLCallHook;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
|
||||
/**
|
||||
* For autodownloading stuff.
|
||||
* This is really unoriginal, mostly ripped off FML, credits to cpw.
|
||||
* For autodownloading stuff. This is really unoriginal, mostly ripped off FML, credits to cpw.
|
||||
*/
|
||||
@MCVersion("1.7.10")
|
||||
public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
|
||||
private static ByteBuffer downloadBuffer = ByteBuffer.allocateDirect(1 << 23);
|
||||
private static final String owner = "CB's DepLoader";
|
||||
private static DepLoadInst inst;
|
||||
|
||||
public interface IDownloadDisplay {
|
||||
|
||||
void resetProgress(int sizeGuess);
|
||||
|
||||
void setPokeThread(Thread currentThread);
|
||||
@@ -64,6 +70,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class Downloader extends JOptionPane implements IDownloadDisplay {
|
||||
|
||||
private JDialog container;
|
||||
private JLabel currentActivity;
|
||||
private JProgressBar progress;
|
||||
@@ -73,12 +80,13 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
private Box makeProgressPanel() {
|
||||
Box box = Box.createVerticalBox();
|
||||
box.add(Box.createRigidArea(new Dimension(0, 10)));
|
||||
JLabel welcomeLabel = new JLabel("<html><b><font size='+1'>" + owner
|
||||
+ " is setting up your minecraft environment</font></b></html>");
|
||||
JLabel welcomeLabel = new JLabel(
|
||||
"<html><b><font size='+1'>" + owner
|
||||
+ " is setting up your minecraft environment</font></b></html>");
|
||||
box.add(welcomeLabel);
|
||||
welcomeLabel.setAlignmentY(LEFT_ALIGNMENT);
|
||||
welcomeLabel =
|
||||
new JLabel("<html>Please wait, " + owner + " has some tasks to do before you can play</html>");
|
||||
welcomeLabel = new JLabel(
|
||||
"<html>Please wait, " + owner + " has some tasks to do before you can play</html>");
|
||||
welcomeLabel.setAlignmentY(LEFT_ALIGNMENT);
|
||||
box.add(welcomeLabel);
|
||||
box.add(Box.createRigidArea(new Dimension(0, 10)));
|
||||
@@ -98,8 +106,9 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
|
||||
setMessageType(JOptionPane.INFORMATION_MESSAGE);
|
||||
setMessage(makeProgressPanel());
|
||||
setOptions(new Object[] {"Stop"});
|
||||
setOptions(new Object[] { "Stop" });
|
||||
addPropertyChangeListener(new PropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (evt.getSource() == Downloader.this && evt.getPropertyName() == VALUE_PROPERTY) {
|
||||
@@ -117,6 +126,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
container.setVisible(true);
|
||||
container.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
container.addWindowListener(new WindowAdapter() {
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
requestClose(
|
||||
@@ -170,21 +180,26 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
JEditorPane ep = new JEditorPane(
|
||||
"text/html",
|
||||
"<html>" + owner
|
||||
+ " was unable to download required library " + name
|
||||
+ " was unable to download required library "
|
||||
+ name
|
||||
+ "<br>Check your internet connection and try restarting or download it manually from"
|
||||
+ "<br><a href=\""
|
||||
+ url + "\">" + url + "</a> and put it in your mods folder" + "</html>");
|
||||
+ url
|
||||
+ "\">"
|
||||
+ url
|
||||
+ "</a> and put it in your mods folder"
|
||||
+ "</html>");
|
||||
|
||||
ep.setEditable(false);
|
||||
ep.setOpaque(false);
|
||||
ep.addHyperlinkListener(new HyperlinkListener() {
|
||||
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent event) {
|
||||
try {
|
||||
if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
|
||||
Desktop.getDesktop().browse(event.getURL().toURI());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -193,6 +208,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
}
|
||||
|
||||
public static class DummyDownloader implements IDownloadDisplay {
|
||||
|
||||
@Override
|
||||
public void resetProgress(int sizeGuess) {}
|
||||
|
||||
@@ -220,6 +236,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
}
|
||||
|
||||
public static class VersionedFile {
|
||||
|
||||
public final Pattern pattern;
|
||||
public final String filename;
|
||||
public final ComparableVersion version;
|
||||
@@ -244,6 +261,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
}
|
||||
|
||||
public static class Dependency {
|
||||
|
||||
public String url;
|
||||
public VersionedFile file;
|
||||
|
||||
@@ -261,6 +279,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
}
|
||||
|
||||
public static class DepLoadInst {
|
||||
|
||||
private File modsDir;
|
||||
private File v_modsDir;
|
||||
private IDownloadDisplay downloadMonitor;
|
||||
@@ -312,7 +331,8 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
|
||||
if (!mod.delete()) {
|
||||
mod.deleteOnExit();
|
||||
String msg = owner + " was unable to delete file " + mod.getPath()
|
||||
String msg = owner + " was unable to delete file "
|
||||
+ mod.getPath()
|
||||
+ " the game will now try to delete it on exit. If this dialog appears again, delete it manually.";
|
||||
CodeChickenCorePlugin.logger.error(msg);
|
||||
if (!GraphicsEnvironment.isHeadless())
|
||||
@@ -342,8 +362,8 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
} catch (Exception e) {
|
||||
libFile.delete();
|
||||
if (downloadMonitor.shouldStopIt()) {
|
||||
CodeChickenCorePlugin.logger.error(
|
||||
"You have stopped the downloading operation before it could complete");
|
||||
CodeChickenCorePlugin.logger
|
||||
.error("You have stopped the downloading operation before it could complete");
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
@@ -353,10 +373,10 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
}
|
||||
|
||||
private void download(InputStream is, int sizeGuess, File target) throws Exception {
|
||||
if (sizeGuess > downloadBuffer.capacity())
|
||||
throw new Exception(String.format(
|
||||
"The file %s is too large to be downloaded by " + owner + " - the download is invalid",
|
||||
target.getName()));
|
||||
if (sizeGuess > downloadBuffer.capacity()) throw new Exception(
|
||||
String.format(
|
||||
"The file %s is too large to be downloaded by " + owner + " - the download is invalid",
|
||||
target.getName()));
|
||||
|
||||
downloadBuffer.clear();
|
||||
|
||||
@@ -387,20 +407,20 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
}
|
||||
|
||||
try {
|
||||
/*String cksum = generateChecksum(downloadBuffer);
|
||||
if (cksum.equals(validationHash))
|
||||
{*/
|
||||
/*
|
||||
* String cksum = generateChecksum(downloadBuffer); if (cksum.equals(validationHash)) {
|
||||
*/
|
||||
if (!target.exists()) target.createNewFile();
|
||||
|
||||
downloadBuffer.position(0);
|
||||
FileOutputStream fos = new FileOutputStream(target);
|
||||
fos.getChannel().write(downloadBuffer);
|
||||
fos.close();
|
||||
/*}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException(String.format("The downloaded file %s has an invalid checksum %s (expecting %s). The download did not succeed correctly and the file has been deleted. Please try launching again.", target.getName(), cksum, validationHash));
|
||||
}*/
|
||||
/*
|
||||
* } else { throw new RuntimeException(String.
|
||||
* format("The downloaded file %s has an invalid checksum %s (expecting %s). The download did not succeed correctly and the file has been deleted. Please try launching again."
|
||||
* , target.getName(), cksum, validationHash)); }
|
||||
*/
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
@@ -427,8 +447,12 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
return null;
|
||||
}
|
||||
if (cmp > 0) {
|
||||
CodeChickenCorePlugin.logger.warn("Warning: version of " + dep.file.name + ", " + vfile.version
|
||||
+ " is newer than request " + dep.file.version);
|
||||
CodeChickenCorePlugin.logger.warn(
|
||||
"Warning: version of " + dep.file.name
|
||||
+ ", "
|
||||
+ vfile.version
|
||||
+ " is newer than request "
|
||||
+ dep.file.version);
|
||||
return f.getName();
|
||||
}
|
||||
return f.getName(); // found dependency
|
||||
@@ -497,8 +521,8 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
if (e != null) loadJSon(zip.getInputStream(e));
|
||||
zip.close();
|
||||
} catch (Exception e) {
|
||||
CodeChickenCorePlugin.logger.error(
|
||||
"Failed to load dependencies.info from " + file.getName() + " as JSON");
|
||||
CodeChickenCorePlugin.logger
|
||||
.error("Failed to load dependencies.info from " + file.getName() + " as JSON");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -516,9 +540,8 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
}
|
||||
|
||||
private void loadJson(JsonObject node) throws IOException {
|
||||
boolean obfuscated =
|
||||
((LaunchClassLoader) DepLoader.class.getClassLoader()).getClassBytes("net.minecraft.world.World")
|
||||
== null;
|
||||
boolean obfuscated = ((LaunchClassLoader) DepLoader.class.getClassLoader())
|
||||
.getClassBytes("net.minecraft.world.World") == null;
|
||||
|
||||
String testClass = node.get("class").getAsString();
|
||||
if (DepLoader.class.getResource("/" + testClass.replace('.', '/') + ".class") != null) return;
|
||||
@@ -531,8 +554,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
if (node.has("pattern"))
|
||||
pattern = Pattern.compile(node.get("pattern").getAsString());
|
||||
if (node.has("pattern")) pattern = Pattern.compile(node.get("pattern").getAsString());
|
||||
} catch (PatternSyntaxException e) {
|
||||
CodeChickenCorePlugin.logger.error("Invalid filename pattern: " + node.get("pattern"));
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -2,9 +2,9 @@ package codechicken.obfuscator;
|
||||
|
||||
import static org.objectweb.asm.tree.AbstractInsnNode.*;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -12,7 +12,10 @@ import org.objectweb.asm.tree.LdcInsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
|
||||
public class ConstantObfuscator implements Opcodes {
|
||||
|
||||
public ObfRemapper obf;
|
||||
public List<ObfMapping> descCalls = new LinkedList<ObfMapping>();
|
||||
public List<ObfMapping> classCalls = new LinkedList<ObfMapping>();
|
||||
|
||||
@@ -3,6 +3,7 @@ package codechicken.obfuscator;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class DummyOutputStream extends OutputStream {
|
||||
|
||||
public static DummyOutputStream instance = new DummyOutputStream();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package codechicken.obfuscator;
|
||||
|
||||
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
|
||||
|
||||
public interface IHeirachyEvaluator {
|
||||
|
||||
/**
|
||||
* @param desc The mapping descriptor of the class to evaluate heirachy for
|
||||
* @return A list of parents (srg or obf names)
|
||||
|
||||
@@ -3,6 +3,7 @@ package codechicken.obfuscator;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public interface ILogStreams {
|
||||
|
||||
public PrintStream err();
|
||||
|
||||
public PrintStream out();
|
||||
|
||||
@@ -4,6 +4,7 @@ import codechicken.lib.asm.ObfMapping;
|
||||
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
|
||||
|
||||
public class ObfDirection {
|
||||
|
||||
public boolean obfuscate;
|
||||
public boolean srg;
|
||||
public boolean srg_cst;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package codechicken.obfuscator;
|
||||
|
||||
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
|
||||
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
|
||||
|
||||
public class ObfRemapper extends Remapper {
|
||||
|
||||
public final ObfuscationMap obf;
|
||||
public ObfDirection dir;
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package codechicken.obfuscator;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -10,8 +7,15 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
|
||||
public class ObfuscationMap {
|
||||
|
||||
public class ObfuscationEntry {
|
||||
|
||||
public final ObfMapping obf;
|
||||
public final ObfMapping srg;
|
||||
public final ObfMapping mcp;
|
||||
@@ -24,6 +28,7 @@ public class ObfuscationMap {
|
||||
}
|
||||
|
||||
private class ClassEntry extends ObfuscationEntry {
|
||||
|
||||
public Map<String, ObfuscationEntry> mcpMap = new HashMap<String, ObfuscationEntry>();
|
||||
public Map<String, ObfuscationEntry> srgMap = new HashMap<String, ObfuscationEntry>();
|
||||
public Map<String, ObfuscationEntry> obfMap = new HashMap<String, ObfuscationEntry>();
|
||||
@@ -81,8 +86,8 @@ public class ObfuscationMap {
|
||||
return addEntry(new ObfMapping(obf_owner, obf_name, ""), new ObfMapping(srg_owner, srg_name, ""));
|
||||
}
|
||||
|
||||
public ObfuscationEntry addMethod(
|
||||
String obf_owner, String obf_name, String obf_desc, String srg_owner, String srg_name, String srg_desc) {
|
||||
public ObfuscationEntry addMethod(String obf_owner, String obf_name, String obf_desc, String srg_owner,
|
||||
String srg_name, String srg_desc) {
|
||||
return addEntry(new ObfMapping(obf_owner, obf_name, obf_desc), new ObfMapping(srg_owner, srg_name, srg_desc));
|
||||
}
|
||||
|
||||
@@ -161,10 +166,8 @@ public class ObfuscationMap {
|
||||
private ObfuscationEntry getOrCreateClassEntry(String name) {
|
||||
ObfuscationEntry e = lookupObfClass(name);
|
||||
if (e == null) e = lookupMcpClass(name);
|
||||
if (e == null)
|
||||
e = addClass(
|
||||
name,
|
||||
name); // if the class isn't in obf or srg maps, it must be a custom mod class with no name change.
|
||||
if (e == null) e = addClass(name, name); // if the class isn't in obf or srg maps, it must be a custom mod class
|
||||
// with no name change.
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -207,7 +210,7 @@ public class ObfuscationMap {
|
||||
|
||||
public static String[] splitLast(String s, char c) {
|
||||
int i = s.lastIndexOf(c);
|
||||
return new String[] {s.substring(0, i), s.substring(i + 1)};
|
||||
return new String[] { s.substring(0, i), s.substring(i + 1) };
|
||||
}
|
||||
|
||||
public static String[] split4(String s, char c) {
|
||||
@@ -230,6 +233,7 @@ public class ObfuscationMap {
|
||||
log.out().println("Parsing " + srgs.getName());
|
||||
|
||||
Function<String, Void> function = new Function<String, Void>() {
|
||||
|
||||
@Override
|
||||
public Void apply(String line) {
|
||||
int hpos = line.indexOf('#');
|
||||
@@ -261,6 +265,7 @@ public class ObfuscationMap {
|
||||
log.out().println("Parsing " + csv.getName());
|
||||
|
||||
Function<String, Void> function = new Function<String, Void>() {
|
||||
|
||||
@Override
|
||||
public Void apply(String line) {
|
||||
if (line.startsWith("func_") || line.startsWith("field_")) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package codechicken.obfuscator;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
@@ -9,11 +8,15 @@ import java.text.DecimalFormat;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.commons.RemappingClassAdapter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
public class ObfuscationRun implements ILogStreams {
|
||||
|
||||
public final ObfDirection obfDir;
|
||||
public final ObfuscationMap obf;
|
||||
public final ObfRemapper obfMapper;
|
||||
@@ -98,27 +101,24 @@ public class ObfuscationRun implements ILogStreams {
|
||||
}
|
||||
|
||||
public static Map<String, String> fillDefaults(Map<String, String> config) {
|
||||
if (!config.containsKey("excludedPackages"))
|
||||
config.put(
|
||||
"excludedPackages",
|
||||
"java/;sun/;javax/;scala/;" + "argo/;org/lwjgl/;org/objectweb/;org/bouncycastle/;com/google/");
|
||||
if (!config.containsKey("excludedPackages")) config.put(
|
||||
"excludedPackages",
|
||||
"java/;sun/;javax/;scala/;" + "argo/;org/lwjgl/;org/objectweb/;org/bouncycastle/;com/google/");
|
||||
if (!config.containsKey("ignore")) config.put("ignore", ".");
|
||||
if (!config.containsKey("classConstantCalls"))
|
||||
config.put(
|
||||
"classConstantCalls",
|
||||
"codechicken/lib/asm/ObfMapping.<init>(Ljava/lang/String;)V,"
|
||||
+ "codechicken/lib/asm/ObfMapping.subclass(Ljava/lang/String;)Lcodechicken/lib/asm/ObfMapping;,"
|
||||
+ "codechicken/lib/asm/ObfMapping.<init>(Lcodechicken/lib/asm/ObfMapping;Ljava/lang/String;)V");
|
||||
if (!config.containsKey("descConstantCalls"))
|
||||
config.put(
|
||||
"descConstantCalls",
|
||||
"codechicken/lib/asm/ObfMapping.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/MethodVisitor.visitFieldInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/tree/MethodNode.visitFieldInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/MethodVisitor.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/tree/MethodNode.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/tree/MethodInsnNode.<init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/tree/FieldInsnNode.<init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
if (!config.containsKey("classConstantCalls")) config.put(
|
||||
"classConstantCalls",
|
||||
"codechicken/lib/asm/ObfMapping.<init>(Ljava/lang/String;)V,"
|
||||
+ "codechicken/lib/asm/ObfMapping.subclass(Ljava/lang/String;)Lcodechicken/lib/asm/ObfMapping;,"
|
||||
+ "codechicken/lib/asm/ObfMapping.<init>(Lcodechicken/lib/asm/ObfMapping;Ljava/lang/String;)V");
|
||||
if (!config.containsKey("descConstantCalls")) config.put(
|
||||
"descConstantCalls",
|
||||
"codechicken/lib/asm/ObfMapping.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/MethodVisitor.visitFieldInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/tree/MethodNode.visitFieldInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/MethodVisitor.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/tree/MethodNode.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/tree/MethodInsnNode.<init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V,"
|
||||
+ "org/objectweb/asm/tree/FieldInsnNode.<init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
|
||||
return config;
|
||||
}
|
||||
@@ -135,9 +135,8 @@ public class ObfuscationRun implements ILogStreams {
|
||||
}
|
||||
|
||||
public static void processFiles(File dir, Function<File, Void> function, boolean recursive) {
|
||||
for (File file : dir.listFiles())
|
||||
if (file.isDirectory() && recursive) processFiles(file, function, recursive);
|
||||
else function.apply(file);
|
||||
for (File file : dir.listFiles()) if (file.isDirectory() && recursive) processFiles(file, function, recursive);
|
||||
else function.apply(file);
|
||||
}
|
||||
|
||||
public static void deleteDir(File directory, boolean remove) {
|
||||
@@ -173,7 +172,7 @@ public class ObfuscationRun implements ILogStreams {
|
||||
File fields = new File(mapDir, "fields.csv");
|
||||
if (!fields.exists()) throw new RuntimeException("Could not find fields.csv");
|
||||
|
||||
return new File[] {srgs, methods, fields};
|
||||
return new File[] { srgs, methods, fields };
|
||||
}
|
||||
|
||||
public long startTime() {
|
||||
@@ -196,8 +195,8 @@ public class ObfuscationRun implements ILogStreams {
|
||||
|
||||
public void finish(boolean errored) {
|
||||
long millis = System.currentTimeMillis() - startTime;
|
||||
out().println((errored ? "Errored after" : "Done in ") + new DecimalFormat("0.00").format(millis / 1000D)
|
||||
+ "s");
|
||||
out().println(
|
||||
(errored ? "Errored after" : "Done in ") + new DecimalFormat("0.00").format(millis / 1000D) + "s");
|
||||
finished = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package codechicken.obfuscator;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class SystemLogStreams implements ILogStreams {
|
||||
|
||||
public static SystemLogStreams inst = new SystemLogStreams();
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user