Skip to content

Commit

Permalink
Fix daviscook477#162 PostEnergyRecharge hook
Browse files Browse the repository at this point in the history
  • Loading branch information
kiooeht committed Dec 7, 2018
1 parent d26fe8a commit 8040422
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,3 +492,4 @@ This is a fast forward to v1.6.3 of daviscook477's fork with a few additional ch
* Fix startup crash if base character is fully (level 6) unlocked (kiooeht)

#### dev ####
* Fix PostEnergyRecharge hook (kiooeht)
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
package basemod.patches.com.megacrit.cardcrawl.core.EnergyManager;

import basemod.BaseMod;
import com.evacipated.cardcrawl.modthespire.lib.SpireInsertPatch;
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;
import com.evacipated.cardcrawl.modthespire.lib.*;
import com.megacrit.cardcrawl.actions.GameActionManager;
import com.megacrit.cardcrawl.audio.SoundMaster;
import com.megacrit.cardcrawl.core.EnergyManager;
import javassist.CtBehavior;

@SpirePatch(cls="com.megacrit.cardcrawl.core.EnergyManager", method="recharge")
public class PostEnergyRechargeHook {
@SpireInsertPatch(rloc=10)
public static void Insert(Object __obj_instance) {
@SpirePatch(
clz=EnergyManager.class,
method="recharge"
)
public class PostEnergyRechargeHook
{
@SpireInsertPatch(
locator=Locator.class
)
public static void Insert(EnergyManager __instance)
{
BaseMod.publishPostEnergyRecharge();
}

private static class Locator extends SpireInsertLocator
{
@Override
public int[] Locate(CtBehavior ctMethodToPatch) throws Exception
{
Matcher finalMatcher = new Matcher.MethodCallMatcher(GameActionManager.class, "updateEnergyGain");
return LineFinder.findInOrder(ctMethodToPatch, finalMatcher);
}
}
}

0 comments on commit 8040422

Please sign in to comment.