Search in sources :

Example 1 with WorldtimeResetEvent

use of org.terasology.engine.logic.players.event.WorldtimeResetEvent in project Terasology by MovingBlocks.

the class DebugControlSystem method timeTravel.

/**
 * Ensures every player on the server has their time updated when a KeyEvent is triggered in Debug mode.
 *
 * @param entity The player entity that triggered the time change.
 * @param event The KeyEvent which triggered the time change.
 * @param timeDiff The time (in days) to add/retrieve.
 */
private void timeTravel(EntityRef entity, KeyEvent event, float timeDiff) {
    float timeInDays = world.getTime().getDays();
    entity.send(new WorldtimeResetEvent(timeInDays + timeDiff));
    event.consume();
}
Also used : WorldtimeResetEvent(org.terasology.engine.logic.players.event.WorldtimeResetEvent)

Example 2 with WorldtimeResetEvent

use of org.terasology.engine.logic.players.event.WorldtimeResetEvent in project Terasology by MovingBlocks.

the class ClientCommands method setWorldTime.

/**
 * Sets the current world time for the local player in days
 * @param day Float containing day to be set
 * @return String message containing message to notify user
 */
@Command(shortDescription = "Sets the current world time for the local player in days", requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setWorldTime(@CommandParam("day") float day, @Sender EntityRef sender) {
    worldProvider.getTime().setDays(day);
    sender.send(new WorldtimeResetEvent(day));
    return "World time changed";
}
Also used : WorldtimeResetEvent(org.terasology.engine.logic.players.event.WorldtimeResetEvent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Aggregations

WorldtimeResetEvent (org.terasology.engine.logic.players.event.WorldtimeResetEvent)2 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)1