split time into 3 categories
This commit is contained in:
parent
2f9e7ba728
commit
1d19cddcef
21 changed files with 362 additions and 167 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public final class Star extends Dimension {
|
|||
return DimType.STAR;
|
||||
}
|
||||
|
||||
public boolean isCelestial() {
|
||||
public boolean hasRotation() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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<String> 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]);
|
||||
|
|
|
@ -7,27 +7,31 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
|
||||
public class SPacketTimeUpdate implements Packet<IClientPlayer> {
|
||||
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<IClientPlayer> {
|
|||
handler.handleTimeUpdate(this);
|
||||
}
|
||||
|
||||
public long getWorldTime() {
|
||||
return this.worldTime;
|
||||
public long getOrbit() {
|
||||
return this.orbit;
|
||||
}
|
||||
|
||||
public long getRotation() {
|
||||
return this.rotation;
|
||||
}
|
||||
|
||||
public String getLocalTime() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue