Jump to content

[1.7.10] Overwriting existing Enum


Ieuan

Recommended Posts

I'm trying to create a mod that changes an Enum in an already existing mod to allow more skins to be loaded. The idea was that I'd overwrite the existing Enum with the one from my mod, either by loading it before the other mod does and ignoring the one the other mod has, or by overwriting the other mod's class with mine.

 

I tested it in various ways, and I can't seem to get it working well. I got to the point where in my dev environment it works, but then in a normal client it errors out because the class was already injected.

 

Is there any (good) way to do this?

Link to comment
Share on other sites

Too little information.

 

What have you already tried? Are you using a Coremod and a Class Adapter? That's what I'd go with.

If it's just a variable you need to adjust, I'd try using reflection instead. I avoid core mods as far as possible... Makes your coding life slightly easier.

 

Also, do you see any error in the Launcher's output in a regular, non-dev environment?

 

Last but not least, you might want to post some code...

Link to comment
Share on other sites

Well there really isn't a lot else to say. It's a mod that has an Enum used to load NPC textures, I need to overwrite that Enum from another mod.

 

The problem isn't that I can't access the Enum, it's that before the textures are loaded (i.e. before the Enum is called) I need to already change it so that it loads the added textures as well.

 

I'll reproduce my errors and post some logs.

Link to comment
Share on other sites

You want to replace textures? Use a ResourcePack (mods are ResourcePacks, too, but they are always active).

 

No, why would I use an Enum to replace textures? There's basically an Enum with texture names in the mod, that Enum gets loaded and from there it selects the textures (using the Enum to iterate over the available textures). I need to add textures to this list, which is only possible by modifying the Enum. I right now have my own modified version of the mod (copied the deobfuscated class, built my file, copied my built class to the mod jar and copied the assets over as well) but I need it separate.

Link to comment
Share on other sites

You can use Coremods to modify classes, but that is a very bad idea, especially when it comes to classes from other mods.

 

Well what other options do I have? I can't find any info on Class Adapters as mentioned before, not sure if that would work..

 

The thing is that the way this mod is built, the only thing it checks for the textures are that Enum. It's just for one NPC with multiple possible textures, and that Enum has all the current assets for that NPC in it. I simply have to add more to that Enum to get it to 'recognize' the assets I put in the folder.

 

It's either modifying just that Enum that doesn't have any real impact other than that one texture, or modifying the way it loads that texture by checking the Enum for possibilities..

Link to comment
Share on other sites

Oh, so you just want to add new Enum instances. Look at Forge's EnumHelper class.

 

I don't want to reference the Enum though.. I want to change the Enum so that the mod itself can load my textures as well.. As far as I can find EnumHelper doesn't let me do that :(

Link to comment
Share on other sites

Oh, so you just want to add new Enum instances. Look at Forge's EnumHelper class.

 

I don't want to reference the Enum though.. I want to change the Enum so that the mod itself can load my textures as well.. As far as I can find EnumHelper doesn't let me do that :(

EnumHelper should let you do exactly what you've talked about (shove some new enum values into somebody else's enum), so look again. If there's still a problem, then start posting code. Maybe you need to learn reflection from looking at how EnumHelper works. Then you can hack the enum the way you want.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

He doesn't want to add new enums to an existing one, but modify the ones that already exist.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Oh, so you just want to add new Enum instances. Look at Forge's EnumHelper class.

 

I don't want to reference the Enum though.. I want to change the Enum so that the mod itself can load my textures as well.. As far as I can find EnumHelper doesn't let me do that :(

EnumHelper should let you do exactly what you've talked about (shove some new enum values into somebody else's enum), so look again. If there's still a problem, then start posting code. Maybe you need to learn reflection from looking at how EnumHelper works. Then you can hack the enum the way you want.

 

Alright. I'll look into EnumHelper. I can't post code because the only code that's relevant is not mine, which is also why I need to go the long way around instead of simply modifying that code.

 

I'll post my results when I have some.

 

Link to comment
Share on other sites

He doesn't want to add new enums to an existing one, but modify the ones that already exist.

He said "I want to change the Enum so that the mod itself can load my textures as well."

That looks like adding new enum values.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

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.