Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Getting started with changing vanilla minecraft code


lblackburn
 Share

Recommended Posts

Hi,

 

I am new here and would like some basic modding information.

 

I have managed to setup minecraft forge for 1.7.10 on my machine using Eclipse 4.4.2 and forge 10.13.2.1291.

 

I am able to start reading and debugging the vanilla minecraft code (yeah!)

 

I have already made a change to one of the vanilla minecraft classes and would like to recompile and test my change.

 

I have tried Build All from the project menu but when I start debugging, the code reads the same as before my change.

 

Could you please provide the proper steps to change and debug vanilla minecraft classes please?

 

Thank you in advance!

Link to comment
Share on other sites

Ok, thank you for that information I was confused when the vanilla minecraft classes were not included in the project.

 

I would still like to override some vanilla entity behavior...

 

Or is this the wrong tool for that?

 

Do I create a subclass of the vanilla class I want to modify and override the original functionality there, and then somehow replace the original entity with my inheritied entity?

Link to comment
Share on other sites

There are plenty of events and hooks for entities. You can use them to modify an entity's behaviour.

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

And if that isn't somehow enough, you can use ASM and make a core mod.

Warning: I am not responsible for any effects, temporary or permanent, acquired from having The Abyss looking back at you.

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

There are plenty of events and hooks for entities. You can use them to modify an entity's behaviour.

 

That sounds excellent!

 

I don't suppose there are any links out there that demonstrate using minecraft forge hooks to modify vanilla minecraft entities...

 

From my point of view I am not looking for anything very specific to start with.

 

I think it could help me if I could see a sample or something of someone modifying any aspect of a vanilla entity.

 

Basically I know that I know nothing about this tool and I am looking for a place to start learning.

Link to comment
Share on other sites

When trying to modify vanilla behavior, you should consider the following approaches (in this order).

 

1) Look for public methods, fields and registries. The vanilla code has a lot of public scope stuff -- like entity AI is in a list that is public so you can simply modify it directly.

2) Events. There are events for many of the things that modders are interested in, and the events allow you to change and even cancel the vanilla behavior.

3) Java reflection. Java is a funny language and reflection allows you to access a lot of vanilla stuff that is technically out of scope.

4) ASM and transformer techniques.

 

 

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

Link to comment
Share on other sites

When trying to modify vanilla behavior, you should consider the following approaches (in this order).

 

1) Look for public methods, fields and registries. The vanilla code has a lot of public scope stuff -- like entity AI is in a list that is public so you can simply modify it directly.

2) Events. There are events for many of the things that modders are interested in, and the events allow you to change and even cancel the vanilla behavior.

3) Java reflection. Java is a funny language and reflection allows you to access a lot of vanilla stuff that is technically out of scope.

4) ASM and transformer techniques.

 

I have created a class that inherits from the vanilla entity and overrides a protected method to implement some sample overriden behavior.

 

Now my question is how do I tell the game engine to use my inherited entity instead of the original entity (without modifying the vanilla files of course!)?

 

I am assuming that this kind of change is supported I guess.

Link to comment
Share on other sites

No.

 

You either make new entity and register it as separate entity, or you use events to hook into vanilla ones.

 

There is like milions of tutorials on "How to use Events in Forge".

 

Say exacly what you want to archieve, then we can be more direct, otherwise - read ab out events (tutorial, code, anything).

To for example hook into update() method of entity (one that is called every tick) you can use LivingUpdateEvent.

 

Notes: Remember to register entity, understand that client events should be put into client proxies, know that there are few different buses that will call event. Everything can be found VERY easily on google.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

No.

 

You either make new entity and register it as separate entity, or you use events to hook into vanilla ones.

 

There is like milions of tutorials on "How to use Events in Forge".

 

Say exacly what you want to archieve, then we can be more direct, otherwise - read ab out events (tutorial, code, anything).

To for example hook into update() method of entity (one that is called every tick) you can use LivingUpdateEvent.

 

Notes: Remember to register entity, understand that client events should be put into client proxies, know that there are few different buses that will call event. Everything can be found VERY easily on google.

 

After reading lots of code and googling minecraft forge events I managed to subscribe to an event in a generic custom event handler class that I wrote.

 

I built and ran my code and got eclipse to stop at my breakpoint. I think that it even does what I want it to do.

 

(I did figure out that onLivingUpdate was probably to high up the stack for my purpose and found a hook much closer to the behavior that I wanted to override.)

 

Many thanks!

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.