How to change the source code within a mod? [Magic Right Cast Mod]

Discuss modding questions and implementation details.
Post Reply
WuSix
Posts: 1
Joined: Wed Aug 10, 2022 7:51 pm

How to change the source code within a mod? [Magic Right Cast Mod]

Post by WuSix »

Someday I thought that the spellcasting system wasn't perfect: when you press the activate center object (left mouse click), you use a spell; when you press the swing weapon button (right click), you get nothing; and if you also use vanilla swing mode, your screen will be stuck.

So I thought, why don't you make a spell cast using the swing weapon button and force the remaining free activate center object button to activate its usual action, which is used by default when the sword is taken out? That is, it will also be possible to talk to villagers with spells in your hands.

I started to create the mod called "Magic Right Cast", and almost immediately faced big problems, which consisted of the fact that I needed to somehow change some private fields and functions in the source code using a script. So there's part of the code that is responsible for casting spells in the EntityEffectsManager Update function:

Code: Select all

246|         // Cast spell
247|         if (InputManager.Instance.ActionStarted(InputManager.Actions.ActivateCenterObject) && readySpell != null)
248|         {
249|             CastReadySpell();
250|             return;
251|         }
I need to change ActivateCenterObject to SwingWeapon there, but I can't do it using the DFU API. Therefore, I need to find a walkaround or somehow change the code above after all.

There is also logic for talking to villagers in the PlayerActivate class that needs to be changed the same way.

I have read some advice from the forum about using a dll, but I don't know how to change source code that way at all. Maybe you could know some ways to solve the problem and tell me. I will be grateful.

Post Reply