ModAPI - Sedridor/B3M GitHub Wiki

Import sedridor.B3M.api.B3MAPI.

Methods

B3MAPI.setTimeMultiplier(int multiplicator)

Sets the time multiplier. Must be between -20 and 72.

  • Values below -1 increase the speed of time, i.e. -5 speeds up days to be 5 times faster
  • Values above 1 slow down the speed of time by multiples of the Minecraft default, i.e. 3 means that it takes 3 times longer for a day to pass
  • 0 freezes time, -1 and 1 are equal to Minecraft default

Must be invoked from server.

int B3MAPI.getTimeMultiplier()

Gets the current time multiplier.

B3MAPI.setTimeMultiplierRaw(int multiplicator)

Sets the time multiplier temporarily. Must be between -2000 and 72. Will not be saved across sessions.

Must be invoked from server.

B3MAPI.resetTimeMultiplier()

Resets the time multiplier back after using B3MAPI.setTimeMultiplierRaw().

Must be invoked from server.

long B3MAPI.getDawnTime(World world, long worldTime)

Calculates the time of dawn for a specified world time. Used by WorldServer to determine the time for wakeAllPlayers().

float B3MAPI.getLatitude() returns latitude in degrees

Gets the latitude for which to simulate the sun and moon in the sky.

float B3MAPI.getLocalOffset() returns longitude offset in degrees

Gets the longitude offset from the center of local timezone for which to simulate the sun and moon in the sky.

B3MAPI.setLatitude(float degrees)

Sets the latitude for which to simulate the sun and moon in the sky.

Must be invoked from server.

B3MAPI.setLocalOffset(float degrees)

Sets the longitude offset from the center of local timezone for which to simulate the sun and moon in the sky.

Must be invoked from server.

boolean B3MAPI.getDaylightSaving()

Determines whether the daylight saving feature is active.

B3MAPI.setDaylightSaving(boolean active)

Activates or deactivates the gradual addition of an hour throughout the year.

Must be invoked from server.

float B3MAPI.getDefaultSunSize()

Gets the size of the sun.

B3MAPI.setDefaultSunSize(float size)

Sets the size of the sun. Must be between 7.5F and 40.0F.

float B3MAPI.getDefaultMoonSize()

Gets the size of the moon.

B3MAPI.setDefaultMoonSize(float size)

Sets the size of the moon. Must be between 7.5F and 40.0F.

World B3MAPI.getWorld()

Gets the active world object.

boolean B3MAPI.isModEnabled()

Determines whether the mod is active.

Examples

    import sedridor.B3M.api.B3MAPI;

    ...

    @EventHandler
    public void serverStarting(FMLServerStartingEvent event)
    {
        if (Loader.isModLoaded("B3M"))
        {
            // Make days 3 times longer
            B3MAPI.setTimeMultiplier(3);
            // Set location to Paris (48.87N 2.34E)
            B3MAPI.setLatitude(48.87F);
            // 2.34E is -12.66 degrees away from the center of its timezone UTC+1, which is defined as 15.0E
            B3MAPI.setLocalOffset(-12.66F);
        }
    }

Changes the day/night cycle to be 1 hour long and to simulate the sun/moon as if viewed from Paris.

    public void startSleeping()
    {
        if (Loader.isModLoaded("B3M"))
        {
            // Speeds up time by factor of 500 temporarily
            B3MAPI.setTimeMultiplierRaw(-500);
            ...
        }
    }

    public void stopSleeping()
    {
        if (Loader.isModLoaded("B3M"))
        {
            // Resets it back to what it was before setTimeMultiplierRaw(500) was used
            B3MAPI.resetTimeMultiplier();
            ...
        }
    }

Change time multiplier temporarily.