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;
}