fix dimension names
This commit is contained in:
parent
d09b9516a8
commit
cad8ff6adb
44 changed files with 147 additions and 140 deletions
|
@ -72,7 +72,7 @@ public class BlockBed extends Block implements Rotatable {
|
|||
&& Math.abs(player.posY - (double)pos.getY()) <= 2.0D && Math.abs(player.posZ - (double)pos.getZ()) <= 3.0D) {
|
||||
player.setSpawnPoint(new WorldPos(pos, player.worldObj));
|
||||
player.connection.addHotbar(TextColor.DGREEN + "Dein Einstiegspunkt wurde auf %s bei [%s, %s, %s] gesetzt",
|
||||
player.worldObj.dimension.getFormattedName(false), player.getSpawnPoint().getX(),
|
||||
player.worldObj.dimension.getNameString(), player.getSpawnPoint().getX(),
|
||||
player.getSpawnPoint().getY(), player.getSpawnPoint().getZ());
|
||||
}
|
||||
// else if(!Config.bedSpawn) {
|
||||
|
|
|
@ -160,7 +160,7 @@ public abstract class Dimension extends Nameable {
|
|||
private SkyboxType skyboxTexture = null;
|
||||
private ColorGenerator starColorFunc = null;
|
||||
private ColorGenerator deepstarColorFunc = null;
|
||||
private String display; // synced only
|
||||
private String[] baseNames; // synced only
|
||||
private int sunColor = 0xffffffff;
|
||||
private int[] moonColors = null;
|
||||
|
||||
|
@ -866,12 +866,38 @@ public abstract class Dimension extends Nameable {
|
|||
return !this.getType().days;
|
||||
}
|
||||
|
||||
public final void setDisplayName(String display) {
|
||||
this.display = display;
|
||||
public final void setBaseNames(String[] names) {
|
||||
this.baseNames = names;
|
||||
}
|
||||
|
||||
public final String getFormattedName(boolean full) {
|
||||
return this.display != null ? (full ? this.display : this.getNameString()) : UniverseRegistry.getFormattedName(this, full);
|
||||
public final String[] getBaseNames() {
|
||||
if(this.baseNames != null)
|
||||
return this.baseNames;
|
||||
String planet = null;
|
||||
String star = null;
|
||||
Dimension dim = this;
|
||||
switch(this.getType()) {
|
||||
case MOON:
|
||||
dim = UniverseRegistry.getPlanet((Moon)dim);
|
||||
planet = dim.getNameString();
|
||||
case PLANET:
|
||||
dim = UniverseRegistry.getStar((Planet)dim);
|
||||
star = dim.getNameString();
|
||||
case STAR:
|
||||
Sector sector = UniverseRegistry.getSector((Star)dim);
|
||||
String sect = sector.getNameString();
|
||||
String galaxy = UniverseRegistry.getGalaxy(sector).getNameString();
|
||||
if(planet != null)
|
||||
return new String[] {planet, star, sect, galaxy};
|
||||
else if(star != null)
|
||||
return new String[] {star, sect, galaxy};
|
||||
else
|
||||
return new String[] {sect, galaxy};
|
||||
case AREA:
|
||||
return new String[] {UniverseRegistry.getDomain((Area)dim).getNameString()};
|
||||
default:
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,12 +21,11 @@ import common.dimension.Semi;
|
|||
import common.dimension.Space;
|
||||
import common.dimension.Star;
|
||||
import common.world.Weather;
|
||||
import common.world.World;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class UniverseRegistry {
|
||||
public static final long EARTH_YEAR = 8766144L;
|
||||
|
||||
private static final List<Dimension> DIMENSIONS = Lists.newArrayList();
|
||||
private static final Map<Integer, Dimension> ID_MAP = Maps.newTreeMap();
|
||||
private static final Map<Dimension, Integer> IDS = new IdentityHashMap();
|
||||
|
@ -123,35 +122,13 @@ public abstract class UniverseRegistry {
|
|||
public static Set<String> getWorldNames() {
|
||||
return NAME_LIST;
|
||||
}
|
||||
|
||||
public static String getFormattedName(Dimension dim, boolean full) {
|
||||
String base = dim.getNameString();
|
||||
if(!full)
|
||||
return base;
|
||||
switch(dim.getType()) {
|
||||
case MOON:
|
||||
dim = MOON_MAP.get(dim);
|
||||
base += " / " + dim.getNameString();
|
||||
case PLANET:
|
||||
dim = PLANET_MAP.get(dim);
|
||||
base += " / " + dim.getNameString();
|
||||
case STAR:
|
||||
Sector sector = STAR_MAP.get(dim);
|
||||
base += " / " + sector.getNameString();
|
||||
return base + " / " + SECTOR_MAP.get(sector).getNameString();
|
||||
case AREA:
|
||||
return base + " / " + AREA_MAP.get(dim).getNameString();
|
||||
default:
|
||||
return base;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isRegistered(String name) {
|
||||
return GALAXIES.containsKey(name) || SECTORS.containsKey(name) || DOMAINS.containsKey(name) || NAME_MAP.containsKey(name);
|
||||
}
|
||||
|
||||
public static boolean isDimension(String name) {
|
||||
return NAME_MAP.containsKey(name);
|
||||
public static boolean isType(String name, DimType type) {
|
||||
return NAME_MAP.containsKey(name) && NAME_MAP.get(name).getType() == type;
|
||||
}
|
||||
|
||||
public static Galaxy registerCustomGalaxy(String name, String display) {
|
||||
|
@ -304,7 +281,7 @@ public abstract class UniverseRegistry {
|
|||
registerGalaxy("milkyway", "Milchstraße");
|
||||
registerSector("solar", "Solar", "milkyway");
|
||||
registerStar("sol", "Sol", new Star(0xff7f00, 274.0f, 5778.0f, Blocks.lava.getState(), 128).setTimeQualifier(1), "solar");
|
||||
registerPlanet("terra", "Terra", new Planet(0xffffffff, 0xc0d8ff, 0xffffff, UniverseRegistry.EARTH_YEAR, 24000L, 28.0f, 9.81f,
|
||||
registerPlanet("terra", "Terra", new Planet(0xffffffff, 0xc0d8ff, 0xffffff, World.EARTH_YEAR, 24000L, 28.0f, 9.81f,
|
||||
259.15f).setTimeQualifier(0)
|
||||
.setPerlinGen(Blocks.stone.getState(), Blocks.water.getState(), 63)
|
||||
.setBiomeReplacer(Blocks.gravel.getState())
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ItemCharTemplate extends Item
|
|||
|
||||
public void addInformation(ItemStack stack, EntityNPC player, List<String> tooltip) {
|
||||
Dimension dim = this.spawned.species.origin == null ? null : UniverseRegistry.getDimension(this.spawned.species.origin);
|
||||
tooltip.add(TextColor.ORANGE + "Herkunft: " + (dim == null ? "???" : dim.getFormattedName(false)));
|
||||
tooltip.add(TextColor.ORANGE + "Herkunft: " + (dim == null ? "???" : dim.getNameString()));
|
||||
}
|
||||
|
||||
public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ)
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ItemMobTemplate extends Item
|
|||
EntityInfo egg = EntityRegistry.DNA.get(this.entityId);
|
||||
if(egg != null) {
|
||||
Dimension dim = egg.origin() == null ? null : UniverseRegistry.getDimension(egg.origin());
|
||||
tooltip.add(TextColor.ORANGE + "Herkunft: " + (dim == null ? "???" : dim.getFormattedName(false)));
|
||||
tooltip.add(TextColor.ORANGE + "Herkunft: " + (dim == null ? "???" : dim.getNameString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ public class ItemExterminator extends ItemMagnetic {
|
|||
if(world.dimension == Space.INSTANCE)
|
||||
player.connection.addHotbar(TextColor.RED + "Der Weltraum kann nicht zerstört werden (lol)");
|
||||
else if(!((AWorldServer)world).exterminate())
|
||||
player.connection.addHotbar(TextColor.YELLOW + "Die Welt %s ist bereits zerstört", world.dimension.getFormattedName(false));
|
||||
player.connection.addHotbar(TextColor.YELLOW + "Die Welt %s ist bereits zerstört", world.dimension.getNameString());
|
||||
else
|
||||
player.connection.addHotbar(TextColor.CRIMSON + "Die Welt %s wurde vernichtet >:)-", world.dimension.getFormattedName(false));
|
||||
player.connection.addHotbar(TextColor.CRIMSON + "Die Welt %s wurde vernichtet >:)-", world.dimension.getNameString());
|
||||
|
||||
// if (!playerIn.capabilities.isCreativeMode)
|
||||
// {
|
||||
|
|
|
@ -16,7 +16,7 @@ public class ItemScanner extends ItemWand {
|
|||
public void onUse(ItemStack stack, EntityNPC player, AWorldServer world, Vec3 vec)
|
||||
{
|
||||
Biome biome = world.getBiomeGenForCoords(new BlockPos(vec.xCoord, 0, vec.zCoord));
|
||||
player.connection.addHotbar(TextColor.NEON + "* Position in %s: %.3f %.3f %.3f, %s, %.2f °C", world.dimension.getFormattedName(false),
|
||||
player.connection.addHotbar(TextColor.NEON + "* Position in %s: %.3f %.3f %.3f, %s, %.2f °C", world.dimension.getNameString(),
|
||||
vec.xCoord, vec.yCoord, vec.zCoord,
|
||||
biome.display, world.getTemperatureC(new BlockPos(vec)));
|
||||
}
|
||||
|
|
|
@ -4,48 +4,31 @@ import java.util.List;
|
|||
|
||||
import common.color.TextColor;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.item.ItemMagnetic;
|
||||
import common.item.ItemStack;
|
||||
import common.util.BlockPos;
|
||||
import common.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 + 1L);
|
||||
}
|
||||
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 + 1L,
|
||||
time / 1000L, time % 1000L, (day / 1000L) % 1000L, day % 1000L, day / 1000000L);
|
||||
}
|
||||
|
||||
public ItemSpaceNavigator() {
|
||||
public ItemSpaceNavigator() {
|
||||
this.setUnstackable();
|
||||
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 bei %d, %d, %d", player.worldObj.dimension.getFormattedName(false) + TextColor.ORANGE,
|
||||
return TextColor.ORANGE + player.worldObj.formatImperialTime(false) + " / " +
|
||||
String.format("%s bei %d, %d, %d", player.worldObj.dimension.getNameString() + TextColor.ORANGE,
|
||||
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 + player.worldObj.formatImperialTime(true));
|
||||
String[] dims = player.worldObj.dimension.getBaseNames();
|
||||
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 bei %d, %d, %d", player.worldObj.dimension.getFormattedName(false)
|
||||
tooltip.add(TextColor.ORANGE + String.format("%s bei %d, %d, %d", player.worldObj.dimension.getNameString()
|
||||
+ TextColor.ORANGE, pos.getX(), pos.getY(), pos.getZ()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
|
||||
public class SPacketDimensionName implements Packet<IClientPlayer> {
|
||||
private String fullName;
|
||||
private String[] fullName;
|
||||
private String customName;
|
||||
|
||||
public SPacketDimensionName() {
|
||||
}
|
||||
|
||||
public SPacketDimensionName(Dimension dim) {
|
||||
this.fullName = dim.getFormattedName(true);
|
||||
this.fullName = dim.getBaseNames();
|
||||
this.customName = dim.getCustomName();
|
||||
}
|
||||
|
||||
|
@ -24,16 +24,22 @@ public class SPacketDimensionName implements Packet<IClientPlayer> {
|
|||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.fullName = buf.readString(4096);
|
||||
this.fullName = new String[buf.readByte()];
|
||||
for(int z = 0; z < this.fullName.length; z++) {
|
||||
this.fullName[z] = buf.readString(1024);
|
||||
}
|
||||
this.customName = buf.readString(1024);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeString(this.fullName);
|
||||
buf.writeByte(this.fullName.length);
|
||||
for(int z = 0; z < this.fullName.length; z++) {
|
||||
buf.writeString(this.fullName[z]);
|
||||
}
|
||||
buf.writeString(this.customName);
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
public String[] getFullName() {
|
||||
return this.fullName;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class SPacketRespawn implements Packet<IClientPlayer> {
|
|||
private TagObject dimData;
|
||||
private String dimName;
|
||||
private String dimDisplay;
|
||||
private String dimFull;
|
||||
private String[] dimFull;
|
||||
private int sunColor;
|
||||
private int[] moonColors;
|
||||
private int type;
|
||||
|
@ -39,7 +39,7 @@ public class SPacketRespawn implements Packet<IClientPlayer> {
|
|||
if(dim.isCustom()) {
|
||||
this.dimName = UniverseRegistry.getName(dim);
|
||||
this.dimDisplay = dim.getCustomName();
|
||||
this.dimFull = dim.getFormattedName(true);
|
||||
this.dimFull = dim.getBaseNames();
|
||||
this.dimId = -1;
|
||||
}
|
||||
else {
|
||||
|
@ -70,7 +70,10 @@ public class SPacketRespawn implements Packet<IClientPlayer> {
|
|||
if(this.dimId == -1) {
|
||||
this.dimName = buf.readString(1024);
|
||||
this.dimDisplay = buf.readString(1024);
|
||||
this.dimFull = buf.readString(4096);
|
||||
this.dimFull = new String[buf.readByte()];
|
||||
for(int z = 0; z < this.dimFull.length; z++) {
|
||||
this.dimFull[z] = buf.readString(1024);
|
||||
}
|
||||
}
|
||||
this.type = buf.readUnsignedShort();
|
||||
this.editor = buf.readBoolean();
|
||||
|
@ -92,7 +95,10 @@ public class SPacketRespawn implements Packet<IClientPlayer> {
|
|||
if(this.dimId == -1) {
|
||||
buf.writeString(this.dimName);
|
||||
buf.writeString(this.dimDisplay);
|
||||
buf.writeString(this.dimFull);
|
||||
buf.writeByte(this.dimFull.length);
|
||||
for(int z = 0; z < this.dimFull.length; z++) {
|
||||
buf.writeString(this.dimFull[z]);
|
||||
}
|
||||
}
|
||||
buf.writeShort(this.type & 65535);
|
||||
buf.writeBoolean(this.editor);
|
||||
|
@ -110,7 +116,7 @@ public class SPacketRespawn implements Packet<IClientPlayer> {
|
|||
if(!dim.isCustom())
|
||||
return dim;
|
||||
dim.setCustomName(this.dimDisplay);
|
||||
dim.setDisplayName(this.dimFull);
|
||||
dim.setBaseNames(this.dimFull);
|
||||
return dim;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ public abstract class Util {
|
|||
public static final boolean DEVMODE = System.getProperty("runtime.devmode") != null;
|
||||
public static final int PROTOCOL = Version.MAJOR << 16 | Version.MINOR << 8 | Version.PATCH;
|
||||
public static final String VERSION = "v" + Version.MAJOR + "." + Version.MINOR + "." + Version.PATCH + Version.RELEASE;
|
||||
|
||||
private static final String[] TIERS = new String[] {"II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"};
|
||||
|
||||
private static boolean crashed;
|
||||
|
|
|
@ -56,6 +56,7 @@ public abstract class World implements IWorldAccess {
|
|||
public static final int MAX_SIZE_Y = 4096;
|
||||
public static final long START_TIME = 4385238000L;
|
||||
public static final float ABSOLUTE_ZERO = -273.15f;
|
||||
public static final long EARTH_YEAR = 8766144L;
|
||||
// private static final Calendar calendar = Calendar.getInstance();
|
||||
// private static long lastUpdate;
|
||||
|
||||
|
@ -132,6 +133,21 @@ public abstract class World implements IWorldAccess {
|
|||
this.gravity = Math.signum(this.gravity) * 0.075;
|
||||
}
|
||||
|
||||
public String formatImperialTime(boolean days) {
|
||||
long time = this.daytime;
|
||||
long year = time / EARTH_YEAR;
|
||||
long frac = (time * 1000L / EARTH_YEAR) % 1000L;
|
||||
if(!this.dimension.getType().time) {
|
||||
return String.format("%d.%03d.%03d.M%d" + (days ? " T???.??? D???.???.G?" : ""), this.dimension.getTimeQualifier(),
|
||||
frac, year % 1000L, year / 1000L + 1L);
|
||||
}
|
||||
long day = time / this.dimension.getRotationalPeriod();
|
||||
time = time % this.dimension.getRotationalPeriod();
|
||||
return String.format("%d.%03d.%03d.M%d" + (days ? " T%03d.%03d D%03d.%03d.G%d" : ""), this.dimension.getTimeQualifier(),
|
||||
frac, year % 1000L, year / 1000L + 1L,
|
||||
time / 1000L, time % 1000L, (day / 1000L) % 1000L, day % 1000L, day / 1000000L);
|
||||
}
|
||||
|
||||
public abstract Biome getBiomeGenForCoords(BlockPos pos);
|
||||
|
||||
public boolean isAirBlock(BlockPos pos) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue