Jump to content

[1.6.4] How to override main/base classes?


ASHninja1997

Recommended Posts

Hi

 

So I have tried looking up how to override main (or base) classes a couple times a found nothing. Is there ANY sort of method in forge that will allow me to override any main/base classes?

 

I gave a short and to the point answer, if you need more information please ask.

 

Thanks,

~ASHninja1997

Every day is a new day to learn.

I acknowledge the hard work of original content.

I will always improve in many ways.

 

Java > c

Link to comment
Share on other sites

What are you trying to accomplish?  All modding is "overriding" the base classes.

 

Generally, if you want to change behavior of base classes you should first look for public methods and fields.  For example, the AI task lists of entities are public and so you can totally replace the entity AI.

 

Secondly, you can look at events.  Forge specifically intercepts many places where modders may want to change base behavior.  You can cancel many default behaviors and replace with your own code.

 

Thirdly you can use Java reflection.  This can help you access many protected and private fields and methods directly.

 

Fourthly you can use access transformers to truly modify the way the code operates.

 

Fifthly, many things are in registries which are public and you can de-register and re-register your own version of things.

 

Lastly, you can create custom versions (meaning extend in Java) of things and replace the base versions.  Like whenever a creeper spawns you could replace it with your own custom creeper, whenever a block gets placed put your own custom block instead, and so on.

 

So there is very little reason to actually want to change the actual base classes, since you have all the techniques above to use.

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.



×
×
  • Create New...

Important Information

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