Jump to content

1.6.4 CoreMod - Patching Minecraft.class - Error: Unable to launch


Recommended Posts

Posted

Hi,

i'm trying to program a new mod, which changes the way minecraft starts. It should show up a progressbar.

4LP77E2.png

So this mod has to be a coremod to, but i have some problem. I get this error:

Unable to launch
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft
at net.minecraft.client.main.Main.main(SourceFile:37)

 

This happens right after this patch:

@Override
public byte[] transform(String arg0, String arg1, byte[] arg2) {
	if (arg0.equals("atv") | arg0.contains("net.minecraft.client.Minecraft")) {
		System.out.println("********* INSIDE OBFUSCATED MINECRAFTLOADER TRANSFORMER ABOUT TO PATCH: " + arg0);
		arg2 = patchClassInJar(arg0, arg2, arg0, LoaderPatchingLoader.location);
	}
	/*if (arg0.equals("aee") | arg0.contains("net.minecraft.world.chunk.storage.AnvilChunkLoader")) {
		System.out.println("********* INSIDE OBFUSCATED GENERATION TRANSFORMER ABOUT TO PATCH: " + arg0);
		arg2 = patchClassInJar(arg0, arg2, arg1, LoaderPatchingLoader.location);
	}*/
	if (arg0.equals("cpw.mods.fml.common.LoadController")) {
		System.out.println("********* INSIDE OBFUSCATED MINECRAFTLOADER TRANSFORMER ABOUT TO PATCH: " + arg0);
		arg2 = patchClassInJar(arg0, arg2, arg1, LoaderPatchingLoader.location);
	}

	return arg2;
}

public byte[] patchClassInJar(String name, byte[] bytes, String ObfName, File location)
{
	try {
		//open the jar as zip
		ZipFile zip = new ZipFile(location);
		//find the file inside the zip that is called te.class or net.minecraft.entity.monster.EntityCreeper.class
		//replacing the . to / so it would look for net/minecraft/entity/monster/EntityCreeper.class
		ZipEntry entry = zip.getEntry(name.replace('.', '/') + ".class");


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

			//serialize the class file into the bytes array
			InputStream zin = zip.getInputStream(entry);
			bytes = new byte[(int) entry.getSize()];
			zin.read(bytes);
			zin.close();
			System.out.println("[" + "MinecraftLoader" + "]: " + "Class " + name + " patched!");
		}
		zip.close();
	} catch (Exception e) {
		throw new RuntimeException("Error overriding " + name + " from " + location.getName(), e);
	}

	//return the new bytes
	return bytes;
}

Yes, i my file contains the atv.class file.

Download this mod:

https://www.dropbox.com/s/uhtzr9oql436hnh/MinecraftLoader%200.1%20mc1.6.4.jar

 

This is not the first time for me working with this, but i don't know what i'm doing wrong, because it does obviously patch that file.

Posted

I don't think you need to replace the entire Minecraft class to do this.

Learning to use ASM would help you immensely.

 

if (arg0.equals("cpw.mods.fml.common.LoadController")) {
		System.out.println("********* INSIDE OBFUSCATED MINECRAFTLOADER TRANSFORMER ABOUT TO PATCH: " + arg0);

Why patching this ? You didn't realize this is a FML class ?

Posted

I dont know much about core mods but the crash says

Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft

 

so maybe change

if (arg0.equals("atv") | arg0.contains("net.minecraft.client.Minecraft")) {

to just

if (arg0.equals("atv")) {

 

because due to obfustication "net.minecraft.client.Minecraft" wouldn't be called this?

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

I don't think you need to replace the entire Minecraft class to do this.

Learning to use ASM would help you immensely.

 

if (arg0.equals("cpw.mods.fml.common.LoadController")) {
		System.out.println("********* INSIDE OBFUSCATED MINECRAFTLOADER TRANSFORMER ABOUT TO PATCH: " + arg0);

Why patching this ? You didn't realize this is a FML class ?

You are totally right, but i don't know how. I only have to overwrite one method startGame()

private void startGame() throws LWJGLException
    {
        this.gameSettings = new GameSettings(this, this.mcDataDir);

        if (this.gameSettings.overrideHeight > 0 && this.gameSettings.overrideWidth > 0)
        {
            this.displayWidth = this.gameSettings.overrideWidth;
            this.displayHeight = this.gameSettings.overrideHeight;
        }

        if (this.fullscreen)
        {
            Display.setFullscreen(true);
            this.displayWidth = Display.getDisplayMode().getWidth();
            this.displayHeight = Display.getDisplayMode().getHeight();

            if (this.displayWidth <= 0)
            {
                this.displayWidth = 1;
            }

            if (this.displayHeight <= 0)
            {
                this.displayHeight = 1;
            }
        }
        else
        {
            Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight));
        }

        Display.setResizable(true);
        Display.setTitle("Minecraft 1.6.4");
        this.getLogAgent().logInfo("LWJGL Version: " + Sys.getVersion());

        if (Util.getOSType() != EnumOS.MACOS)
        {
            try
            {
                Display.setIcon(new ByteBuffer[] {this.readImage(new File(this.fileAssets, "/icons/icon_16x16.png")), this.readImage(new File(this.fileAssets, "/icons/icon_32x32.png"))});
            }
            catch (IOException ioexception)
            {
                ioexception.printStackTrace();
            }
        }

        try
        {
            ForgeHooksClient.createDisplay();
        }
        catch (LWJGLException lwjglexception)
        {
            lwjglexception.printStackTrace();

            try
            {
                Thread.sleep(1000L);
            }
            catch (InterruptedException interruptedexception)
            {
                ;
            }

            if (this.fullscreen)
            {
                this.updateDisplayMode();
            }

            Display.create();
        }

        OpenGlHelper.initializeTextures();
        this.guiAchievement = new GuiAchievement(this);
        this.metadataSerializer_.registerMetadataSectionType(new TextureMetadataSectionSerializer(), TextureMetadataSection.class);
        this.metadataSerializer_.registerMetadataSectionType(new FontMetadataSectionSerializer(), FontMetadataSection.class);
        this.metadataSerializer_.registerMetadataSectionType(new AnimationMetadataSectionSerializer(), AnimationMetadataSection.class);
        this.metadataSerializer_.registerMetadataSectionType(new PackMetadataSectionSerializer(), PackMetadataSection.class);
        this.metadataSerializer_.registerMetadataSectionType(new LanguageMetadataSectionSerializer(), LanguageMetadataSection.class);
        this.saveLoader = new AnvilSaveConverter(new File(this.mcDataDir, "saves"));
        this.mcResourcePackRepository = new ResourcePackRepository(this.fileResourcepacks, this.mcDefaultResourcePack, this.metadataSerializer_, this.gameSettings);
        this.mcResourceManager = new SimpleReloadableResourceManager(this.metadataSerializer_);
        this.mcLanguageManager = new LanguageManager(this.metadataSerializer_, this.gameSettings.language);
        this.mcResourceManager.registerReloadListener(this.mcLanguageManager);
        this.refreshResources();
        this.renderEngine = new TextureManager(this.mcResourceManager);
        this.mcResourceManager.registerReloadListener(this.renderEngine);
        this.sndManager = new SoundManager(this.mcResourceManager, this.gameSettings, this.fileAssets);
        this.mcResourceManager.registerReloadListener(this.sndManager);
        this.fontRenderer = new FontRenderer(this.gameSettings, new ResourceLocation("textures/font/ascii.png"), this.renderEngine, false);
        if (this.gameSettings.language != null)
        {
            this.fontRenderer.setUnicodeFlag(this.mcLanguageManager.isCurrentLocaleUnicode());
            this.fontRenderer.setBidiFlag(this.mcLanguageManager.isCurrentLanguageBidirectional());
        }
        this.standardGalacticFontRenderer = new FontRenderer(this.gameSettings, new ResourceLocation("textures/font/ascii_sga.png"), this.renderEngine, false);
        this.mcResourceManager.registerReloadListener(this.fontRenderer);
        this.mcResourceManager.registerReloadListener(this.standardGalacticFontRenderer);
        LoaderDummyContainer.loadScreen("Start loading mods...", 0);
        
        FMLClientHandler.instance().beginMinecraftLoading(this, this.defaultResourcePacks, this.mcResourceManager);

        
        LoaderDummyContainer.loadScreen("Start loading recources...", 200);
        this.mcResourceManager.registerReloadListener(new GrassColorReloadListener());
        this.mcResourceManager.registerReloadListener(new FoliageColorReloadListener());
        RenderManager.instance.itemRenderer = new ItemRenderer(this);
        this.entityRenderer = new EntityRenderer(this);
        this.statFileWriter = new StatFileWriter(this.session, this.mcDataDir);
        AchievementList.openInventory.setStatStringFormatter(new StatStringFormatKeyInv(this));
        this.mouseHelper = new MouseHelper();
        this.checkGLError("Pre startup");
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glShadeModel(GL11.GL_SMOOTH);
        GL11.glClearDepth(1.0D);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glCullFace(GL11.GL_BACK);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        this.checkGLError("Startup");
        this.renderGlobal = new RenderGlobal(this);
        this.renderEngine.loadTextureMap(TextureMap.locationBlocksTexture, new TextureMap(0, "textures/blocks"));
        this.renderEngine.loadTextureMap(TextureMap.locationItemsTexture, new TextureMap(1, "textures/items"));
        GL11.glViewport(0, 0, this.displayWidth, this.displayHeight);
        this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine);
        FMLClientHandler.instance().finishMinecraftLoading();
        this.checkGLError("Post startup");
        this.ingameGUI = new GuiIngameForge(this);

        if (this.serverName != null)
        {
            this.displayGuiScreen(new GuiConnecting(new GuiMainMenu(), this, this.serverName, this.serverPort));
        }
        else
        {
            this.displayGuiScreen(new GuiMainMenu());
        }

        this.loadingScreen = new LoadingScreenRenderer(this);

        if (this.gameSettings.fullScreen && !this.fullscreen)
        {
            this.toggleFullscreen();
        }
        FMLClientHandler.instance().onInitializationComplete();
        LoaderDummyContainer.loadScreen("Complete loading mods...", 700);
    }

Can you show me how to do this?

 

@dude22072 I'm sorry but this

 | arg0.contains("net.minecraft.client.Minecraft")

has no influence on that.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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