Search in sources :

Example 1 with PlayerProgress

use of hellfirepvp.astralsorcery.common.data.research.PlayerProgress in project RandomTweaker by Project-RT.

the class IPlayerExpansionAS method modifyPerkExp.

@ZenMethod
public static boolean modifyPerkExp(IPlayer player, double exp) {
    EntityPlayer mcPlayer = CraftTweakerMC.getPlayer(player);
    PlayerProgress prog = ResearchManager.getProgress(mcPlayer);
    if (IPlayerExpansionAS.getAttunedConstellation(player) == null) {
        CraftTweakerAPI.logInfo("This Player is not constellations");
        return false;
    }
    try {
        Class<? extends PlayerProgress> progClass = prog.getClass();
        Method setExp = progClass.getMethod("modifyExp", double.class, EntityPlayer.class);
        setExp.setAccessible(true);
        setExp.invoke(prog, exp, mcPlayer);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
        CraftTweakerAPI.logError("Maybe you need to report this error", e);
    }
    return true;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ZenMethod(stanhebben.zenscript.annotations.ZenMethod) Method(java.lang.reflect.Method) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) InvocationTargetException(java.lang.reflect.InvocationTargetException) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 2 with PlayerProgress

use of hellfirepvp.astralsorcery.common.data.research.PlayerProgress in project RandomTweaker by Project-RT.

the class IPlayerExpansionAS method setPerkExp.

@ZenMethod
public static boolean setPerkExp(IPlayer player, double exp) {
    PlayerProgress prog = ResearchManager.getProgress(CraftTweakerMC.getPlayer(player));
    if (IPlayerExpansionAS.getAttunedConstellation(player) == null) {
        CraftTweakerAPI.logInfo("This Player is not constellations");
        return false;
    }
    try {
        Class<? extends PlayerProgress> progClass = prog.getClass();
        Method setExp = progClass.getDeclaredMethod("setExp", double.class);
        setExp.setAccessible(true);
        setExp.invoke(prog, exp);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
        CraftTweakerAPI.logError("Maybe you need to report this error", e);
    }
    return true;
}
Also used : ZenMethod(stanhebben.zenscript.annotations.ZenMethod) Method(java.lang.reflect.Method) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) InvocationTargetException(java.lang.reflect.InvocationTargetException) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Aggregations

PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1