Jump to content

[1.7.2] [Unsolved] How to create a coremod in 1.7.2? (modify vanilla classes)


Recommended Posts

Posted

I've followed the steps at Tutorial [1.6.2] Changing vanilla without editing base classes [coremods] and [events] very advanced!

 

But when i run minecraft on eclipse a get this crash:

 

[15:14:40] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker
[15:14:40] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker
[15:14:40] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker
[15:14:40] [main/INFO] [FML]: Forge Mod Loader version 7.2.109.1022 for Minecraft 1.7.2 loading
[15:14:40] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_25, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre7
[15:14:40] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[15:14:40] [main/INFO] [FML]: Found a command line coremod : SackCastellon.core.asm.FMLLoadingPlugin
********* getAccessTransformerClass. OK
[15:14:40] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[15:14:40] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker
[15:14:40] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[15:14:40] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker
[15:14:40] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper
[15:14:40] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[15:14:41] [main/ERROR] [FML]: The minecraft jar file:/C:/Users/Juanjo%20hijo/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.2-10.12.0.1022/forgeSrc-1.7.2-10.12.0.1022.jar!/net/minecraft/client/ClientBrandRetriever.class appears to be corrupt! There has been CRITICAL TAMPERING WITH MINECRAFT, it is highly unlikely minecraft will work! STOP NOW, get a clean copy and try again!
[15:14:41] [main/ERROR] [FML]: FML has been ordered to ignore the invalid or missing minecraft certificate. This is very likely to cause a problem!
[15:14:41] [main/ERROR] [FML]: Technical information: ClientBrandRetriever was at jar:file:/C:/Users/Juanjo%20hijo/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.2-10.12.0.1022/forgeSrc-1.7.2-10.12.0.1022.jar!/net/minecraft/client/ClientBrandRetriever.class, there were 0 certificates for it
[15:14:41] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[15:14:41] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper
[15:14:41] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper
********* getASMTransformerClass. OK
********* getASMTransformerClass. OK
********* injectData. OK
********* getSetupClass. OK
********* getModContainerClass. OK
[15:14:41] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker
[15:14:42] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[15:14:43] [main/INFO]: Setting user: Player848
********* PATCHING CLASS: net.minecraft.block.BlockEnchantmentTable
[15:14:44] [main/ERROR] [LaunchWrapper]: Unable to launch
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_25]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_25]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?]
Caused by: java.lang.NoClassDefFoundError: net/minecraft/block/BlockEnchantmentTable
at net.minecraft.block.Block.func_149671_p(Block.java:325) ~[block.class:?]
at net.minecraft.init.Bootstrap.func_151354_b(Bootstrap.java:457) ~[bootstrap.class:?]
at net.minecraft.client.Minecraft.<init>(Minecraft.java:356) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:89) ~[Main.class:?]
... 6 more
Caused by: java.lang.ClassNotFoundException: net.minecraft.block.BlockEnchantmentTable
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:188) ~[launchwrapper-1.9.jar:?]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]
at net.minecraft.block.Block.func_149671_p(Block.java:325) ~[block.class:?]
at net.minecraft.init.Bootstrap.func_151354_b(Bootstrap.java:457) ~[bootstrap.class:?]
at net.minecraft.client.Minecraft.<init>(Minecraft.java:356) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:89) ~[Main.class:?]
... 6 more
Caused by: java.lang.NullPointerException
at SackCastellon.core.asm.ClassTransformer.patchClassInJar(ClassTransformer.java:49) ~[bin/:?]
at SackCastellon.core.asm.ClassTransformer.transform(ClassTransformer.java:18) ~[bin/:?]
at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:276) ~[launchwrapper-1.9.jar:?]
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:174) ~[launchwrapper-1.9.jar:?]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_25]
at net.minecraft.block.Block.func_149671_p(Block.java:325) ~[block.class:?]
at net.minecraft.init.Bootstrap.func_151354_b(Bootstrap.java:457) ~[bootstrap.class:?]
at net.minecraft.client.Minecraft.<init>(Minecraft.java:356) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:89) ~[Main.class:?]
... 6 more

 

Here is the code:

 

FMLLoadingPlugin.class

package SackCastellon.core.asm;

import java.io.File;
import java.util.Map;

import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;;

@MCVersion(value = "1.7.2")
public class FMLLoadingPlugin implements IFMLLoadingPlugin
{
public static File location;

@Override
public String[] getASMTransformerClass()
{
	System.out.println("********* getASMTransformerClass. OK");
	return new String[] {"SackCastellon.core.asm.ClassTransformer"};
}

@Override
public String getModContainerClass()
{
	System.out.println("********* getModContainerClass. OK");
	return CoreDummyContainer.class.getName();
}

@Override
public String getSetupClass()
{
	System.out.println("********* getSetupClass. OK");
	// TODO Auto-generated method stub
	return null;
}

@Override
public void injectData(Map<String, Object> data)
{
	System.out.println("********* injectData. OK");
	location = (File) data.get("coremodLocation");
}

@Override
public String getAccessTransformerClass()
{
	System.out.println("********* getAccessTransformerClass. OK");
	// TODO Auto-generated method stub
	return null;
}
}

 

CoreDummyContainer.class

package SackCastellon.core.asm;

import java.util.Arrays;

import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;

import cpw.mods.fml.common.DummyModContainer;
import cpw.mods.fml.common.LoadController;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.event.FMLConstructionEvent;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;

public class CoreDummyContainer extends DummyModContainer
{
public CoreDummyContainer()
{		
	super(new ModMetadata());

	System.out.println("********* CoreDummyContainer. OK");

	ModMetadata meta = getMetadata();

	meta.modId = "CoreMod";
	meta.name = "Core Mod";
	meta.version = "1";
	meta.credits = "Created by SackCastellon";
	meta.authorList = Arrays.asList("SackCastellon");
	meta.description = "An API that contain some common classes for all my mods";
	meta.url = "http://www.minecraftforum.net/topic/1909056-/#core";
	meta.updateUrl = "";
	meta.screenshots = new String[0];
	meta.logoFile = "";
}

@Override
public boolean registerBus(EventBus bus, LoadController controller)
{
	System.out.println("********* registerBus. OK");
	bus.register(this);
	return true;
}

@Subscribe
public void modConstruction(FMLConstructionEvent event) {}

@Subscribe
public void preInit(FMLPreInitializationEvent event) {}

@Subscribe
public void load(FMLInitializationEvent event) {}

@Subscribe
public void postInit(FMLPostInitializationEvent event) {}
}

 

ClassTransformer.class

package SackCastellon.core.asm;

import java.io.File;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import net.minecraft.launchwrapper.IClassTransformer;

public class ClassTransformer implements IClassTransformer
{
@Override
public byte[] transform(String name, String transformedName, byte[] basicClass)
{
	if (name.equals("aje") || name.equals("net.minecraft.block.BlockEnchantmentTable"))
	{
		System.out.println("********* PATCHING CLASS: " + name);
		basicClass = patchClassInJar(name, basicClass, name, FMLLoadingPlugin.location);
	}
	return basicClass;
}

private byte[] patchClassInJar(String name, byte[] basicClass, String ObfName, File location)
{
	try
	{
		ZipFile zip = new ZipFile(location);
		ZipEntry entry = zip.getEntry(name.replace('.', '/') + ".class");

		if (entry == null)
		{
			System.out.println("********* " + name + " not found in " + location.getName());
		}

		else
		{
			InputStream zin = zip.getInputStream(entry);
			basicClass = new byte[(int) entry.getSize()];
			zin.read(basicClass);
			zin.close();
			System.out.println("********* Class " + name + " patched!");
		}

		zip.close();
	}

	catch (Exception e)
	{
		throw new RuntimeException("********* Error overriding " + name + " from " + location.getName(), e);
	}

	return basicClass;
}
}

 

And finally the VM arguments:

 

arguments.png

Posted

Ouch. You defeat the point of coremods, if you do it that way. You could just as well directly edit base classes if you're just gonna replace entire class anyways.

 

OK.

Another problem i have is that when i run gradlew build (i think) it doesn't re-obfuscate correctly the vanilla modified classes, because i get this class (instead the aje.class):

 

deobf1.png

 

And the class also isn't re-obfuscated correctly (i think)

 

deobf2.png

Posted

Thread locked for being stupid, we DO NOT support editing base classes like that, stop being lazy/stupid/incompatible.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.