split time into 3 categories
This commit is contained in:
parent
2f9e7ba728
commit
1d19cddcef
21 changed files with 362 additions and 167 deletions
|
@ -148,6 +148,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
private long lastSchedule;
|
||||
private long lastPoll;
|
||||
private long tpsRate;
|
||||
private long time;
|
||||
|
||||
private long lastWarning;
|
||||
|
||||
|
@ -433,7 +434,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
}
|
||||
|
||||
private void saveDimension(Dimension dim) {
|
||||
TagObject tag = dim.writeData(false, dim == Space.INSTANCE ? this.space.getDayTime() : dim.getTimeOffset());
|
||||
TagObject tag = dim.writeData(false, this.time);
|
||||
File file = new File(new File(new File("chunk"), UniverseRegistry.getName(dim)), "data.cdt");
|
||||
try {
|
||||
file.getParentFile().mkdirs();
|
||||
|
@ -672,6 +673,10 @@ public final class Server implements IThreadListener, Executor {
|
|||
}
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public void run(long time) {
|
||||
Region.loadMap();
|
||||
this.loadServerConfig();
|
||||
|
@ -684,7 +689,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
this.keyPair = EncryptUtil.createKeypair();
|
||||
}
|
||||
User.loadDatabase(this.users);
|
||||
this.worlds.add(this.space = new WorldServer(this, 0L, Space.INSTANCE, UniverseRegistry.getGenerator(Space.INSTANCE)));
|
||||
this.worlds.add(this.space = new WorldServer(this, Space.INSTANCE));
|
||||
this.dimensions.put(UniverseRegistry.getId(this.space.dimension), this.space);
|
||||
new File("players").mkdirs();
|
||||
this.setTpsTarget(20.0f);
|
||||
|
@ -805,7 +810,8 @@ public final class Server implements IThreadListener, Executor {
|
|||
}
|
||||
if(++this.syncTimer == 20) {
|
||||
for(Player conn : this.players) {
|
||||
this.sendPacket(new SPacketTimeUpdate((conn.getPresentEntity() == null ? this.space : conn.getPresentEntity().worldObj).getDayTime(), Dimensions.formatTime(conn.getPresentEntity() == null ? this.space : (WorldServer)conn.getPresentEntity().worldObj, conn.getPresentEntity(), true), this.getInfo()));
|
||||
WorldServer world = conn.getPresentEntity() == null ? this.space : (WorldServer)conn.getPresentEntity().worldObj;
|
||||
this.sendPacket(new SPacketTimeUpdate(world.getOrbit(), world.getRotation(), Dimensions.formatTime(world, this.time, conn.getPresentEntity()), this.getInfo()));
|
||||
}
|
||||
this.syncTimer = 0;
|
||||
}
|
||||
|
@ -831,6 +837,8 @@ public final class Server implements IThreadListener, Executor {
|
|||
this.saveAllWorlds(false);
|
||||
this.saveTimer = 0;
|
||||
}
|
||||
if(Vars.timeFlow > 0)
|
||||
this.time += (long)Vars.timeFlow;
|
||||
Log.flushLog();
|
||||
this.tickTimes[this.perfTimer++] = System.currentTimeMillis() - now;
|
||||
if(this.perfTimer == 100) {
|
||||
|
@ -847,7 +855,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
return null;
|
||||
WorldServer world = this.dimensions.get(UniverseRegistry.getId(dim));
|
||||
if(world == null) {
|
||||
world = new WorldServer(this, this.space.getDayTime(), dim, UniverseRegistry.getGenerator(dim));
|
||||
world = new WorldServer(this, dim);
|
||||
this.worlds.add(world);
|
||||
this.dimensions.put(UniverseRegistry.getId(dim), world);
|
||||
}
|
||||
|
@ -1012,7 +1020,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
}
|
||||
conn.sendPacket(new SPacketServerConfig(vars));
|
||||
conn.sendPacket(new SPacketDimensions(Dimensions.getDimensionData()));
|
||||
conn.sendPacket(new SPacketJoinGame(player.getId(), world.dimension, world.getDayTime(), UniverseRegistry.getName(world.dimension), EntityRegistry.getEntityID(player), tag == null));
|
||||
conn.sendPacket(new SPacketJoinGame(player.getId(), world.dimension, this.time, UniverseRegistry.getName(world.dimension), EntityRegistry.getEntityID(player), tag == null));
|
||||
conn.sendPacket(new SPacketHeldItemChange(player.getSelectedIndex()));
|
||||
this.sendPacket(new SPacketPlayerListItem(false, conn));
|
||||
|
||||
|
@ -1147,7 +1155,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
nplayer.setPosition(nplayer.posX, nplayer.posY + 1.0D, nplayer.posZ);
|
||||
}
|
||||
}
|
||||
conn.sendPacket(new SPacketRespawn(world.dimension != oldWorld.dimension ? world.dimension : null, world.getDayTime(), world.dimension != oldWorld.dimension ? UniverseRegistry.getName(world.dimension) : null, EntityRegistry.getEntityID(nplayer), conn.isInEditor()));
|
||||
conn.sendPacket(new SPacketRespawn(world.dimension != oldWorld.dimension ? world.dimension : null, this.time, world.dimension != oldWorld.dimension ? UniverseRegistry.getName(world.dimension) : null, EntityRegistry.getEntityID(nplayer), conn.isInEditor()));
|
||||
conn.setPlayerLocation(nplayer.posX, nplayer.posY, nplayer.posZ, nplayer.rotYaw, nplayer.rotPitch);
|
||||
conn.sendPacket(new SPacketSetExperience(nplayer.experience, nplayer.experienceTotal, nplayer.experienceLevel));
|
||||
this.updateTimeAndWeatherForPlayer(conn, world);
|
||||
|
@ -1189,7 +1197,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
world.loadChunk((int)nplayer.posX >> 4, (int)nplayer.posZ >> 4);
|
||||
world.addPlayer(nplayer);
|
||||
world.spawnEntityInWorld(nplayer);
|
||||
conn.sendPacket(new SPacketRespawn(world.dimension != oldWorld.dimension ? world.dimension : null, world.getDayTime(), world.dimension != oldWorld.dimension ? UniverseRegistry.getName(world.dimension) : null, EntityRegistry.getEntityID(nplayer), conn.isInEditor()));
|
||||
conn.sendPacket(new SPacketRespawn(world.dimension != oldWorld.dimension ? world.dimension : null, this.time, world.dimension != oldWorld.dimension ? UniverseRegistry.getName(world.dimension) : null, EntityRegistry.getEntityID(nplayer), conn.isInEditor()));
|
||||
conn.sendPacket(new SPacketSkin(nplayer.getId(), nplayer.getSkin())); // , nplayer.getModel()));
|
||||
conn.setPlayerLocation(nplayer.posX, nplayer.posY, nplayer.posZ, nplayer.rotYaw, nplayer.rotPitch);
|
||||
conn.sendPacket(new SPacketSetExperience(nplayer.experience, nplayer.experienceTotal, nplayer.experienceLevel));
|
||||
|
@ -1207,7 +1215,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
public void transferToDimension(EntityNPC player, Dimension dimension, BlockPos pos, float yaw, float pitch, PortalType portal) {
|
||||
WorldServer oldWorld = (WorldServer)player.getServerWorld(); // this.getWorld(player.dimension);
|
||||
WorldServer newWorld = this.getWorld(dimension);
|
||||
player.connection.sendPacket(new SPacketRespawn(newWorld.dimension, newWorld.getDayTime(), UniverseRegistry.getName(newWorld.dimension), EntityRegistry.getEntityID(player), player.connection.isInEditor()));
|
||||
player.connection.sendPacket(new SPacketRespawn(newWorld.dimension, this.time, UniverseRegistry.getName(newWorld.dimension), EntityRegistry.getEntityID(player), player.connection.isInEditor()));
|
||||
oldWorld.removePlayerEntityDangerously(player);
|
||||
player.dead = false;
|
||||
this.placeInDimension(player, oldWorld, newWorld, pos, portal);
|
||||
|
@ -1278,7 +1286,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
}
|
||||
|
||||
private void updateTimeAndWeatherForPlayer(Player conn, WorldServer world) {
|
||||
conn.sendPacket(new SPacketTimeUpdate(world.getDayTime(), Dimensions.formatTime(world, conn.getPresentEntity(), true), this.getInfo()));
|
||||
conn.sendPacket(new SPacketTimeUpdate(world.getOrbit(), world.getRotation(), Dimensions.formatTime(world, this.time, conn.getPresentEntity()), this.getInfo()));
|
||||
conn.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.SET_WEATHER, world.getWeather().ordinal()));
|
||||
conn.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.RAIN_STRENGTH, world.getRainStrength()));
|
||||
conn.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.DARKNESS, world.getDarkness()));
|
||||
|
|
|
@ -239,7 +239,6 @@ public class CommandEnvironment {
|
|||
this.registerExecutable(new CommandWorld());
|
||||
this.registerExecutable(new CommandOfflinetp());
|
||||
this.registerExecutable(new CommandWarp());
|
||||
this.registerExecutable(new CommandTime());
|
||||
this.registerExecutable(new CommandRemove());
|
||||
this.registerExecutable(new CommandWeather());
|
||||
this.registerExecutable(new CommandKick());
|
||||
|
@ -281,6 +280,9 @@ public class CommandEnvironment {
|
|||
this.registerExecutable(new CommandReset());
|
||||
this.registerExecutable(new CommandTick());
|
||||
this.registerExecutable(new CommandFreeze());
|
||||
this.registerExecutable(new CommandEpoch());
|
||||
this.registerExecutable(new CommandTime());
|
||||
this.registerExecutable(new CommandSeason());
|
||||
|
||||
this.registerExecutable(new CommandSet());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package server.command.commands;
|
||||
|
||||
import common.dimension.Dimension;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.RunException;
|
||||
import server.world.WorldServer;
|
||||
|
||||
public class CommandEpoch extends Command {
|
||||
public CommandEpoch() {
|
||||
super("epoch");
|
||||
|
||||
this.addString("epoch", false, "1h", "10h", "20h", "50h", "1d", "10d", "20d", "50d", "1y", "10y", "20y", "50y", "1m", "10m", "20m", "50m");
|
||||
this.addWorld("dim", true);
|
||||
|
||||
this.setParamsOptional();
|
||||
this.addFlag("absolute", 'a');
|
||||
}
|
||||
|
||||
public static long parseInt(String input, long max) {
|
||||
long num;
|
||||
try {
|
||||
num = Long.parseLong(input);
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
throw new RunException("'%s' ist keine gültige Zahl", input);
|
||||
}
|
||||
if(num < 0)
|
||||
throw new RunException("Die Zeit muss mindestens 0 betragen", num);
|
||||
else if(num > max)
|
||||
throw new RunException("Die Zeit darf höchstens %d betragen", num, max);
|
||||
return num;
|
||||
}
|
||||
|
||||
private long parseTime(Dimension dim, String arg) {
|
||||
long t;
|
||||
if(arg.toLowerCase().endsWith("m"))
|
||||
t = dim.getOrbitalPeriod() * 1000L;
|
||||
else if(arg.toLowerCase().endsWith("y"))
|
||||
t = dim.getOrbitalPeriod();
|
||||
else if(arg.toLowerCase().endsWith("d"))
|
||||
t = dim.getRotationalPeriod();
|
||||
else if(arg.toLowerCase().endsWith("h"))
|
||||
t = 1000L;
|
||||
else
|
||||
t = -1L;
|
||||
arg = t == -1L ? arg : arg.substring(0, arg.length() - 1);
|
||||
t = t < 1L ? 1L : t;
|
||||
return t * parseInt(arg, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, String timeStr, WorldServer world, boolean absolute) {
|
||||
long time = absolute ? 0L : world.dimension.getEpoch();
|
||||
time += parseTime(world.dimension, timeStr);
|
||||
world.dimension.setEpoch(time);
|
||||
world.resetWeather();
|
||||
exec.log("Zeit in %s auf %s gesetzt", world.dimension.getDisplay(), world.formatEpoch());
|
||||
return time;
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ public class CommandFreeze extends Command {
|
|||
exec.log("Die Welt ist jetzt nicht mehr eingefroren");
|
||||
return;
|
||||
}
|
||||
env.getServer().setVariableOverride("freeze", () -> {SVars.randomTick = 0; SVars.boltChance = 0; SVars.weatherTick = 0; SVars.weatherChance = 0; SVars.tickSpawn = false; Vars.dayCycle = false; Vars.mobTick = false; Vars.liquidPhysics = false; Vars.blockGravity = false; Vars.fire = false;});
|
||||
env.getServer().setVariableOverride("freeze", () -> {SVars.randomTick = 0; SVars.boltChance = 0; SVars.weatherTick = 0; SVars.weatherChance = 0; SVars.tickSpawn = false; Vars.timeFlow = 0; Vars.mobTick = false; Vars.liquidPhysics = false; Vars.blockGravity = false; Vars.fire = false;});
|
||||
exec.log("Welt wurde eingefroren");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package server.command.commands;
|
||||
|
||||
import common.dimension.Dimension;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.RunException;
|
||||
import server.world.WorldServer;
|
||||
|
||||
public class CommandSeason extends Command {
|
||||
public CommandSeason() {
|
||||
super("season");
|
||||
|
||||
this.addString("season", false, "spring", "summer", "autumn", "winter", "1d", "10d", "20d", "50d");
|
||||
this.addWorld("dim", true);
|
||||
|
||||
this.setParamsOptional();
|
||||
this.addFlag("absolute", 'a');
|
||||
}
|
||||
|
||||
private long parseOrbitTime(Dimension dim, String arg) {
|
||||
if(arg.equalsIgnoreCase("spring"))
|
||||
return 0L;
|
||||
else if(arg.equalsIgnoreCase("summer"))
|
||||
return dim.getOrbitalPeriod() / 4L;
|
||||
else if(arg.equalsIgnoreCase("autumn"))
|
||||
return dim.getOrbitalPeriod() / 2L;
|
||||
else if(arg.equalsIgnoreCase("winter"))
|
||||
return dim.getOrbitalPeriod() * 3L / 4L;
|
||||
else if(arg.startsWith("@"))
|
||||
return CommandEpoch.parseInt(arg.substring(1), dim.getOrbitalPeriod() - 1);
|
||||
else
|
||||
return -1L;
|
||||
}
|
||||
|
||||
private long parseTime(Dimension dim, String arg) {
|
||||
long t;
|
||||
if(arg.toLowerCase().endsWith("d"))
|
||||
t = dim.getRotationalPeriod();
|
||||
else
|
||||
t = -1L;
|
||||
arg = t == -1L ? arg : arg.substring(0, arg.length() - 1);
|
||||
t = t < 1L ? 1L : t;
|
||||
return t * CommandEpoch.parseInt(arg, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, String timeStr, WorldServer world, boolean absolute) {
|
||||
if(!world.dimension.hasOrbit())
|
||||
throw new RunException("Welt %s hat keine Jahreszeiten", world.dimension.getDisplay());
|
||||
long time = absolute ? 0L : world.getOrbit();
|
||||
long fwd = parseOrbitTime(world.dimension, timeStr);
|
||||
if(fwd >= 0L) {
|
||||
if(absolute) {
|
||||
time += fwd;
|
||||
}
|
||||
else {
|
||||
time -= world.getOrbit() % world.dimension.getOrbitalPeriod();
|
||||
time += fwd;
|
||||
time += time <= world.getOrbit() ? world.dimension.getOrbitalPeriod() : 0L;
|
||||
}
|
||||
}
|
||||
else {
|
||||
time += parseTime(world.dimension, timeStr);
|
||||
}
|
||||
time = time % world.dimension.getOrbitalPeriod();
|
||||
world.dimension.setOrbit(time);
|
||||
world.setOrbit(time);
|
||||
world.resetWeather();
|
||||
exec.log("Jahreszeit in %s auf %s (%d / %d) gesetzt", world.dimension.getDisplay(), world.getLeavesType().getDisplay(), world.getOrbit(), world.dimension.getOrbitalPeriod());
|
||||
return time;
|
||||
}
|
||||
}
|
|
@ -1,41 +1,21 @@
|
|||
package server.command.commands;
|
||||
|
||||
import common.dimension.Dimension;
|
||||
import common.dimension.Space;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.RunException;
|
||||
import server.dimension.Dimensions;
|
||||
import server.init.UniverseRegistry;
|
||||
import server.network.Player;
|
||||
import server.world.WorldServer;
|
||||
|
||||
public class CommandTime extends Command {
|
||||
public CommandTime() {
|
||||
super("time");
|
||||
|
||||
this.addString("time", false, "day", "night", "noon", "midnight", "sunrise", "sunset");
|
||||
this.addString("time", false, "day", "night", "noon", "midnight", "sunrise", "sunset", "1h", "10h", "20h", "50h");
|
||||
this.addWorld("dim", true);
|
||||
|
||||
this.setParamsOptional();
|
||||
this.addFlag("absolute", 'a');
|
||||
this.addFlag("global", 'g');
|
||||
}
|
||||
|
||||
private long parseInt(String input, long max) {
|
||||
long num;
|
||||
try {
|
||||
num = Long.parseLong(input);
|
||||
}
|
||||
catch(NumberFormatException e) {
|
||||
throw new RunException("'%s' ist keine gültige Zahl", input);
|
||||
}
|
||||
if(num < 0)
|
||||
throw new RunException("Die Zeit muss mindestens 0 betragen", num);
|
||||
else if(num > max)
|
||||
throw new RunException("Die Zeit darf höchstens %d betragen", num, max);
|
||||
return num;
|
||||
}
|
||||
|
||||
private long parseDayTime(Dimension dim, String arg) {
|
||||
|
@ -52,65 +32,45 @@ public class CommandTime extends Command {
|
|||
else if(arg.equalsIgnoreCase("midnight"))
|
||||
return 0L;
|
||||
else if(arg.startsWith("@"))
|
||||
return this.parseInt(arg.substring(1), dim.getRotationalPeriod() - 1);
|
||||
return CommandEpoch.parseInt(arg.substring(1), dim.getRotationalPeriod() - 1);
|
||||
else
|
||||
return -1L;
|
||||
}
|
||||
|
||||
private long parseTime(Dimension dim, String arg) {
|
||||
long t;
|
||||
if(arg.toLowerCase().endsWith("y"))
|
||||
t = dim.getOrbitalPeriod();
|
||||
else if(arg.toLowerCase().endsWith("d"))
|
||||
t = dim.getRotationalPeriod();
|
||||
else if(arg.toLowerCase().endsWith("h"))
|
||||
if(arg.toLowerCase().endsWith("h"))
|
||||
t = 1000L;
|
||||
else
|
||||
t = -1L;
|
||||
arg = t == -1L ? arg : arg.substring(0, arg.length() - 1);
|
||||
t = t < 1L ? 1L : t;
|
||||
return t * this.parseInt(arg, Long.MAX_VALUE);
|
||||
return t * CommandEpoch.parseInt(arg, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, String timeStr, WorldServer world, boolean absolute, boolean global) {
|
||||
long time = absolute ? 0L : world.getDayTime();
|
||||
public Object exec(CommandEnvironment env, Executor exec, String timeStr, WorldServer world, boolean absolute) {
|
||||
if(!world.dimension.hasRotation())
|
||||
throw new RunException("Welt %s hat keine Tageszeit", world.dimension.getDisplay());
|
||||
long time = absolute ? 0L : world.getRotation();
|
||||
long fwd = parseDayTime(world.dimension, timeStr);
|
||||
if(fwd >= 0L) {
|
||||
if(absolute) {
|
||||
time += fwd;
|
||||
}
|
||||
else {
|
||||
time -= world.getDayTime() % world.dimension.getRotationalPeriod();
|
||||
time -= world.getRotation() % world.dimension.getRotationalPeriod();
|
||||
time += fwd;
|
||||
time += time <= world.getDayTime() ? world.dimension.getRotationalPeriod() : 0L;
|
||||
time += time <= world.getRotation() ? world.dimension.getRotationalPeriod() : 0L;
|
||||
}
|
||||
}
|
||||
else {
|
||||
time += parseTime(world.dimension, timeStr);
|
||||
}
|
||||
if(global) {
|
||||
for(Dimension dim : UniverseRegistry.getDimensions()) {
|
||||
dim.setTimeOffset(dim != Space.INSTANCE ? 0L : time);
|
||||
}
|
||||
for(WorldServer wld : env.getServer().getWorlds()) {
|
||||
wld.setDayTime(time);
|
||||
wld.resetWeather();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(world.dimension == Space.INSTANCE) {
|
||||
long diff = time - world.getDayTime();
|
||||
for(Dimension dim : UniverseRegistry.getDimensions()) {
|
||||
dim.setTimeOffset(dim != Space.INSTANCE ? dim.getTimeOffset() - diff : time);
|
||||
}
|
||||
}
|
||||
else {
|
||||
world.dimension.setTimeOffset(time - env.getServer().getSpace().getDayTime());
|
||||
}
|
||||
world.setDayTime(time);
|
||||
world.resetWeather();
|
||||
}
|
||||
exec.log("Zeit " + (global ? "aller Dimensionen (relativ zu %s)" : "in %s") + " auf %s gesetzt", world.dimension.getDisplay(), Dimensions.formatTime(world, exec.isPlayer() ? ((Player)exec).getPresentEntity() : null, false));
|
||||
time = time % world.dimension.getRotationalPeriod();
|
||||
world.dimension.setRotation(time);
|
||||
world.setRotation(time);
|
||||
world.resetWeather();
|
||||
exec.log("Tageszeit in %s auf %s (%d / %d) gesetzt", world.dimension.getDisplay(), world.formatTime(), world.getRotation(), world.dimension.getRotationalPeriod());
|
||||
return time;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import common.dimension.Space;
|
|||
import common.dimension.Star;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.packet.SPacketDimensions.DimData;
|
||||
import common.world.World;
|
||||
import server.init.UniverseRegistry;
|
||||
import server.world.WorldServer;
|
||||
|
||||
|
@ -105,36 +106,10 @@ public abstract class Dimensions {
|
|||
return 6;
|
||||
}
|
||||
|
||||
public static String formatTime(WorldServer world, Dimension home, int category, boolean days) {
|
||||
String qualifier = home != null ? (category >= 0 ? category + "." : "?.") : "";
|
||||
long time = world.getDayTime();
|
||||
String gtime;
|
||||
if((home == null || !home.isCelestial()) && !world.dimension.isCelestial()) {
|
||||
gtime = "???.???.M?";
|
||||
}
|
||||
else {
|
||||
long yearTime = (home != null && home.isCelestial() ? home : world.dimension).getOrbitalPeriod();
|
||||
long year = time / yearTime;
|
||||
long frac = (time * 1000L / yearTime) % 1000L;
|
||||
gtime = String.format("%03d.%03d.M%d", frac, year % 1000L, year / 1000L + 1L);
|
||||
}
|
||||
if(!days)
|
||||
return qualifier + gtime;
|
||||
String ltime;
|
||||
if(!world.dimension.isCelestial()) {
|
||||
ltime = " T???.??? D???.???.G?";
|
||||
}
|
||||
else {
|
||||
long day = time / world.dimension.getRotationalPeriod();
|
||||
time = time % world.dimension.getRotationalPeriod();
|
||||
ltime = String.format(" T%03d.%03d D%03d.%03d.G%d",
|
||||
time / 1000L, time % 1000L, (day / 1000L) % 1000L, day % 1000L, day / 1000000L);
|
||||
}
|
||||
return qualifier + gtime + ltime;
|
||||
}
|
||||
|
||||
public static String formatTime(WorldServer world, EntityNPC player, boolean days) {
|
||||
return formatTime(world, player == null ? null : player.getOrigin().getDimension(), player == null ? -1 : getTimeQualifier(world.dimension, player.getOrigin().getDimension()), days);
|
||||
public static String formatTime(WorldServer world, long time, EntityNPC player) {
|
||||
Dimension dim = player == null ? null : player.getOrigin().getDimension();
|
||||
int category = getTimeQualifier(world.dimension, dim);
|
||||
return (category >= 0 ? category + "." : "?.") + World.formatEpoch(dim, dim == null ? 0L : dim.getEpoch() + time - dim.getLastTicked(), true);
|
||||
}
|
||||
|
||||
public static void updateDimensions() {
|
||||
|
|
|
@ -249,18 +249,23 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
}
|
||||
|
||||
public WorldServer(Server server, long dtime, Dimension dim, GeneratorData gen) {
|
||||
public WorldServer(Server server, Dimension dim) {
|
||||
super(dim);
|
||||
this.server = server;
|
||||
// this.time = time;
|
||||
this.daytime = dtime + this.dimension.getTimeOffset();
|
||||
this.gen = gen;
|
||||
this.time = this.dimension.getTimeExisted();
|
||||
long dtime = this.server.getTime() - this.dimension.getLastTicked();
|
||||
this.dimension.setLastTicked(this.server.getTime());
|
||||
if(this.dimension.hasOrbit())
|
||||
this.dimension.setOrbit(this.orbit = (this.dimension.getOrbit() + dtime) % this.dimension.getOrbitalPeriod());
|
||||
if(this.dimension.hasRotation())
|
||||
this.dimension.setRotation(this.rotation = (this.dimension.getRotation() + dtime) % this.dimension.getRotationalPeriod());
|
||||
this.dimension.setEpoch(this.dimension.getEpoch() + dtime);
|
||||
this.gen = UniverseRegistry.getGenerator(dim);
|
||||
this.updateViewRadius();
|
||||
this.chunkDir = new File(new File("chunk"), UniverseRegistry.getName(dim));
|
||||
this.chunkDir.mkdirs();
|
||||
|
||||
this.seed = this.dimension.getSeed();
|
||||
this.time = this.dimension.getTimeExisted();
|
||||
|
||||
this.grng = new Random(this.seed ^ 836430928262265276L);
|
||||
this.tempGen = new PerlinGen(this.grng, 1);
|
||||
|
@ -320,9 +325,14 @@ public final class WorldServer extends AWorldServer {
|
|||
// if(this.primary)
|
||||
// this.info.tick();
|
||||
this.dimension.setTimeExisted(this.time += 1L);
|
||||
// this.dataModified = true;
|
||||
if(Vars.dayCycle) // {
|
||||
this.daytime += (long)Vars.timeFlow;
|
||||
this.dimension.setLastTicked(this.server.getTime());
|
||||
if(Vars.timeFlow > 0) {
|
||||
if(this.dimension.hasOrbit())
|
||||
this.dimension.setOrbit(this.orbit = ((this.orbit + (long)Vars.timeFlow) % this.dimension.getOrbitalPeriod()));
|
||||
if(this.dimension.hasRotation())
|
||||
this.dimension.setRotation(this.rotation = ((this.rotation + (long)Vars.timeFlow) % this.dimension.getRotationalPeriod()));
|
||||
this.dimension.setEpoch(this.dimension.getEpoch() + (long)Vars.timeFlow);
|
||||
}
|
||||
// if(this.dimension.getType().dayCycle)
|
||||
// this.season = this.getSeasonByTime();
|
||||
// }
|
||||
|
@ -2199,8 +2209,8 @@ public final class WorldServer extends AWorldServer {
|
|||
|
||||
public LeavesType getLeavesGen(BlockPos pos) {
|
||||
return this.canFreezeAt(pos) ? LeavesType.SNOWY : (!this.dimension.hasSeasons() ?
|
||||
this.gen.getLeavesType() : LeavesType.values()[(int)((this.daytime %
|
||||
this.dimension.getOrbitalPeriod()) * (long)LeavesType.values().length / this.dimension.getOrbitalPeriod())]);
|
||||
this.gen.getLeavesType() : LeavesType.values()[(int)((this.orbit %
|
||||
this.dimension.getOrbitalPeriod()) * 4L / this.dimension.getOrbitalPeriod())]);
|
||||
}
|
||||
|
||||
// public boolean canBlockSeeSky(BlockPos pos) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue