From 1d19cddcef2052e602b2224215ef931121758a2a Mon Sep 17 00:00:00 2001 From: Sen Date: Sun, 3 Aug 2025 21:58:30 +0200 Subject: [PATCH] split time into 3 categories --- client/src/main/java/client/Client.java | 25 ++++--- .../java/client/network/ClientPlayer.java | 6 +- .../java/client/renderer/RenderGlobal.java | 4 +- .../java/common/block/foliage/LeavesType.java | 5 +- .../main/java/common/dimension/Dimension.java | 62 +++++++++++++--- .../src/main/java/common/dimension/Moon.java | 6 +- .../main/java/common/dimension/Planet.java | 6 +- .../src/main/java/common/dimension/Star.java | 2 +- .../main/java/common/init/BlockRegistry.java | 2 +- .../common/item/tool/ItemSpaceNavigator.java | 13 +++- .../java/common/packet/SPacketTimeUpdate.java | 22 ++++-- common/src/main/java/common/vars/Vars.java | 4 +- common/src/main/java/common/world/World.java | 72 +++++++++++++------ server/src/main/java/server/Server.java | 26 ++++--- .../server/command/CommandEnvironment.java | 4 +- .../server/command/commands/CommandEpoch.java | 61 ++++++++++++++++ .../command/commands/CommandFreeze.java | 2 +- .../command/commands/CommandSeason.java | 72 +++++++++++++++++++ .../server/command/commands/CommandTime.java | 70 ++++-------------- .../java/server/dimension/Dimensions.java | 35 ++------- .../main/java/server/world/WorldServer.java | 30 +++++--- 21 files changed, 362 insertions(+), 167 deletions(-) create mode 100644 server/src/main/java/server/command/commands/CommandEpoch.java create mode 100644 server/src/main/java/server/command/commands/CommandSeason.java diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 352ff638..2899a8c3 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -177,6 +177,7 @@ import common.vars.Vars; import common.world.Chunk; import common.world.LightType; import common.world.State; +import common.world.Weather; import common.world.World; /* @@ -285,7 +286,8 @@ public class Client implements IThreadListener { private final class WorldClient extends World { public WorldClient(Dimension dim) { super(dim, true); - this.daytime = dim.getTimeOffset(); + this.orbit = dim.getOrbit(); + this.rotation = dim.getRotation(); this.calculateInitialSkylight(); this.calculateInitialWeather(); this.updatePhysics(); @@ -1895,16 +1897,17 @@ public class Client implements IThreadListener { + chunk.getLight(LightType.BLOCK, pos) + " Blöcke, " + String.format( "%.1f", this.entityRenderer.getSunBrightness(1.0f) * 15.0f) + " Welt), A: " + String.format("%.1f °", this.world.getCelestialAngle(1.0f)) + "\n" + - String.format("Zeit: %d T, R %d / %d T, U %d / %d T", - this.world.getDayTime(), - this.world.getDayTime() % this.world.dimension.getRotationalPeriod(), + String.format("Zeit: %s" + (this.world.dimension.hasRotation() ? ", R %d / %d T" : "") + (this.world.dimension.hasOrbit() ? ", U %d / %d T" : ""), + this.world.formatEpochSimple(), + this.world.getRotation(), this.world.dimension.getRotationalPeriod(), - this.world.getDayTime() % this.world.dimension.getOrbitalPeriod(), + this.world.getOrbit(), this.world.dimension.getOrbitalPeriod() ) + "\n" + - String.format("Laub: %s, T: %.2f K / %.2f °C, %s (R %.1f, %.1f)", - !this.world.dimension.hasSeasons() ? "*" : this.world.getLeavesType().getDisplayName(), + String.format("Laub: %s, T: %.2f K / %.2f °C, %s%s (R %.1f, %.1f)", + !this.world.dimension.hasSeasons() ? "*" : this.world.getLeavesType().getDisplay(), this.world.getTemperatureK(pos), this.world.getTemperatureC(pos), + this.world.dimension.hasWeather() ? "" : "*", !this.world.dimension.hasWeather() && this.world.getWeather() == Weather.CLEAR ? "" : this.world.getWeather().getDisplay(), this.world.getRainStrength(), this.world.getDarkness() ) + "\n" + @@ -3468,9 +3471,13 @@ public class Client implements IThreadListener { this.world.updatePhysics(); this.markReload(); - if (Vars.dayCycle) + if (Vars.timeFlow > 0) { - this.world.setDayTime(this.world.getDayTime() + (long)Vars.timeFlow); + if(this.world.dimension.hasOrbit()) + this.world.setOrbit((this.world.getOrbit() + (long)Vars.timeFlow) % this.world.dimension.getOrbitalPeriod()); + if(this.world.dimension.hasRotation()) + this.world.setRotation((this.world.getRotation() + (long)Vars.timeFlow) % this.world.dimension.getRotationalPeriod()); + this.world.dimension.setEpoch(this.world.dimension.getEpoch() + (long)Vars.timeFlow); } for (int i = 0; i < 10 && !this.spawnQueue.isEmpty(); ++i) diff --git a/client/src/main/java/client/network/ClientPlayer.java b/client/src/main/java/client/network/ClientPlayer.java index 96291d2d..f0e1878b 100755 --- a/client/src/main/java/client/network/ClientPlayer.java +++ b/client/src/main/java/client/network/ClientPlayer.java @@ -959,8 +959,10 @@ public class ClientPlayer implements IClientPlayer public void handleTimeUpdate(SPacketTimeUpdate packetIn) { NetHandler.checkThread(packetIn, this, this.gm, this.world); -// this.gameController.theWorld.getWorldInfo().setTime(packetIn.getTotalWorldTime()); - this.gm.world.setDayTime(packetIn.getWorldTime()); + if(this.gm.world.dimension.hasOrbit()) + this.gm.world.setOrbit(packetIn.getOrbit()); + if(this.gm.world.dimension.hasRotation()) + this.gm.world.setRotation(packetIn.getRotation()); this.gm.setTicked(packetIn.getServerinfo()); Items.navigator.setLocalTime(packetIn.getLocalTime()); } diff --git a/client/src/main/java/client/renderer/RenderGlobal.java b/client/src/main/java/client/renderer/RenderGlobal.java index 92269b8a..9c8a8e5c 100755 --- a/client/src/main/java/client/renderer/RenderGlobal.java +++ b/client/src/main/java/client/renderer/RenderGlobal.java @@ -1254,7 +1254,7 @@ public class RenderGlobal float f15 = this.gm.entityRenderer.getStarBrightness(partialTicks) * f16; if (f15 > 0.0F) { - int stars = this.theWorld.dimension.getStarColor(this.theWorld.getDayTime()); + int stars = this.theWorld.dimension.getStarColor(this.theWorld.getRotation()); if(stars == 0xffffffff) { GlState.color(f15, f15, f15, f15); } @@ -1281,7 +1281,7 @@ public class RenderGlobal f15 = this.gm.entityRenderer.getDeepStarBrightness(partialTicks) * f16; if (f15 > 0.0F) { - int stars = this.theWorld.dimension.getDeepStarColor(this.theWorld.getDayTime()); + int stars = this.theWorld.dimension.getDeepStarColor(this.theWorld.getRotation()); if(stars == 0xffffffff) { GlState.color(f15, f15, f15, f15); } diff --git a/common/src/main/java/common/block/foliage/LeavesType.java b/common/src/main/java/common/block/foliage/LeavesType.java index 7e3c4a69..5c7ea31a 100755 --- a/common/src/main/java/common/block/foliage/LeavesType.java +++ b/common/src/main/java/common/block/foliage/LeavesType.java @@ -1,8 +1,9 @@ package common.block.foliage; +import common.util.Displayable; import common.util.Identifyable; -public enum LeavesType implements Identifyable { +public enum LeavesType implements Identifyable, Displayable { SPRING("spring", "Frühling"), SUMMER("summer", "Sommer"), AUTUMN("autumn", "Herbst"), @@ -21,7 +22,7 @@ public enum LeavesType implements Identifyable { return this.name; } - public String getDisplayName() { + public String getDisplay() { return this.display; } diff --git a/common/src/main/java/common/dimension/Dimension.java b/common/src/main/java/common/dimension/Dimension.java index 434c9aac..66482027 100755 --- a/common/src/main/java/common/dimension/Dimension.java +++ b/common/src/main/java/common/dimension/Dimension.java @@ -92,7 +92,10 @@ public abstract class Dimension extends Section { private long seed = 0L; private boolean exterminated = false; private long timeExisted = 0L; - private long timeOffset = 0L; + private long lastTicked = 0L; + private long orbit = 0L; + private long rotation = 0L; + private long epoch = 0L; private Weather weather = this.defaultWeather; protected Dimension(boolean custom) { @@ -114,13 +117,25 @@ public abstract class Dimension extends Section { this.timeExisted = time; } - public final void setTimeOffset(long time) { - this.timeOffset = time; + public final void setLastTicked(long time) { + this.lastTicked = time; } - public final void setCurrentWeather(Weather weather) { + public final void setOrbit(long time) { + this.orbit = time; + } + + public final void setRotation(long time) { + this.rotation = time; + } + + public final void setWeather(Weather weather) { this.weather = weather; } + + public final void setEpoch(long time) { + this.epoch = time; + } public final long getSeed() { @@ -135,14 +150,26 @@ public abstract class Dimension extends Section { return this.timeExisted; } - public final long getTimeOffset() { - return this.timeOffset; + public final long getLastTicked() { + return this.lastTicked; } - public final Weather getCurrentWeather() { + public final long getOrbit() { + return this.orbit; + } + + public final long getRotation() { + return this.rotation; + } + + public final Weather getWeather() { return this.weather; } + public final long getEpoch() { + return this.epoch; + } + protected final void setComposition(State filler, State liquid, int seaLevel) { this.filler = filler; @@ -378,7 +405,11 @@ public abstract class Dimension extends Section { return false; } - public boolean isCelestial() { + public boolean hasRotation() { + return false; + } + + public boolean hasOrbit() { return false; } @@ -444,11 +475,16 @@ public abstract class Dimension extends Section { return dim; } - public final TagObject writeData(boolean send, long offset) { + public final TagObject writeData(boolean send, long dtime) { + dtime -= this.lastTicked; TagObject tag = new TagObject(); tag.setLong("Seed", this.seed); tag.setLong("Time", this.timeExisted); - tag.setLong("Offset", offset); + if(this.hasOrbit()) + tag.setLong("Orbit", (this.orbit + dtime) % this.orbitalPeriod); + if(this.hasRotation()) + tag.setLong("Rotation", (this.rotation + dtime) % this.rotationPeriod); + tag.setLong("Epoch", this.epoch + dtime); if(this == Space.INSTANCE) return tag; tag.setBool("Exterminated", this.exterminated); @@ -462,7 +498,11 @@ public abstract class Dimension extends Section { public final void readData(TagObject tag) { this.seed = tag.getLong("Seed"); this.timeExisted = tag.getLong("Time"); - this.timeOffset = tag.getLong("Offset"); + if(this.hasOrbit()) + this.orbit = tag.getLong("Orbit"); + if(this.hasRotation()) + this.rotation = tag.getLong("Rotation"); + this.epoch = tag.getLong("Epoch"); if(this == Space.INSTANCE) return; this.exterminated = tag.getBool("Exterminated"); diff --git a/common/src/main/java/common/dimension/Moon.java b/common/src/main/java/common/dimension/Moon.java index 4979f973..7318f4d3 100755 --- a/common/src/main/java/common/dimension/Moon.java +++ b/common/src/main/java/common/dimension/Moon.java @@ -40,7 +40,11 @@ public final class Moon extends Dimension { return true; } - public boolean isCelestial() { + public boolean hasRotation() { + return true; + } + + public boolean hasOrbit() { return true; } } diff --git a/common/src/main/java/common/dimension/Planet.java b/common/src/main/java/common/dimension/Planet.java index 5523d84c..4575b2a0 100755 --- a/common/src/main/java/common/dimension/Planet.java +++ b/common/src/main/java/common/dimension/Planet.java @@ -67,7 +67,11 @@ public final class Planet extends Dimension { return true; } - public boolean isCelestial() { + public boolean hasRotation() { + return true; + } + + public boolean hasOrbit() { return true; } diff --git a/common/src/main/java/common/dimension/Star.java b/common/src/main/java/common/dimension/Star.java index b1057014..495354ef 100755 --- a/common/src/main/java/common/dimension/Star.java +++ b/common/src/main/java/common/dimension/Star.java @@ -23,7 +23,7 @@ public final class Star extends Dimension { return DimType.STAR; } - public boolean isCelestial() { + public boolean hasRotation() { return true; } } diff --git a/common/src/main/java/common/init/BlockRegistry.java b/common/src/main/java/common/init/BlockRegistry.java index f9667c28..6e4e6981 100755 --- a/common/src/main/java/common/init/BlockRegistry.java +++ b/common/src/main/java/common/init/BlockRegistry.java @@ -395,7 +395,7 @@ public abstract class BlockRegistry { for(WoodType wood : WoodType.values()) { register(wood.getName() + "_log", (new BlockLog()).setDisplay(wood.getDisplay() + "holz")); for(LeavesType type : LeavesType.values()) { - register(wood.getName() + "_leaves_" + type.getName(), (new BlockLeaves(wood, type)).setDisplay(wood.getDisplay() + "laub (" + type.getDisplayName() + ")")); + register(wood.getName() + "_leaves_" + type.getName(), (new BlockLeaves(wood, type)).setDisplay(wood.getDisplay() + "laub (" + type.getDisplay() + ")")); } register(wood.getName() + "_sapling", (new BlockSapling(wood)).setHardness(0.0F).setSound(SoundType.GRASS) .setDisplay(wood.getDisplay() + "setzling")); diff --git a/common/src/main/java/common/item/tool/ItemSpaceNavigator.java b/common/src/main/java/common/item/tool/ItemSpaceNavigator.java index 0b543626..ea69cfcf 100755 --- a/common/src/main/java/common/item/tool/ItemSpaceNavigator.java +++ b/common/src/main/java/common/item/tool/ItemSpaceNavigator.java @@ -4,14 +4,18 @@ import java.util.List; import common.entity.npc.EntityNPC; import common.item.Item; +import common.item.ItemControl; import common.item.ItemStack; import common.util.BlockPos; import common.util.Clientside; import common.util.Color; +import common.world.World; public class ItemSpaceNavigator extends Item { @Clientside private String localTime = ""; + @Clientside + private boolean local = true; public ItemSpaceNavigator() { this.setUnstackable(); @@ -26,11 +30,17 @@ public class ItemSpaceNavigator extends Item { public String getLocalTime() { return this.localTime; } + + public boolean onAction(ItemStack stack, EntityNPC player, World world, ItemControl control, BlockPos block) { + if(world.client && control == ItemControl.QUARTERNARY) + this.local ^= true; + return false; + } @Clientside public String getHotbarText(EntityNPC player, ItemStack stack) { BlockPos pos = player.getPosition(); - return Color.ORANGE + this.localTime + " / " + + return Color.ORANGE + (this.local ? this.localTime : player.worldObj.formatEpoch()) + " / " + String.format("%s bei %d, %d, %d", player.worldObj.dimension.getDisplay() + Color.ORANGE, pos.getX(), pos.getY(), pos.getZ()); } @@ -38,6 +48,7 @@ public class ItemSpaceNavigator extends Item { @Clientside public void addInformation(ItemStack stack, EntityNPC player, List tooltip) { tooltip.add(Color.ORANGE + this.localTime); + tooltip.add(Color.ORANGE + player.worldObj.formatEpoch() + " T" + player.worldObj.formatTime()); String[] dims = player.worldObj.dimension.getBaseNames(); for(int z = dims.length - 1; z >= 0; z--) { tooltip.add(Color.ORANGE + dims[z]); diff --git a/common/src/main/java/common/packet/SPacketTimeUpdate.java b/common/src/main/java/common/packet/SPacketTimeUpdate.java index 1ded4725..b53f25c8 100755 --- a/common/src/main/java/common/packet/SPacketTimeUpdate.java +++ b/common/src/main/java/common/packet/SPacketTimeUpdate.java @@ -7,27 +7,31 @@ import common.network.Packet; import common.network.PacketBuffer; public class SPacketTimeUpdate implements Packet { - private long worldTime; + private long orbit; + private long rotation; private String localTime; private String serverInfo; public SPacketTimeUpdate() { } - public SPacketTimeUpdate(long time, String local, String info) { - this.worldTime = time; + public SPacketTimeUpdate(long orbit, long rotation, String local, String info) { + this.orbit = orbit; + this.rotation = rotation; this.localTime = local; this.serverInfo = info; } public void readPacketData(PacketBuffer buf) throws IOException { - this.worldTime = buf.readLong(); + this.orbit = buf.readLong(); + this.rotation = buf.readLong(); this.localTime = buf.readString(64); this.serverInfo = buf.readString(512); } public void writePacketData(PacketBuffer buf) throws IOException { - buf.writeLong(this.worldTime); + buf.writeLong(this.orbit); + buf.writeLong(this.rotation); buf.writeString(this.localTime); buf.writeString(this.serverInfo); } @@ -36,8 +40,12 @@ public class SPacketTimeUpdate implements Packet { handler.handleTimeUpdate(this); } - public long getWorldTime() { - return this.worldTime; + public long getOrbit() { + return this.orbit; + } + + public long getRotation() { + return this.rotation; } public String getLocalTime() { diff --git a/common/src/main/java/common/vars/Vars.java b/common/src/main/java/common/vars/Vars.java index 589862dc..a079fc2e 100755 --- a/common/src/main/java/common/vars/Vars.java +++ b/common/src/main/java/common/vars/Vars.java @@ -193,8 +193,6 @@ public abstract class Vars { public static boolean itemExplosion = true; @Var(name = "signEditing") public static boolean editSigns = true; - @Var(name = "daylightCycle") - public static boolean dayCycle = true; @Var(name = "dropPlayerSkulls") public static boolean skullDrop = true; @@ -267,7 +265,7 @@ public abstract class Vars { public static int maxExplosionIters = 1024; @Var(name = "viewDistance", min = 2, max = 16) public static int distance = 8; - @Var(name = "timeFlow", min = 1) + @Var(name = "timeFlow", min = 0) public static int timeFlow = 1; @Var(name = "torchBurnoutChance") public static int torchBurnout = 30; diff --git a/common/src/main/java/common/world/World.java b/common/src/main/java/common/world/World.java index 5b4c019d..a94ac369 100755 --- a/common/src/main/java/common/world/World.java +++ b/common/src/main/java/common/world/World.java @@ -45,7 +45,6 @@ public abstract class World implements IWorldAccess { public static final float[] MOON_PHASES = new float[] {1.0F, 0.75F, 0.5F, 0.25F, 0.0F, 0.25F, 0.5F, 0.75F}; public static final int MAX_SIZE = 67108864; public static final int MAX_SIZE_Y = 4096; - public static final long START_TIME = 4385238000L; public static final float ABSOLUTE_ZERO = -273.15f; public final boolean client; @@ -71,7 +70,8 @@ public abstract class World implements IWorldAccess { protected float fog; protected float temp; protected Weather weather; - protected long daytime; + protected long orbit; + protected long rotation; public boolean isBlockSolid(BlockPos pos) { return isSolidSurface(this.getState(pos)); @@ -103,7 +103,7 @@ public abstract class World implements IWorldAccess { this.dimension = dim; // this.storage = storage; this.client = client; - this.weather = dim.getCurrentWeather(); + this.weather = dim.getWeather(); } public void updatePhysics() { @@ -801,7 +801,7 @@ public abstract class World implements IWorldAccess { } public int calcSkylightSubtracted(boolean current) { - float f = !this.dimension.hasDaylight() || (current && this.dimension.isBaseDestroyed()) ? 0.5f : this.calcRotationPhase(current ? this.daytime : + float f = !this.dimension.hasDaylight() || (current && this.dimension.isBaseDestroyed()) ? 0.5f : this.calcRotationPhase(current ? this.rotation : (this.dimension.getRotationalPeriod() / 4L), 1.0f); float f1 = 1.0F - (ExtMath.cos(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F); f1 = ExtMath.clampf(f1, 0.0F, 1.0F); @@ -813,12 +813,12 @@ public abstract class World implements IWorldAccess { } public float getCelestialAngle(float partial) { - return !this.dimension.isCelestial() ? 180.0f : (this.calcRotationPhase(this.daytime, Vars.dayCycle ? partial : 0.0f) * 360.0F); + return !this.dimension.hasRotation() ? 180.0f : (this.calcRotationPhase(this.rotation, Vars.timeFlow > 0 ? partial : 0.0f) * 360.0F); } public int getMoonPhase(int moon) { this.rand.setSeed((this.dimension.getSeed() + moon) ^ (moon << 12)); - return (int)(this.daytime / this.dimension.getRotationalPeriod() % 8L + 8L + this.rand.zrange(8)) % 8; + return (int)(this.rotation / this.dimension.getRotationalPeriod() % 8L + 8L + this.rand.zrange(8)) % 8; } public float getMoonPhase() { @@ -826,7 +826,7 @@ public abstract class World implements IWorldAccess { } public float getDayPhase(float partial) { - return !this.dimension.hasDaylight() || this.dimension.isBaseDestroyed() ? (float)Math.PI : (this.calcRotationPhase(this.daytime, Vars.dayCycle ? partial : 0.0f) * (float)Math.PI * 2.0F); + return !this.dimension.hasDaylight() || this.dimension.isBaseDestroyed() ? (float)Math.PI : (this.calcRotationPhase(this.rotation, Vars.timeFlow > 0 ? partial : 0.0f) * (float)Math.PI * 2.0F); } public BlockPos getPrecipitationHeight(BlockPos pos) { @@ -1447,13 +1447,13 @@ public abstract class World implements IWorldAccess { protected float getBaseTemperature() { return this.dimension.getTemperature() + this.dimension.getOrbitOffset() * - ExtMath.sin((((float)(this.daytime % this.dimension.getOrbitalPeriod()) / (float)this.dimension.getOrbitalPeriod()) + ExtMath.sin((((float)(this.orbit % this.dimension.getOrbitalPeriod()) / (float)this.dimension.getOrbitalPeriod()) -0.125f) * (float)Math.PI * 2.0f); } public LeavesType getLeavesType() { - return LeavesType.values()[(int)((this.daytime % - this.dimension.getOrbitalPeriod()) * (long)LeavesType.values().length / this.dimension.getOrbitalPeriod())]; + return LeavesType.values()[(int)((this.orbit % + this.dimension.getOrbitalPeriod()) * 4L / this.dimension.getOrbitalPeriod())]; } public float getTemperatureK(BlockPos pos) { @@ -1787,20 +1787,28 @@ public abstract class World implements IWorldAccess { public void setEntityState(Entity entityIn, byte state) { } + public long getRotation() { + return this.rotation; + } + + public void setRotation(long time) { + this.rotation = time; + } + + public long getOrbit() { + return this.orbit; + } + + public void setOrbit(long time) { + this.orbit = time; + } + public Weather getWeather() { return this.weather; } - public long getDayTime() { - return this.daytime; - } - public void setWeather(Weather weather) { - this.dimension.setCurrentWeather(this.weather = weather); - } - - public void setDayTime(long time) { - this.daytime = time; + this.dimension.setWeather(this.weather = weather); } public float getDarkness() { @@ -1867,7 +1875,7 @@ public abstract class World implements IWorldAccess { public double getSpaceFactor(double x, double y, double z) { if(this.dimension.getType() == DimType.SEMI) return ExtMath.clampd((y - (double)World.MAX_SIZE_Y) / 16384.0, 0.0, 1.0); - else if(!this.dimension.isCelestial()) + else if(!this.dimension.hasRotation()) return 0.0; double r = (double)this.dimension.getSize(); double xm = (Math.abs(x) - r) / 16384.0; @@ -1885,6 +1893,30 @@ public abstract class World implements IWorldAccess { double gravity = this.gravity * (1.0 - this.getSpaceFactor(entity.posX, entity.posY, entity.posZ)); return Math.abs(gravity) < 0.075 ? 0.0 : gravity; } + + public String formatTime() { + return this.dimension.hasOrbit() ? String.format("%03d.%03d", this.rotation / 1000L, this.rotation % 1000L) : "???.???"; + } + + public static String formatEpoch(Dimension dim, long epoch, boolean extended) { + if(dim != null && dim.hasOrbit()) { + long year = epoch / dim.getOrbitalPeriod(); + long frac = (epoch * 1000L / dim.getOrbitalPeriod()) % 1000L; + long day = epoch / dim.getRotationalPeriod(); + return String.format("%03d.%03d.M%d" + (extended ? " D%03d.%03d.G%d" : ""), frac, year % 1000L, year / 1000L + 1L, (day / 1000L) % 1000L, day % 1000L, day / 1000000L); + } + else { + return "???.???.M?" + (extended ? " D???.???.G?" : ""); + } + } + + public String formatEpoch() { + return formatEpoch(this.dimension, this.dimension.getEpoch(), true); + } + + public String formatEpochSimple() { + return formatEpoch(this.dimension, this.dimension.getEpoch(), false); + } public final void playEffect(int type, BlockPos pos, int data) { this.playEffect(null, type, pos, data); diff --git a/server/src/main/java/server/Server.java b/server/src/main/java/server/Server.java index ccbe1192..0dece94e 100755 --- a/server/src/main/java/server/Server.java +++ b/server/src/main/java/server/Server.java @@ -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())); diff --git a/server/src/main/java/server/command/CommandEnvironment.java b/server/src/main/java/server/command/CommandEnvironment.java index c53861e0..989b679e 100644 --- a/server/src/main/java/server/command/CommandEnvironment.java +++ b/server/src/main/java/server/command/CommandEnvironment.java @@ -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()); } diff --git a/server/src/main/java/server/command/commands/CommandEpoch.java b/server/src/main/java/server/command/commands/CommandEpoch.java new file mode 100644 index 00000000..2d5db20c --- /dev/null +++ b/server/src/main/java/server/command/commands/CommandEpoch.java @@ -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; + } +} diff --git a/server/src/main/java/server/command/commands/CommandFreeze.java b/server/src/main/java/server/command/commands/CommandFreeze.java index 5953089a..90f6806a 100644 --- a/server/src/main/java/server/command/commands/CommandFreeze.java +++ b/server/src/main/java/server/command/commands/CommandFreeze.java @@ -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"); } } diff --git a/server/src/main/java/server/command/commands/CommandSeason.java b/server/src/main/java/server/command/commands/CommandSeason.java new file mode 100644 index 00000000..31d5b8a2 --- /dev/null +++ b/server/src/main/java/server/command/commands/CommandSeason.java @@ -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; + } +} diff --git a/server/src/main/java/server/command/commands/CommandTime.java b/server/src/main/java/server/command/commands/CommandTime.java index f028b229..17cbffa6 100644 --- a/server/src/main/java/server/command/commands/CommandTime.java +++ b/server/src/main/java/server/command/commands/CommandTime.java @@ -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; } } diff --git a/server/src/main/java/server/dimension/Dimensions.java b/server/src/main/java/server/dimension/Dimensions.java index d26107c8..be86af28 100644 --- a/server/src/main/java/server/dimension/Dimensions.java +++ b/server/src/main/java/server/dimension/Dimensions.java @@ -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() { diff --git a/server/src/main/java/server/world/WorldServer.java b/server/src/main/java/server/world/WorldServer.java index abaebcd3..510e9ddb 100755 --- a/server/src/main/java/server/world/WorldServer.java +++ b/server/src/main/java/server/world/WorldServer.java @@ -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) {