Skip to content

Commit

Permalink
Calendar bugfixing and localization. Added /timetfc add ticks to repl…
Browse files Browse the repository at this point in the history
…ace /time add for changing the daylight cycle.
  • Loading branch information
alcatrazEscapee committed Mar 30, 2019
1 parent 0a3e842 commit c9ef71f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
18 changes: 16 additions & 2 deletions src/main/java/net/dries007/tfc/cmd/CommandTimeTFC.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public String getName()
@Override
public String getUsage(ICommandSender sender)
{
return "/timetfc [set|add] [year|month|day|monthLength] [value]";
return "/timetfc [set|add] [year|month|day|monthLength|ticks] [value]";
}

@Override
Expand All @@ -45,6 +45,7 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
if (args.length != 3) throw new WrongUsageException("Requires three arguments");

long time = CalendarTFC.TICKS_IN_DAY;
boolean updateDaylightCycle = false;
switch (args[1].toLowerCase())
{
case "month":
Expand All @@ -58,6 +59,11 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
case "day":
time *= parseInt(args[2], 0, CalendarTFC.getDaysInMonth() * 12 * 1000);
break;
case "ticks":
// This one is different, because it needs to update the actual sun cycle
time = parseInt(args[2], 0, Integer.MAX_VALUE);
updateDaylightCycle = true;
break;
case "monthlength":
int value = parseInt(args[2], 1, 1000);
CalendarTFC.setMonthLength(server.getEntityWorld(), value);
Expand All @@ -78,6 +84,14 @@ else if (!args[0].equals("set"))

CalendarTFC.setCalendarTime(server.getEntityWorld(), time);
ITextComponent month = new TextComponentTranslation(Helpers.getEnumName(CalendarTFC.getMonthOfYear()));
sender.sendMessage(new TextComponentTranslation(MOD_ID + ".tooltip.set_time", CalendarTFC.getTotalYears(), month, CalendarTFC.getDayOfMonth(), CalendarTFC.getHourOfDay(), CalendarTFC.getMinuteOfHour()));
sender.sendMessage(new TextComponentTranslation(MOD_ID + ".tooltip.set_time", CalendarTFC.getTotalYears(), month, CalendarTFC.getDayOfMonth(), String.format("%02d:%02d", CalendarTFC.getHourOfDay(), CalendarTFC.getMinuteOfHour())));

if (updateDaylightCycle)
{
for (int i = 0; i < server.worlds.length; ++i)
{
server.worlds[i].setWorldTime(time);
}
}
}
}
3 changes: 0 additions & 3 deletions src/main/java/net/dries007/tfc/world/classic/CalendarTFC.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ public static int getDaysInYear()

public enum Month
{
// todo: make tfc.enum.month.march=Early Spring a translation key
JANUARY(10, 66.5f, "Jan"),
FEBRUARY(11, 65.5f, "Feb"),
MARCH(0, 56f, "Mar"),
Expand Down Expand Up @@ -224,8 +223,6 @@ public static Month getById(int id)

public String getShortName() { return abrev; }

public String getLongName() { return name().substring(0, 1) + name().substring(1).toLowerCase(); }

public Month next()
{
if (this == FEBRUARY)
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/tfc/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tfc.tooltip.crucible_result=Result:

## Command Tooltips / Messages
tfc.tooltip.set_month_length=Set Month Length to %d days
tfc.tooltip.set_time=Set Calendar Time to Year %04d, %s %02d %02d:%02d
tfc.tooltip.set_time=Set Calendar Time to Year %04d, %s %02d %s
tfc.tooltip.time_command_disabled=This command has been disabled by TFC. Use /timetfc instead!

## Keybindings
Expand Down Expand Up @@ -187,7 +187,7 @@ tfc.enum.forgerule.shrink_third_last=Shrink Third Last


tfc.enum.month.january=Winter
tfc.enum.month.febuary=Late Winter
tfc.enum.month.february=Late Winter
tfc.enum.month.march=Early Spring
tfc.enum.month.april=Spring
tfc.enum.month.may=Late Spring
Expand Down

0 comments on commit c9ef71f

Please sign in to comment.