forked from tModLoader/tModLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddTimeCommand.cs
44 lines (36 loc) · 868 Bytes
/
AddTimeCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace ExampleMod.Commands
{
public class AddTimeCommand : ModCommand
{
public override CommandType Type
=> CommandType.World;
public override string Command
=> "addTime";
public override string Usage
=> "/addTime numTicks";
public override string Description
=> "Add or rewind world time";
public override void Action(CommandCaller caller, string input, string[] args) {
double fullTime = Main.time;
if (!Main.dayTime) {
fullTime += 54000.0;
}
fullTime += int.Parse(args[0]);
fullTime %= 86400.0;
if (fullTime < 0) {
fullTime += 86400;
}
Main.dayTime = fullTime < 54000;
Main.time = fullTime;
if (!Main.dayTime) {
Main.time -= 54000;
}
if (Main.netMode == 2) {
NetMessage.SendData(MessageID.WorldData);
}
}
}
}