forked from xjboss/KCauldronX
Patch ClimateControl for compatibility. Meh.
This commit is contained in:
parent
7483df1567
commit
bab4bd8b46
34
build.gradle
34
build.gradle
@ -62,7 +62,7 @@ ext.mcVersion = "1.7.10"
|
||||
ext.forgeVersion = "1408"
|
||||
ext.revision = retrieveBuildNumber()
|
||||
version = "${mcVersion}-${forgeVersion}.${revision}"
|
||||
println "Updated KCauldron version: ${version}"
|
||||
println " # Updated KCauldron version: ${version}"
|
||||
|
||||
launch4j {
|
||||
jreMinVersion = '1.6.0'
|
||||
@ -128,3 +128,35 @@ publishing {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.generateProjectCauldron << {
|
||||
def file = new File('eclipse/cauldron/build.gradle')
|
||||
file.append('''
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://prok.pw/repo'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
compile 'pw.prok:KImagine:+@jar'
|
||||
}
|
||||
''')
|
||||
}
|
||||
|
||||
configurations {
|
||||
compile.extendsFrom exported
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://prok.pw/repo'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
exported 'pw.prok:KImagine:+'
|
||||
}
|
||||
|
||||
packageUniversal {
|
||||
from { configurations.exported.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||
}
|
||||
|
@ -23,19 +23,24 @@
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.asm.transformers.ModAccessTransformer;
|
||||
import cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker;
|
||||
@@ -94,6 +99,11 @@
|
||||
@@ -53,7 +58,7 @@
|
||||
private static final Attributes.Name COREMODCONTAINSFMLMOD = new Attributes.Name("FMLCorePluginContainsFMLMod");
|
||||
private static final Attributes.Name MODTYPE = new Attributes.Name("ModType");
|
||||
private static final Attributes.Name MODSIDE = new Attributes.Name("ModSide");
|
||||
- private static String[] rootPlugins = { "cpw.mods.fml.relauncher.FMLCorePlugin", "net.minecraftforge.classloading.FMLForgePlugin" };
|
||||
+ private static String[] rootPlugins = { "cpw.mods.fml.relauncher.FMLCorePlugin", "net.minecraftforge.classloading.FMLForgePlugin", "pw.prok.imagine.ImagineLoadingPlugin" };
|
||||
private static List<String> loadedCoremods = Lists.newArrayList();
|
||||
private static List<FMLPluginWrapper> loadPlugins;
|
||||
private static boolean deobfuscatedEnvironment;
|
||||
@@ -94,6 +99,7 @@
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader)
|
||||
{
|
||||
+ // Cauldron start
|
||||
+ // Register own ClassTransformer for some needs
|
||||
+ classLoader.registerTransformer("kcauldron.KCauldronClassTransformer");
|
||||
+ KCauldronClassTransformer.DEV = deobfuscatedEnvironment;
|
||||
+ // Cauldron end
|
||||
FMLRelaunchLog.fine("Injecting coremod %s {%s} class transformers", name, coreModInstance.getClass().getName());
|
||||
if (coreModInstance.getASMTransformerClass() != null) for (String transformer : coreModInstance.getASMTransformerClass())
|
||||
{
|
||||
@@ -153,6 +163,9 @@
|
||||
@@ -153,6 +159,9 @@
|
||||
|
||||
}
|
||||
|
||||
@ -45,7 +50,7 @@
|
||||
public static void handleLaunch(File mcDir, LaunchClassLoader classLoader, FMLTweaker tweaker)
|
||||
{
|
||||
CoreModManager.mcDir = mcDir;
|
||||
@@ -212,6 +225,19 @@
|
||||
@@ -212,6 +221,19 @@
|
||||
loadCoreMod(classLoader, coreModClassName, null);
|
||||
}
|
||||
discoverCoreMods(mcDir, classLoader);
|
||||
@ -65,7 +70,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -322,6 +348,10 @@
|
||||
@@ -322,6 +344,10 @@
|
||||
FMLRelaunchLog.fine("Not found coremod data in %s", coreMod.getName());
|
||||
continue;
|
||||
}
|
||||
@ -76,7 +81,7 @@
|
||||
// Support things that are mod jars, but not FML mod jars
|
||||
try
|
||||
{
|
||||
@@ -424,8 +454,11 @@
|
||||
@@ -424,8 +450,11 @@
|
||||
MCVersion requiredMCVersion = coreModClazz.getAnnotation(IFMLLoadingPlugin.MCVersion.class);
|
||||
if (!Arrays.asList(rootPlugins).contains(coreModClass) && (requiredMCVersion == null || Strings.isNullOrEmpty(requiredMCVersion.value())))
|
||||
{
|
||||
|
@ -1,53 +1,88 @@
|
||||
package kcauldron;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.IntInsnNode;
|
||||
|
||||
import pw.prok.imagine.api.Pair;
|
||||
import pw.prok.imagine.asm.ImagineASM;
|
||||
import pw.prok.imagine.asm.ImagineMethod;
|
||||
import pw.prok.imagine.asm.ImagineRemapper;
|
||||
import pw.prok.imagine.asm.Transformer;
|
||||
|
||||
import com.avaje.ebean.annotation.Transactional;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
public class KCauldronClassTransformer implements IClassTransformer {
|
||||
public static boolean DEV;
|
||||
|
||||
@Transformer.RegisterTransformer
|
||||
public class KCauldronClassTransformer implements Transformer {
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if ("net.minecraft.world.gen.ChunkProviderServer".equals(transformedName) || "net.minecraftforge.common.chunkio.ChunkIOProvider".equals(transformedName)) {
|
||||
return patchChunkCall(basicClass);
|
||||
public void transform(final ImagineASM asm) {
|
||||
if (asm.is("net.minecraft.world.gen.ChunkProviderServer")
|
||||
|| asm.is("net.minecraftforge.common.chunkio.ChunkIOProvider")) {
|
||||
FMLLog.log(Level.INFO, "KCauldron: Patching " + asm.getActualName() + " for compatibility with Mystcraft");
|
||||
ClassReader reader = new ClassReader(asm.build());
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
reader.accept(new ClassVisitor(ASM5, writer) {
|
||||
@Override
|
||||
public FieldVisitor visitField(int access, String name,
|
||||
String desc, String signature, Object value) {
|
||||
if ("loadedChunkHashMap_vanilla".equals(name)) {
|
||||
name = asm.isDev() ? "loadedChunkHashMap" : "field_73244_f";
|
||||
}
|
||||
return super.visitField(access, name, desc, signature,
|
||||
value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name,
|
||||
String desc, String signature, String[] exceptions) {
|
||||
return new MethodVisitor(api, super.visitMethod(access,
|
||||
name, desc, signature, exceptions)) {
|
||||
@Override
|
||||
public void visitFieldInsn(int opcode, String owner,
|
||||
String name, String desc) {
|
||||
if ("loadedChunkHashMap_vanilla".equals(name)) {
|
||||
name = asm.isDev() ? "loadedChunkHashMap" : "field_73244_f";
|
||||
}
|
||||
super.visitFieldInsn(opcode, owner, name, desc);
|
||||
}
|
||||
};
|
||||
}
|
||||
}, 0);
|
||||
asm.loadClass(writer.toByteArray());
|
||||
}
|
||||
if (asm.is("climateControl.utils.ChunkGeneratorExtractor")) {
|
||||
boolean undergroundBiomesInstalled = false;
|
||||
try {
|
||||
Class.forName("exterminatorJeff.undergroundBiomes.worldGen.ChunkProviderWrapper");
|
||||
undergroundBiomesInstalled = true;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (!undergroundBiomesInstalled) {
|
||||
FMLLog.log(Level.INFO, "KCauldron: Patching " + asm.getActualName() + " for compatibility with Climate Control");
|
||||
extractFrom(asm, asm.method("extractFrom",
|
||||
"(Lnet/minecraft/world/WorldServer;)Lnet/minecraft/world/chunk/IChunkProvider;").instructions());
|
||||
}
|
||||
}
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
private byte[] patchChunkCall(byte[] bytes) {
|
||||
ClassReader reader = new ClassReader(bytes);
|
||||
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
reader.accept(new ClassVisitor(ASM5, writer) {
|
||||
@Override
|
||||
public FieldVisitor visitField(int access, String name,
|
||||
String desc, String signature, Object value) {
|
||||
if ("loadedChunkHashMap_vanilla".equals(name)) {
|
||||
name = DEV ? "loadedChunkHashMap" : "field_73244_f";
|
||||
}
|
||||
return super.visitField(access, name, desc, signature, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name,
|
||||
String desc, String signature, String[] exceptions) {
|
||||
return new MethodVisitor(api, super.visitMethod(access, name, desc, signature, exceptions)) {
|
||||
@Override
|
||||
public void visitFieldInsn(int opcode, String owner,
|
||||
String name, String desc) {
|
||||
if ("loadedChunkHashMap_vanilla".equals(name)) {
|
||||
name = DEV ? "loadedChunkHashMap" : "field_73244_f";
|
||||
}
|
||||
super.visitFieldInsn(opcode, owner, name, desc);
|
||||
}
|
||||
};
|
||||
}
|
||||
}, 0);
|
||||
return writer.toByteArray();
|
||||
public void extractFrom(ImagineASM asm, InsnList list) {
|
||||
//Pair<String, String> fieldChunkProvider = asm.field("net/minecraft/world/World", "chunkProvider");
|
||||
list.clear();
|
||||
list.add(new IntInsnNode(ALOAD, 1));
|
||||
list.add(new FieldInsnNode(GETFIELD, "ahb", "v", "Lapu;"));
|
||||
list.add(new InsnNode(ARETURN));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user