Jump to content

[1.10] Is it possible to detect a custom method and edit it?


JackTheRedCreeper

Recommended Posts

Kind of like when you edit a Minecraft vanilla method (such as explosions), but from another mod. Add some code or edit what's there.

 

I'm more interested in if it's possible, as a friend is having problems with his mod (I made custom explosions in mine and his mod is not detecting them) and we're lost on what to do.

 

If it's just necessary to have some code on the custom explosion side, that'd be good enough. However if it all can be done without extra explosion code, it would have more mod compatibility.

 

The idea is: My projectile causes a explosion (CustomExp), my friend's mod detects CustomExp and modifies it.

At the moment his mod only works with vanilla explosions because they're "pre-ofbuscated", to say so (you know where they are and what their name is already)

 

 

Link to comment
Share on other sites

How does he modify it?

Larger|smaller radius? Power?

Stops it?

 

Most likely, unless your friend is doing something major, he can simply subscribe to the

ExplosionEvent

and handle things from there. As long as any mod-dev makes his/her explosions fire this event as well (which they seriously should) then that is all that is needed.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Tell your friend to make an api and then link into that api

 

We could do that, but it's not that important and we want the most compatible method possible.

 

How does he modify it?

Larger|smaller radius? Power?

Stops it?

 

Most likely, unless your friend is doing something major, he can simply subscribe to the

ExplosionEvent

and handle things from there. As long as any mod-dev makes his/her explosions fire this event as well (which they seriously should) then that is all that is needed.

 

He's moving the explosion to other coords. Don't think it's too major.

 

I belive he can use this method because my custom explosion is just a few value changes (on radius and power) :D

 

Now to wait for him to get online... xD

Link to comment
Share on other sites

Kind of like when you edit a Minecraft vanilla method...

That would be a core mod. This forum does not support core mods. You shouldn't edit vanilla methods. If you ever seriously needed a vanilla method to change, then you would submit a "pull request" to the Forge developers.

 

Likewise, you shouldn't edit the methods inside other mods (if that's even possible). Instead, comunicate with the mod's owner about supporting what you want to do.

 

Learn how to integrate your mod with Forge so that your mod can "play nice" with other mods. If you talk about core-modding or hacking others' mods, then maybe the forum moderators will explain things better than I have.

 

However, if all you want to do is to detect the existence of a method in a class, then use reflection. The post-init event handler is a good place to accomplish such inter-mod coordination. Once your code knows that a class and method exist, then you can (still using reflection) call the method to act on the class or objects thereof. Be careful with reflection; it's inefficient.

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

Kind of like when you edit a Minecraft vanilla method...

That would be a core mod. This forum does not support core mods. You shouldn't edit vanilla methods. If you ever seriously needed a vanilla method to change, then you would submit a "pull request" to the Forge developers.

 

Likewise, you shouldn't edit the methods inside other mods (if that's even possible). Instead, comunicate with the mod's owner about supporting what you want to do.

 

Learn how to integrate your mod with Forge so that your mod can "play nice" with other mods. If you talk about core-modding or hacking others' mods, then maybe the forum moderators will explain things better than I have.

 

However, if all you want to do is to detect the existence of a method in a class, then use reflection. The post-init event handler is a good place to accomplish such inter-mod coordination. Once your code knows that a class and method exist, then you can (still using reflection) call the method to act on the class or objects thereof. Be careful with reflection; it's inefficient.

 

I mean something like an EventHandler (those are the ones used to replace Tnt properties for example, no?). His mod works perfectly but it doesn't detect custom explosions, which makes it finnicky.

We thought about "waht if I make CustomExplosion and you detect that?" but the problem is minecraft's ofbuscation.

I guess reflection is what we need because what my friend does is check for explosion, and if that explosion is in the world class. However, after doing those checks, he needs to change the explosion's location.

We'll try the ExplosionEvent first.

Link to comment
Share on other sites

You would need to tell the person who wrote the custom explosions to add the explosion event.

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.

Link to comment
Share on other sites

Realistically any mod that does things like vanilla, but not and vanilla has an event, that mod should also fire that event in their custom whatever.

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.

Link to comment
Share on other sites

Realistically any mod that does things like vanilla, but not and vanilla has an event, that mod should also fire that event in their custom whatever.

 

Yeah, explosion event. My friend hasn't gotten online yet.

When he does and we test all of this, we'll tell you!

 

Amusingly my custom explosions work in dev environment because it's not ofbuscated, but hopefully ExplosionEvent isn't affected.

Link to comment
Share on other sites

Amusingly my custom explosions work in dev environment because it's not ofbuscated, but hopefully ExplosionEvent isn't affected.

What? If your friend is dealing with obfuscated jars, he is doing it all wrong.

When you build the jar, your code is obfuscated to be able to work properly with "real" (aka non-dev environment) Minecraft.

When building (since 1.8and later, I believe), you should by default get 2 jars inside the build/libs folder, [name].jar, and [name]-sources.jar. The "sources" indicates a non-obfuscated version of your mod, which other devs can use for cross-mod/addon interaction, etcetera.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Amusingly my custom explosions work in dev environment because it's not ofbuscated, but hopefully ExplosionEvent isn't affected.

What? If your friend is dealing with obfuscated jars, he is doing it all wrong.

When you build the jar, your code is obfuscated to be able to work properly with "real" (aka non-dev environment) Minecraft.

When building (since 1.8and later, I believe), you should by default get 2 jars inside the build/libs folder, [name].jar, and [name]-sources.jar. The "sources" indicates a non-obfuscated version of your mod, which other devs can use for cross-mod/addon interaction, etcetera.

Oh! That'd be more in my side. The problem he has is detecting a custom mod class, because of obfuscation.

Huh, but thing is, even if someone used "CustomExplosion", supposedly the class and such is all obfuscated, which makes it impossible to find.

I guess there's some method my friend doesn't know, hence this thread.

 

 

Edit (11-11): Still no response from my friend :/

 

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.