add relative time

This commit is contained in:
Sen 2025-08-03 16:45:14 +02:00
parent 83082f4f3c
commit 2f9e7ba728
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
7 changed files with 57 additions and 30 deletions

View file

@ -92,6 +92,7 @@ public abstract class Dimension extends Section {
private long seed = 0L;
private boolean exterminated = false;
private long timeExisted = 0L;
private long timeOffset = 0L;
private Weather weather = this.defaultWeather;
protected Dimension(boolean custom) {
@ -113,6 +114,10 @@ public abstract class Dimension extends Section {
this.timeExisted = time;
}
public final void setTimeOffset(long time) {
this.timeOffset = time;
}
public final void setCurrentWeather(Weather weather) {
this.weather = weather;
}
@ -130,6 +135,10 @@ public abstract class Dimension extends Section {
return this.timeExisted;
}
public final long getTimeOffset() {
return this.timeOffset;
}
public final Weather getCurrentWeather() {
return this.weather;
}
@ -435,10 +444,11 @@ public abstract class Dimension extends Section {
return dim;
}
public final TagObject writeData(boolean send) {
public final TagObject writeData(boolean send, long offset) {
TagObject tag = new TagObject();
tag.setLong("Seed", this.seed);
tag.setLong("Time", this.timeExisted);
tag.setLong("Offset", offset);
if(this == Space.INSTANCE)
return tag;
tag.setBool("Exterminated", this.exterminated);
@ -452,6 +462,7 @@ 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 == Space.INSTANCE)
return;
this.exterminated = tag.getBool("Exterminated");

View file

@ -14,8 +14,8 @@ public class SPacketJoinGame extends SPacketRespawn {
}
@Serverside
public SPacketJoinGame(int id, Dimension dim, String name, int type, boolean editor) {
super(dim, name, type, editor);
public SPacketJoinGame(int id, Dimension dim, long time, String name, int type, boolean editor) {
super(dim, time, name, type, editor);
this.entityId = id;
}

View file

@ -27,10 +27,10 @@ public class SPacketRespawn implements Packet<IClientPlayer> {
}
@Serverside
public SPacketRespawn(Dimension dim, String name, int type, boolean editor) {
public SPacketRespawn(Dimension dim, long time, String name, int type, boolean editor) {
if(dim != null) {
this.dimType = dim.getType();
this.dimData = dim.writeData(true);
this.dimData = dim.writeData(true, time);
if(this.dimType == DimType.PLANET || this.dimType == DimType.MOON) {
this.sunColor = dim.getSunColor();
this.moonColors = dim.getMoonColors();