Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.9.4][Solved] Java inheritance across multiple mods not working correctly

Featured Replies

Posted

I'm probably missing something that more experienced modders already know full well, but Google hasn't helped me on this. Hopefully someone here can point me in the right direction.

 

Problem Description:

 

-  Child Class B in Mod Bb extends Parent Class A in mod Aa.

- obfuscated jar file of Mod Aa is in Bb's ./libs directory.

- Method A1() is implemented in Class A.

- Class C in Mod Bb calls B.A1().

- Eclipse thinks everything is hunky-dory, builds okay.

- ./gradlew build of Mod Bb fails with "Cannot find symbol" error for method A1().

 

Troubleshooting:

 

- move parent Class A into Mod Bb.

- Child class B, class C, etc as before.

- Eclipse build still happy.

- ./gradlew build of Mod Bb works fine.

 

Just to be confusing:

 

- class Z in Mod Aa.

- Mod Bb instantiates Z (NOT extends). (e.g. "Z z1 = new Z();")

- everything builds just fine.

 

What am I doing wrong?  How do I fix it so parental class for lib/core/api-type mod can be properly inherited and its methods invoked by a child class in another mod.

  • Author

Is late for me, so I may be less than coherent, but I'll leave these links up for you to ponder when you get the chance:

 

I am working on the 1.9.4 port of "Fusion" for Alexndr's Simple Ores 2 collection of mods. Source here.

 

Originally, I had blocks/SimpleFurnace.java and tiles/TileEntitySimpleFurnace.java in the SimpleCore API mod, which serves as a common library for all the Simple Ores2 mods, because I thought I might want a common base class for later use with the improved furnaces in the Simple Ores2 Machines mod.

 

blocks/BlockFusionFurnace extends SimpleFurnace, and tiles/TileEntityFusionFurnace extends TileEntitySimpleFurnace. The problem I had was that where inventory/ContainerFusionFurnace's (the container class for the Fusion Furnace) detectAndSendChanges() and updateProgressBar() methods called TileEntityFusionFurnace methods getField() and setField(), that are actually inherited from TileEntitySimpleFurnace, they weren't found by the gradle compile. That is, "cannot find symbol" error.  They weren't the only such errors; I believe stuff in SimpleFurnace wasn't found, either.

 

When built within Eclipse, there were no compile errors.

When I moved both parent classes into the Fusion mod, gradle build compiled okay.  That is the current state you see at the source tree linked above.

 

  • Author

Yes, those sound like obfuscation errors... Are you sure you have an unobfuscated version of the library?

 

I am sure that I do NOT.  I take it I am supposed to use the unobfuscated version to build against?  See, this is an example of "missing something that more experienced modders already know full well", but I've never actually been clear as to what unobfuscated jars were for, beside "to run client inside Eclipse".

 

So why is it building okay when I instantiate a class from an obfuscated library?

 

  • Author

Yes, that's it. Also, someone needs to fix the Forge Gradle Cookbook: the Gradle snippet for creating a deobfuscated file is wrong. I had to go browsing various mod sources on GitHub to find the correct snippet. What's in the Cookbook creates a jar file filled with source code, which doesn't work very well as an external lib.

 

This snippet (from my build.gradle) works:

 

task deobfJar(type: Jar) {
    from sourceSets.main.output
    classifier "deobf"
}

artifacts {
    archives deobfJar
}

 

Note the difference in the 'from' line.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.