Jump to content

Has Forge figured out a way to replace a method (not override)?


MrChoke

Recommended Posts

I have learned how with Forge you can make private and/or final variables public and not final without reflection.  And how to add to enums at runtime even though they are supposed to always be read-only.  Very cool stuff.

 

So how about method replacement?  I know we can override things but if I want to modify vanilla behavior of existing mobs for example, I can't override that and there aren't really any hooks in place for most of what I am thinking.  My only option right now is to make new mobs and maybe disable the vanilla ones when they are replaced.  Or can we somehow override a vanilla method?

 

Edited by MrChoke
Link to comment
Share on other sites

2 minutes ago, MrChoke said:

Or can we somehow override a vanilla method?

This is possible, but is not supported here and there are no tutorials. And ultimately the absolute last resort. You should just replace the entities with custom ones when they are spawned.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

It is possible but it’s absolutely painful and requires dealing with the raw bytecode of the method. It’s painful, a single wrong thing will instantly crash everything, you need to pretty much learn 2 new languages (ASM & Java Bytecode) and you will have no support from anywhere (online tutorials are also a bit non existent).

3 hours ago, Animefan8888 said:

ultimately the absolute last resort

It shouldn’t even be a last resort. If your using it, your doing something wrong.

You should try submitting a PR to forge if you want hooks. It’s a slow process, but you will get a lot of feedback.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Wait, what are you trying to do exactly? You already can customize vanilla mobs completely. You can change all their AI, change all their attributes, change their models and textures, and fully intercept their update methods.

 

If you want to change anything vanilla you should look for ways in this order:

1) Look for natively public methods and fields. There are really quite a lot of these. For example, all entity AI is kept in public task List fields that you can directly manipulate completely.

2) Events. There are already events for most things you would want to mod.

3) Substitutions. You can do things like handle the event when an entity joins the world and replace with your own version. You can do similar thing with blocks during chunk populate event. Some of the modern registries can be manipulated to do substitutions as well.

4) Reflection. You can literally replace comprehensive things by accessing the various singleton fields in classes like the Minecraft class. For example you can replace the mouse helper class, or replace the item renderer or the global renderer or the texture manager or the model manager or whatever. Those are "intrusive" and can cause incompatibility with other mobs, but they are possible.

 

Anyway, mobs are particularly well covered by Forge. What are you trying to do that you think you can't?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.