Jump to content

Recommended Posts

Posted

I'm updating my mod to 1.7.2. After instaling everything and copying my code I got ~300 errors. I've been fixing them (now I have less than 100) but I have some problems:

 

-Since blocks/item ids are gone, I now compare Items using "==". Will this work or not? It seems to be the way that vanilla Minecraft does (e.g. in the ItemStack class) but as far as I know, using "==" on anything than basic types in java won't work. (I could test by myself, but I still have ~100 compilation errors and I don't want to "fix" everything and then have to refix it again)

 

-Again since blocks/item ids are gone. Is there a way to "convert" blocks to items? I need this to check if an ItemStack contains certain Block (getItem() returns and Item which I can't "compare" to Blocks.dirt or MyMod.myBlock) and to register the item renderer o a custom model block I have.

 

-How does lang files now work? LanguageRegistry's loadLocalization method is deprecated and it says that I have to use the assets system. Does that means that I can simply put .lang files in src/main/resources/assets/mymodid/lang/ and forge will detect it automatically?

 

-How does icons/textures now work? I have an error on every Icon, IconRegister or anything similar. Is this related to the assets system?

 

-How does the coremods system now work? With all this gradle stuff and minecraft vanilla classes "hidden" (best way I've found to read their code is to declare a dummy variable of that class type and then use Eclipse's open declaration button to open them) I have no clue about how to update my coremod. (Was hard enough in 1.6.4 having to run it differently depending if you were on Eclipse or on real Minecraft and more strange things so imagine now...)

 

I anyone manages to solve all these problems I'll make to him an altar and pray him every day.  ;D

Posted

- I've been using .equals() and that seems to work out without problems. == should usually work, too, since that's identity equality and there should only be one instance per item type (anyone correct me if I'm wrong on this).

 

- Have a look at the static methods in Item and Block, e.g. Item.getItemFromBlock.

 

- Yes, just put your .lang files in your assets/modid/lang folder and you're good.

 

- Icon has been renamed to IIcon, IconRegister to IIconRegister, otherwise it's the same. Same with (I)Resource and (I)ResourceManager btw.

 

- setupDeobfWorkspace should give you a good start, you'll at least get the sources again like that. Other than that transformers haven't changed much, I think, except for one method name change in the plugin interface. My transformer worked pretty much without changes, IIRC.

Posted

Think the Item ItemBlock and Block just use the Object version of equals which uses identity. Although I guess a mod might try to override it for their own types.

 

Eclipse shows the referenced jars at the bottom of the package manager. You can see the classes and if available their sources there. Everything else, goto declaration, find references, etc works largely the same as for your own code in the project.

Posted

Thanks, I've already solved everything but the coremod part. I used that setupDeobfWorkspace to install forge, but vanilla minecraft sources were hidden. I had to search them because you can't modify the ones that eclipse gives you acess. While modifying them (to recompile and later replace them in runtime as I was doing following the (only?) tutorial about coremods in 1.6.4) eclipse ctrl+shift+o didn't worked and errors where not marked. I organized the imports manually and tryed to test it to see if it worked, but seems that Forge ignored the changes I've made. Since in 1.6.4 coremods didn't work properly in eclipse (I usually got strange errors such as AbstractMethodError) I've tryed to compile my mod and test it in real Minecraft, but I can't find the modified base classes compiled anywhere.

I hope that anyone can help me with this.

Posted

Coremods use reflection and/or ASM, not edits to base classes.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Thanks, I've already solved everything but the coremod part. I used that setupDeobfWorkspace to install forge, but vanilla minecraft sources were hidden. I had to search them because you can't modify the ones that eclipse gives you acess. While modifying them (to recompile and later replace them in runtime as I was doing following the (only?) tutorial about coremods in 1.6.4) eclipse ctrl+shift+o didn't worked and errors where not marked. I organized the imports manually and tryed to test it to see if it worked, but seems that Forge ignored the changes I've made. Since in 1.6.4 coremods didn't work properly in eclipse (I usually got strange errors such as AbstractMethodError) I've tryed to compile my mod and test it in real Minecraft, but I can't find the modified base classes compiled anywhere.

I hope that anyone can help me with this.

You don't need to change the sources for the coremod to work, even in dev.  That's the point of a coremod, actually.

Access transformer changes should be added automatically by ForgeGradle, if your *_at.cfg file is in the resources folder. You'll need to rerun setupDecompWorkspace for changes to be visible.

Using ASM, you can either use a dummy jar to launch your loading plugin, or add the plugin class in the run arguments.

Posted

I was using this tutorial: http://www.minecraftforum.net/topic/1854988-tutorial-162-changing-vanilla-without-editing-base-classes-coremods-and-events-very-advanced/

I had to modify and recompile the base classes to get a .class file to be loaded by the ClassTransformer and replace the original one in runtime so the mod will run perfectly in an unmodified, no base class edited, minecraft.jar.

With the old forge you simply had to run recompile.bat/reobfuscate.bat to get my mod classes and the modified base classes, but now with this confusing gradle stuff I only get my mod classes. What's more, the minecraft sources seems to not be part of the project at all, as the organice imports funcion doesn't work and errors aren't marked.

Posted

I did in this way in 1.6.4 and worked perfectly, why I can't now? I want to modify two classes. One is simply adding a method call and I tried doing it with ASM in 1.6.4 and I got strange errors (like the AbstractMetodError I mentioned earlier, and obviously I wasn't adding anything about abstract classes) and the other class I want to modify adds several instructions intercalated between the original ones so I decided to replace the entrie classes which is easier and doesn't give strange errors.

But anyway, how can I made it without replacing the classes?

Posted
With the old forge you simply had to run recompile.bat/reobfuscate.bat to get my mod classes and the modified base classes, but now with this confusing gradle stuff I only get my mod classes.

Thats exactly what we intend to prevent you from doing because its FUCKING HORRIBLE.

Basically you were creating a jar mod, without having to have the use edit the jar.

THIS IS WRONG.

What id two coremods wanted to edit the same class file?

With the method you're doing we're back to the old 'last one applied wins' method which is crap.

What you SHOULD do is keep your edits small and introduce them specifically using the ASM library.

It's not hard to create fields, methods, whatever in ASM.

We have a fairly straight forward small example in our ASMEventHandler.

It creates an entire class that implements an interface, holds a field, access it, etc..

 

So ya, cleanup your edits, make it less shotgun, more scalpel.

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

Posted

Two mods modifying the same thing will be incompatible not matter if they replace classes, use ASM or anything entirely different (e. g. what if a mod changes "var = x" to "var = 2*x" and other mod to "var = x/2"?) but since they modify the same thing, it's an acceptable incompatibility (who will instal a mod that duplicates creeper damage and other mod that halves it?)


I'm trying to use the eclipse bytecode plugin (which got uninstalled when I swiched to 1.7.2, although I didn't modify my Eclipse instalation folder) to see what I have to modify, but when I open the sources in recompSrc no bytecode is shown. Then what can I do?


This is only for curiosity, but from where forge loads minecraft base files to test your mod in eclipse? The only minecraft files I've found are the recompSrc/Cls folders but the changes I made to the recompSrc files were ignored, and even when deleting entrie files in the recompSrc/Cls folders eclipse was able to load everything perfectly. Also the deleted files where not re-created so it's obious that forge simply ignores them and aren't part of the minecraft code that get's executed.

Posted

forge\build\tmp\recompSrc -> The folder where minecraft sources are (or the only one where I've found them). I want to use the eclipse bytecode plugin to see what ASM stuff I have to change, but the plugin doesn't work whith any .java source file in that folder.

Posted

The were well hiden... (file searching didn't found them). Then what are the recompSrc files for???

I've found the files and the bytecode plugin works for them, but I can't modify them (and later revert the changes, obviusly) to compare the ASM changes to implement them.

Posted

I know you can add anythig with bytecode, but in order to add it, I must know what I have to add. That's why I need the bytecode plugin (or other alternative)

If you don't want to learn bytecode, just write the changes in an external class and read it with the plugin.

Posted

I know you can add anythig with bytecode, but in order to add it, I must know what I have to add. That's why I need the bytecode plugin (or other alternative)

If you don't want to learn bytecode, just write the changes in an external class and read it with the plugin.

 

Thanks, finally someone that helps. I already know bytecode, what I didn't know was what instructions I had to add using it. I tought that using an external class I will get diferent instructions since they would be in different packages.

Posted

If you want to write a coremod, learn ASM. There are many ways you can do it but the basic and best way is to just get comfortable with ASM.

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

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.