49 lines
2.2 KiB
Java
Executable file
49 lines
2.2 KiB
Java
Executable file
package game.item;
|
|
|
|
import java.util.List;
|
|
|
|
import game.color.TextColor;
|
|
import game.entity.npc.EntityNPC;
|
|
import game.init.UniverseRegistry;
|
|
import game.world.BlockPos;
|
|
import game.world.World;
|
|
|
|
public class ItemSpaceNavigator extends ItemMagnetic {
|
|
public static String formatImperialTime(World world, boolean days) {
|
|
long time = world.getDayTime();
|
|
long year = time / UniverseRegistry.EARTH_YEAR;
|
|
long frac = (time * 1000L / UniverseRegistry.EARTH_YEAR) % 1000L;
|
|
if(!world.dimension.getType().time) {
|
|
return String.format("%d.%03d.%03d.M%d" + (days ? " T???.??? D???.???.G?" : ""), world.dimension.getTimeQualifier(),
|
|
frac, year % 1000L, year / 1000L);
|
|
}
|
|
long day = time / world.dimension.getRotationalPeriod();
|
|
time = time % world.dimension.getRotationalPeriod();
|
|
return String.format("%d.%03d.%03d.M%d" + (days ? " T%03d.%03d D%03d.%03d.G%d" : ""), world.dimension.getTimeQualifier(),
|
|
frac, year % 1000L, year / 1000L,
|
|
time / 1000L, time % 1000L, (day / 1000L) % 1000L, day % 1000L, day / 1000000L);
|
|
}
|
|
|
|
public ItemSpaceNavigator() {
|
|
this.setMaxStackSize(1);
|
|
this.setColor(TextColor.DGREEN);
|
|
}
|
|
|
|
public String getHotbarText(EntityNPC player, ItemStack stack) {
|
|
BlockPos pos = player.getPosition();
|
|
return TextColor.ORANGE + formatImperialTime(player.worldObj, false) + " / " +
|
|
String.format("%s (%d) bei %d, %d, %d", player.worldObj.dimension.getFormattedName(false) + TextColor.ORANGE,
|
|
player.worldObj.dimension.getDimensionId(), pos.getX(), pos.getY(), pos.getZ());
|
|
}
|
|
|
|
public void addInformation(ItemStack stack, EntityNPC player, List<String> tooltip) {
|
|
tooltip.add(TextColor.ORANGE + formatImperialTime(player.worldObj, true));
|
|
String[] dims = TextColor.stripCodes(player.worldObj.dimension.getFormattedName(true)).split(" / ");
|
|
for(int z = dims.length - 1; z > 0; z--) {
|
|
tooltip.add(TextColor.ORANGE + dims[z]);
|
|
}
|
|
BlockPos pos = player.getPosition();
|
|
tooltip.add(TextColor.ORANGE + String.format("%s (%d) bei %d, %d, %d", player.worldObj.dimension.getFormattedName(false)
|
|
+ TextColor.ORANGE, player.worldObj.dimension.getDimensionId(), pos.getX(), pos.getY(), pos.getZ()));
|
|
}
|
|
}
|