Search in sources :

Example 1 with Timer

use of net.minecraft.util.Timer in project malmo by Microsoft.

the class TimeHelper method setMinecraftClientClockSpeed.

public static boolean setMinecraftClientClockSpeed(float ticksPerSecond) {
    boolean devEnv = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
    // We need to know, because the member name will either be obfuscated or not.
    String timerMemberName = devEnv ? "timer" : "field_71428_T";
    // NOTE: obfuscated name may need updating if Forge changes - search for "timer" in Malmo\Minecraft\build\tasklogs\retromapSources.log
    Field timer;
    try {
        timer = Minecraft.class.getDeclaredField(timerMemberName);
        timer.setAccessible(true);
        timer.set(Minecraft.getMinecraft(), new Timer(ticksPerSecond));
        return true;
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
    return false;
}
Also used : Field(java.lang.reflect.Field) Timer(net.minecraft.util.Timer) Minecraft(net.minecraft.client.Minecraft)

Aggregations

Field (java.lang.reflect.Field)1 Minecraft (net.minecraft.client.Minecraft)1 Timer (net.minecraft.util.Timer)1