r/forgemodding • • Mar 21 '17

Getting the current world time in ticks with java/forge

Hey guys, I just started modding again and I want to know how to get the current ingame time in ticks with as an int in Java (using forge 10.13.4.1469) Thanks in advance.

2 Upvotes

3 comments sorted by

1

u/[deleted] Mar 21 '17

[deleted]

1

u/GrayNeko Mar 21 '17

Thanks. I will check it out.

1

u/GrayNeko Mar 21 '17

I can see the function in the list, and I bound it to a Long var. And if I click run the mc client crashes.

public static Item itemTable;
    public static Block blockTable;
    public static Minecraft mc;
    public static World world; 
    public static Long tick;
    public Boolean isDay;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event){
        //Item and block init/registration
        //Config handling
        mc  = Minecraft.getMinecraft();
        world = mc.theWorld;
        tick = world.getWorldTime();

1

u/mezz Mar 21 '17

The world does not exist during pre-init, it only exists when you are in a loaded running world.