Jump to content

Recommended Posts

Posted

I made a mod, without forge, that involves editing an existing file (BehaviorDefaultDispenseItem). It works fine by itself, but I want to be able to use the mod with forge mods. Since forge doesn't allow editing of existing classes, how exactly would I do this?

 

The only way I can think of doing this is making a new class that is a subclass of behaviordefaultdispenseitem but includes the changes I've made, and a new block that's a subclass of dispenser but uses the new class instead and has the same block id as dispensers (so dispensers in existing maps would have my modifications). However I'm not sure if this would work or if there's a better way of doing something like this (or is what I want to do even possible?).

 

 

Posted

that would work technicly but forge provides a library called ASM (they didnt make it btw, they're just distributing it with forge)

 

and this library allows you to change the code at runtime (after you launch the game but before its loaded)

 

theres a post about this like 15 minute ago

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

Ok thanks

How exactly do I do this? (all I need to do is add a line of code to a method in a class)

 

The only tutorial I can find on access transformers is outdated (it says "As of 1.4.4, a few methods have been changed/removed, I will fix this soon" )

Posted

www.minecraftforum.net/topic/1854988-tutorial-162-changing-vanilla-without-editing-base-classes-coremods-and-events-very-advanced/

If you guys dont get it.. then well ya.. try harder...

Posted

Thanks! I managed to get my mod working using ASM but it works only in the IDE.

 

When I try to use my mod in the actual client, it finds the mod and recognizes it (it is in the mod list) but the mod doesn't work when I test it... is my jar set up incorrectly or something? did I forget to include a file?

 

right now my jar is located in the "mods" folder in .minecraft

 

and contains two folders, META-INF and mod (my package, which contains my 3 class files). all 3 class files are there, and the meta-inf has the manifest.mf file.

 

Posted

yeah thats the other shitty part about ASMing with minecraft,

 

when recompiling minecraft you will re'obfuscate your code, meaning names like Minecraft.java will become atd.jva (thats notch way of protecting his code) so your coremod (ASM module/code that will change the code ) has to also take this in consideration

the conf folder contains a file called joined.srg, open this file with a text editor (notepad, notepad++, less, more, vi, EDIT etc) and you will see the de-obfuscated name (the one you're used to work with) and the obfuscated name (something like  "ats" "jd", a lot of combination of 2-3 letters, yes its shitty to read)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

then the problem is NOT mcmod.info, it doesnt make the mod not-functionning

i would say double check that you have effectively replaced obfuscated code correctly because other then that i dont see where it can be

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

The obfuscated name can't be the problem

From the log: 2013-07-25 10:11:20 [iNFO] [sTDOUT] ** INSIDE OBFUSCATED DISPENSE BEHAVIOR TRANSFORMER ABOUT TO PATCH: bg

 

In my class transformer, I have this:

 

if (arg0.equals("bg")) {
		System.out.println("** INSIDE OBFUSCATED DISPENSE BEHAVIOR TRANSFORMER ABOUT TO PATCH: " + arg0);

 

so it's getting the obfuscated name

Posted

then praise to alah

 

no seriously, its not because you're patching this class that you're not making errors anywhere else

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

but why would the deobfuscated work but not the obfuscated one?

 

obfuscated:

if (arg0.equals("bg")) {
		System.out.println("** INSIDE OBFUSCATED DISPENSE BEHAVIOR TRANSFORMER ABOUT TO PATCH: " + arg0);
		return patchClassASM(arg0, arg2, true); 
	}

 

deobfuscated (this works):

if (arg0.equals("net.minecraft.dispenser.BehaviorDefaultDispenseItem")) {
		System.out.println("***** INSIDE DISPENSE BEHAVIOR TRANSFORMER ABOUT TO PATCH:" + arg0);
		return patchClassASM(arg0, arg2, false); 
	}

 

 

in patchClassASM I have this:

		if (obfuscated == true)
		targetMethodName = "a"; 
	else 
		targetMethodName = "dispense"; 

maybe "a" is incorrect?

in methods.csv, the method dispense says the "searge" is "func_82482_a"

Posted

if you're calling method inside the method you're changing and youdidnt change those method also it could cause bugs

 

also, saying that if deob work mean that obf work is same as saying that

 

this code:

if (obfuscated == true)

targetMethodName = "penis";

else

targetMethodName = "dispense";

 

is right because the deobf version is right. its obviously false, the deobf version and obf version are COMPLETELLY different, so if one works that doesnt mean the other will

 

maybe "a" is incorrect?

in methods.csv, the method dispense says the "searge" is "func_82482_a"

 

String m1 = "a";

String m2 = "func_82482_a";

m1.equals(m2) ??? since when ?

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

I tried replacing it with "func_82482_a" and it didn't work either...

 

I know it is reaching the if statement (I put a println right before I set the method name to func_82482_a to make sure it's getting at least that far).

Is it not the obfuscated name then?

Posted

usually the obfuscated names have MAX 3 letter (2 to 3 letters)

 

so no func_etc is not the method name, but you can find it in the joined.srg file in conf

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

the only other possibility I could find was "bg/a", so I tried that (which didn't work obviously because a method can't have "/") and "bga", which didn't work either.

 

 

Posted

bg would be the class and "a" the method i think then again that doesnt mean that somewhere else in the code you didnt screw something up

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

if the code you are replacing is calling something that can be obfuscated/deobfus  and that part isnt change it will also fuck.

 

 

example (pseudo code, not real)

 

blah

blah

blah

 

InsnList n = new wtv

n.insert(new method call instruction to call method "Minecraft.getMinecraft()")

 

Minecraft.getMinecraft() is also obfuscated, so basicly inserting thsi in obfuscated code will refer to a function that doesnt exists, in a obf envir

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

do packages change when they are obfuscated?

part of my instructions list I have

"net/minecraft/item/ItemStack"

I know that ItemStack changes to yd, but does the net/minecraft/item change as well?

Posted

package dissapear when you obfuscate

 

net.minecraft.client.Minecraft become just "at" (or wtv, 2-3 letter name)

 

if you open minecraft.jar you will see that there is no folder but like 1000 file just laying at the root of the jar, that cuz theres no pkg

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.