extend dimension system, remove dim ids

This commit is contained in:
Sen 2025-06-29 19:09:47 +02:00
parent a080ed5583
commit f613bd2122
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
46 changed files with 1216 additions and 1283 deletions

View file

@ -498,6 +498,8 @@ public class Client implements IThreadListener {
private boolean waitingForFile;
private boolean refreshing;
public String dimensionName;
public String message;
public int total;
public int progress = -1;
@ -1590,7 +1592,7 @@ public class Client implements IThreadListener {
// SKC.loaded(true);
}
public void setDimensionAndSpawnPlayer(int dimension, int type)
public void setDimensionAndSpawnPlayer(int type)
{
this.world.removeAllEntities();
int i = 0;
@ -1839,9 +1841,9 @@ public class Client implements IThreadListener {
if(this.world.isBlockLoaded(blockpos)) {
ChunkClient chunk = this.world.getChunk(blockpos);
biome = chunk.getBiome(blockpos);
bline = "Biom: " + biome.display + " (" + biome.id + ")" + /* (this.debugHideInfo ? "" : */ (", D: " +
bline = "Biom: " + biome.display + " (" + biome.name + ")" + /* (this.debugHideInfo ? "" : */ (", D: " +
TextColor.stripCodes(this.world.dimension.getFormattedName(false)) +
" (" + this.world.dimension.getDimensionId() + ")");
" (" + (this.dimensionName == null ? UniverseRegistry.getName(this.world.dimension) : this.dimensionName) + ")");
lline = "Licht: " + chunk.getLightSub(blockpos, 0) + " (" + chunk.getLight(LightType.SKY, blockpos) + " Himmel, "
+ chunk.getLight(LightType.BLOCK, blockpos) + " Blöcke, " + String.format(
"%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt), A: "
@ -1850,7 +1852,7 @@ public class Client implements IThreadListener {
else {
bline = "Biom: <?>, D: " +
TextColor.stripCodes(this.world.dimension.getFormattedName(false)) +
" (" + this.world.dimension.getDimensionId() + ")";
" (" + (this.dimensionName == null ? UniverseRegistry.getName(this.world.dimension) : this.dimensionName) + ")";
lline = "Licht: " + String.format(
"%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt, A: "
+ String.format("%.3f", this.world.getCelestialAngle(1.0f));

View file

@ -385,7 +385,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
GuiChar.this.gm.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ..."));
Dimension dim = UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension);
GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText()));
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, dim.getDimensionId()));
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, UniverseRegistry.getId(dim)));
}
}
}, "Charakter erstellen"));
@ -416,7 +416,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
Dimension dim = UniverseRegistry.getDimension(egg.origin());
if(dim != null) {
for(int z = 0; z < UniverseRegistry.getBaseDimensions().size(); z++) {
if(UniverseRegistry.getBaseDimensions().get(z).getDimensionId() == dim.getDimensionId()) {
if(UniverseRegistry.getBaseDimensions().get(z) == dim) {
this.dimension = z;
break;
}

View file

@ -218,6 +218,7 @@ public class ClientPlayer implements IClientPlayer
public void handleJoinGame(SPacketJoinGame packetIn)
{
NetHandler.checkThread(packetIn, this, this.gm);
this.gm.dimensionName = packetIn.getDimName();
this.gm.charEditor = packetIn.isInEditor();
this.gm.controller = new PlayerController(this.gm, this);
this.world = new WorldClient(this.gm, packetIn.getDimension());
@ -1064,10 +1065,9 @@ public class ClientPlayer implements IClientPlayer
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);
this.gm.charEditor = packetIn.isInEditor();
Dimension dim = packetIn.getDimension();
if (dim.getDimensionId() != this.world.dimension.getDimensionId()) // this.gameController.thePlayer.dimension)
{
if(dim != null) {
this.gm.dimensionName = packetIn.getDimName();
this.loaded = false;
// if(dim.getDimensionId() < 0 && this.gameController.thePlayer.dimension >= 0) {
// this.travelSound = "portal.travel";
@ -1082,7 +1082,7 @@ public class ClientPlayer implements IClientPlayer
// this.gameController.displayGuiScreen(GuiSkin.INSTANCE);
// }
this.gm.setDimensionAndSpawnPlayer(dim.getDimensionId(), packetIn.getEntityType());
this.gm.setDimensionAndSpawnPlayer(packetIn.getEntityType());
this.gm.displayGuiScreen(this.gm.charEditor ? GuiChar.INSTANCE : null);
// this.gameController.controller.setCheat(packetIn.getCheat());
}
@ -1928,7 +1928,9 @@ public class ClientPlayer implements IClientPlayer
public void handleDimName(SPacketDimensionName packetIn) {
NetHandler.checkThread(packetIn, this, this.gm, this.world);
this.world.dimension.setFullName(packetIn.getFullName());
this.world.dimension.setCustomName(packetIn.getCustomName());
if(this.world.dimension.isCustom()) {
this.world.dimension.setCustomName(packetIn.getCustomName());
this.world.dimension.setDisplayName(packetIn.getFullName());
}
}
}

View file

@ -70,7 +70,7 @@ public class BlockBed extends Block implements Rotatable {
}
if(player.isEntityAlive() && Math.abs(player.posX - (double)pos.getX()) <= 3.0D
&& 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.dimension.getDimensionId()));
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.getSpawnPoint().getY(), player.getSpawnPoint().getZ());

View file

@ -1,12 +1,12 @@
package common.dimension;
public final class Area extends Dimension {
Area(int id, String name) {
super(id, name);
Area() {
super(true);
}
public Area(int id, String name, int sky, int fog, float temperature, int brightness) {
super(id, name);
public Area(int sky, int fog, float temperature, int brightness) {
super(false);
this.setPhysics(1L, 1L, 0.0f, 10.0f, temperature, brightness);
this.setSkyColor(sky).setFogColor(fog);
}

File diff suppressed because it is too large Load diff

View file

@ -6,9 +6,10 @@ import common.collect.Sets;
public final class Domain extends Nameable implements Comparable<Domain> {
public final String id;
private final Set<Area> areas = Sets.newTreeSet();
private final Set<Area> areas = Sets.newHashSet();
public Domain(String id) {
public Domain(String id, boolean custom) {
super(custom);
this.id = id;
}
@ -23,8 +24,4 @@ public final class Domain extends Nameable implements Comparable<Domain> {
protected String getNameIdentifier() {
return "%s";
}
protected String getIdentifier() {
return this.id;
}
}

View file

@ -8,7 +8,8 @@ public final class Galaxy extends Nameable implements Comparable<Galaxy> {
public final String id;
private final Set<Sector> sectors = Sets.newTreeSet();
public Galaxy(String id) {
public Galaxy(String id, boolean custom) {
super(custom);
this.id = id;
}
@ -23,8 +24,4 @@ public final class Galaxy extends Nameable implements Comparable<Galaxy> {
protected String getNameIdentifier() {
return "Galaxie %s";
}
protected String getIdentifier() {
return this.id;
}
}

View file

@ -1,12 +1,12 @@
package common.dimension;
public final class Moon extends Dimension {
Moon(int id, String name) {
super(id, name);
Moon() {
super(true);
}
public Moon(int id, String name, int sky, int fog, long orbit, long rotation, float gravity, float temperature, int brightness) {
super(id, name);
public Moon(int sky, int fog, long orbit, long rotation, float gravity, float temperature, int brightness) {
super(false);
this.setPhysics(orbit, rotation, 0.0f, gravity, temperature, brightness);
this.setTimeQualifier(7);
this.setStarBrightness(0.75f).setDeepStarBrightness(0.75f);

View file

@ -1,35 +1,31 @@
package common.dimension;
import common.tags.TagObject;
public abstract class Nameable {
protected String customName = null;
private final boolean custom;
private String display = null;
protected Nameable(boolean custom) {
this.custom = custom;
}
public final String getCustomName() {
return this.customName;
return this.display;
}
public final void setCustomName(String name) {
this.customName = name;
this.display = name;
}
public void readTags(TagObject tag) {
this.customName = tag.hasString("CustomName") ? tag.getString("CustomName") : null;
}
public void writeTags(TagObject tag) {
if(this.customName != null)
tag.setString("CustomName", this.customName);
}
public final boolean isCustom() {
return this.custom;
}
protected abstract String getNameIdentifier();
protected abstract String getIdentifier();
public final String getNameString() {
return this.customName != null && !this.customName.isEmpty()
? (this.customName.startsWith("'") && this.customName.endsWith("'") && this.customName.length() > 2
? this.customName.substring(1, this.customName.length() - 1) :
String.format(this.getNameIdentifier(), this.customName)) :
String.format(this.getNameIdentifier(), this.getIdentifier());
return this.display.startsWith("'") && this.display.endsWith("'") && this.display.length() > 2
? this.display.substring(1, this.display.length() - 1) :
String.format(this.getNameIdentifier(), this.display);
}
}

View file

@ -5,29 +5,29 @@ import java.util.Set;
import common.collect.Sets;
public final class Planet extends Dimension {
private final Set<Moon> moons = Sets.newTreeSet();
private final Set<Moon> moons = Sets.newHashSet();
Planet(int id, String name) {
super(id, name);
Planet() {
super(true);
}
public Planet(int id, String name, int sky, int fog, int clouds, long orbit, long rotation, float gravity, float temperature,
public Planet(int sky, int fog, int clouds, long orbit, long rotation, float gravity, float temperature,
int brightness) {
this(id, name, sky, fog, clouds, orbit, rotation, 0.0f, gravity, temperature, brightness);
this(sky, fog, clouds, orbit, rotation, 0.0f, gravity, temperature, brightness);
}
public Planet(int id, String name, int sky, int fog, int clouds, long orbit, long rotation, float offset, float gravity,
public Planet(int sky, int fog, int clouds, long orbit, long rotation, float offset, float gravity,
float temperature) {
this(id, name, sky, fog, clouds, orbit, rotation, offset, gravity, temperature, 0);
this(sky, fog, clouds, orbit, rotation, offset, gravity, temperature, 0);
}
public Planet(int id, String name, int sky, int fog, int clouds, long orbit, long rotation, float gravity, float temperature) {
this(id, name, sky, fog, clouds, orbit, rotation, 0.0f, gravity, temperature, 0);
public Planet(int sky, int fog, int clouds, long orbit, long rotation, float gravity, float temperature) {
this(sky, fog, clouds, orbit, rotation, 0.0f, gravity, temperature, 0);
}
public Planet(int id, String name, int sky, int fog, int clouds, long orbit, long rotation, float offset, float gravity,
public Planet(int sky, int fog, int clouds, long orbit, long rotation, float offset, float gravity,
float temperature, int brightness) {
super(id, name);
super(false);
this.setPhysics(orbit, rotation, offset, gravity, temperature, brightness);
this.setTimeQualifier(7);
this.setStarBrightness(0.5f).setDeepStarBrightness(0.0f);

View file

@ -6,9 +6,10 @@ import common.collect.Sets;
public final class Sector extends Nameable implements Comparable<Sector> {
public final String id;
private final Set<Star> stars = Sets.newTreeSet();
private final Set<Star> stars = Sets.newHashSet();
public Sector(String id) {
public Sector(String id, boolean custom) {
super(custom);
this.id = id;
}
@ -23,8 +24,4 @@ public final class Sector extends Nameable implements Comparable<Sector> {
protected String getNameIdentifier() {
return "Sektor %s";
}
protected String getIdentifier() {
return this.id;
}
}

View file

@ -1,12 +1,12 @@
package common.dimension;
public final class Semi extends Dimension {
Semi(int id, String name) {
super(id, name);
Semi() {
super(true);
}
public Semi(int id, String name, int sky, int fog, int clouds, float temperature, int brightness) {
super(id, name);
public Semi(int sky, int fog, int clouds, float temperature, int brightness) {
super(false);
this.setPhysics(1L, 1L, 0.0f, 10.0f, temperature, brightness);
this.setStarBrightness(0.5f).setDeepStarBrightness(0.5f);
this.setSkyColor(sky).setFogColor(fog).setCloudColor(clouds);

View file

@ -6,10 +6,9 @@ public final class Space extends Dimension {
public static final Space INSTANCE = new Space();
private Space() {
super(0, "space");
super(false);
this.setPhysics(1L, 1L, 0.0f, 0.0f, 2.7f, 15).setTimeQualifier(8);
this.setBiome(Biome.SPACE).setStarBrightness(1.0f).setDeepStarBrightness(1.0f);
this.setCustomName("Der Weltraum");
}
public final DimType getType() {

View file

@ -6,14 +6,14 @@ import common.collect.Sets;
import common.world.State;
public final class Star extends Dimension {
private final Set<Planet> planets = Sets.newTreeSet();
private final Set<Planet> planets = Sets.newHashSet();
Star(int id, String name) {
super(id, name);
Star() {
super(true);
}
public Star(int id, String name, int color, float gravity, float temp, State surface, int height) {
super(id, name);
public Star(int color, float gravity, float temp, State surface, int height) {
super(false);
this.setPhysics(1L, 1L, 0.0f, gravity, temp, 15);
this.setTimeQualifier(7);
this.setStarBrightness(0.75f).setDeepStarBrightness(0.75f);

View file

@ -11,6 +11,7 @@ import common.block.artificial.BlockWall;
import common.block.liquid.BlockLiquid;
import common.color.TextColor;
import common.dimension.DimType;
import common.dimension.Dimension;
import common.enchantment.Enchantment;
import common.enchantment.EnchantmentHelper;
import common.entity.effect.EntityLightning;
@ -268,8 +269,8 @@ public abstract class Entity
protected void checkPortal() {
if(this.inPortal != null) {
if(this.vehicle == null && this.passenger == null && Vars.portals) {
int current = this.worldObj.dimension.getDimensionId();
int dest = UniverseRegistry.getPortalDest(current, this.inPortal);
Dimension current = this.worldObj.dimension;
Dimension dest = UniverseRegistry.getPortalDest(current, this.inPortal);
if(dest != current) {
this.travelToDimension(dest, null, 0.0f, 0.0f, this.inPortal);
this.inPortal = null;
@ -357,8 +358,8 @@ public abstract class Entity
protected void onVoidUpdate() {
if(!this.worldObj.client && this.worldObj.dimension.getType() != DimType.SPACE) {
// this.worldObj.profiler.start("descent");
int current = this.worldObj.dimension.getDimensionId();
int dim = Vars.voidPortal ? UniverseRegistry.getPortalDest(current, PortalType.VOID) : current;
Dimension current = this.worldObj.dimension;
Dimension dim = Vars.voidPortal ? UniverseRegistry.getPortalDest(current, PortalType.VOID) : current;
if(dim == current) { // && (!(this.isPlayer()) || !((EntityNPCMP)this).creative)) {
this.kill();
}
@ -1804,17 +1805,23 @@ public abstract class Entity
return (double)this.height * 0.75D;
}
public void teleport(double x, double y, double z, float yaw, float pitch, int dimension) {
public void teleport(double x, double y, double z, float yaw, float pitch, Dimension dimension) {
if(dimension == null)
return;
x = ExtMath.clampd(x, -World.MAX_SIZE + 1, World.MAX_SIZE - 1);
z = ExtMath.clampd(z, -World.MAX_SIZE + 1, World.MAX_SIZE - 1);
this.unmount();
Entity entity = this;
if(this.worldObj.dimension.getDimensionId() != dimension) {
if(this.worldObj.dimension != dimension) {
entity = this.travelToDimension(dimension, new BlockPos(x, y, z), yaw, pitch, null);
}
entity.setLocationAndAngles(x, y, z, yaw, pitch);
entity.setRotationYawHead(yaw);
}
public final void teleport(double x, double y, double z, float yaw, float pitch, World world) {
this.teleport(x, y, z, yaw, pitch, world.dimension);
}
// protected void setY(double y) {
// this.unmount();
@ -1823,13 +1830,17 @@ public abstract class Entity
// }
public final void teleport(Position pos) {
this.teleport(pos.x(), pos.y(), pos.z(), pos.yaw(), pos.pitch(), pos.dim());
this.teleport(pos.x(), pos.y(), pos.z(), pos.yaw(), pos.pitch(), pos.getDimension());
}
public final void teleport(BlockPos pos, int dim) {
public final void teleport(BlockPos pos, Dimension dim) {
this.teleport(((double)pos.getX()) + 0.5, (double)pos.getY(), ((double)pos.getZ()) + 0.5, this.rotYaw, this.rotPitch, dim);
}
public final void teleport(BlockPos pos, World world) {
this.teleport(pos, world.dimension);
}
// public final Position getLocation() {
// return new Position(this);
// }
@ -2329,7 +2340,7 @@ public abstract class Entity
/**
* Teleports the entity to another dimension. Params: Dimension number to teleport to
*/
public Entity travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
{
if (!this.worldObj.client && !this.dead)
{
@ -2619,7 +2630,7 @@ public abstract class Entity
}
public Position getPos() {
return new Position(this.posX, this.posY, this.posZ, this.rotYaw, this.rotPitch, this.worldObj.dimension.getDimensionId());
return new Position(this.posX, this.posY, this.posZ, this.rotYaw, this.rotPitch, this.worldObj);
}
public abstract EntityType getType();

View file

@ -1,6 +1,7 @@
package common.entity.item;
import common.collect.Lists;
import common.dimension.Dimension;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
@ -166,7 +167,7 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
/**
* Teleports the entity to another dimension. Params: Dimension number to teleport to
*/
public Entity travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
{
this.dropContentsWhenDead = false;
return super.travelToDimension(dimensionId, pos, yaw, pitch, portal);

View file

@ -2,6 +2,7 @@ package common.entity.item;
import common.block.Material;
import common.color.TextColor;
import common.dimension.Dimension;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.EntityType;
@ -477,7 +478,7 @@ public class EntityItem extends Entity
/**
* Teleports the entity to another dimension. Params: Dimension number to teleport to
*/
public Entity travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
{
Entity entity = super.travelToDimension(dimensionId, pos, yaw, pitch, portal);

View file

@ -2,6 +2,7 @@ package common.entity.item;
import common.block.Material;
import common.color.TextColor;
import common.dimension.Dimension;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.EntityType;
@ -196,7 +197,7 @@ public class EntityXp extends Entity implements IObjectData
}
}
public Entity travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
{
Entity entity = super.travelToDimension(dimensionId, pos, yaw, pitch, portal);

View file

@ -24,6 +24,7 @@ import common.block.Block;
import common.block.artificial.BlockBed;
import common.collect.Lists;
import common.color.TextColor;
import common.dimension.Dimension;
import common.dimension.Space;
import common.enchantment.Enchantment;
import common.enchantment.EnchantmentHelper;
@ -48,6 +49,7 @@ import common.init.NameRegistry;
import common.init.SoundEvent;
import common.init.SpeciesRegistry;
import common.init.TradeRegistry;
import common.init.UniverseRegistry;
import common.init.SpeciesRegistry.ModelType;
import common.inventory.Container;
import common.inventory.ContainerPlayer;
@ -206,7 +208,7 @@ public abstract class EntityNPC extends EntityLiving
public double chasingPosX;
public double chasingPosY;
public double chasingPosZ;
private WorldPos originPos = new WorldPos(0, 64, 0, Space.INSTANCE.getDimensionId());
private WorldPos originPos = new WorldPos(0, 64, 0, Space.INSTANCE);
private WorldPos spawnPos;
public int experienceLevel;
public int experienceTotal;
@ -2891,13 +2893,13 @@ public abstract class EntityNPC extends EntityLiving
}
}
public Entity travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal) {
public Entity travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal) {
if(this.connection != null)
this.connection.travelToDimension(dimensionId, pos, yaw, pitch, portal);
return this.isPlayer() ? this : super.travelToDimension(dimensionId, pos, yaw, pitch, portal);
}
public void teleport(double x, double y, double z, float yaw, float pitch, int dimension) {
public void teleport(double x, double y, double z, float yaw, float pitch, Dimension dimension) {
if(this.connection != null)
this.connection.teleport(x, y, z, yaw, pitch, dimension);
else if(!this.isPlayer())
@ -3458,17 +3460,19 @@ public abstract class EntityNPC extends EntityLiving
// this.wakeUpPlayer();
// }
if (tagCompund.hasInt("SpawnX") && tagCompund.hasInt("SpawnY") && tagCompund.hasInt("SpawnZ"))
if (tagCompund.hasInt("SpawnX") && tagCompund.hasInt("SpawnY") && tagCompund.hasInt("SpawnZ") && tagCompund.hasString("SpawnDim"))
{
this.spawnPos = new WorldPos(tagCompund.getInt("SpawnX"), tagCompund.getInt("SpawnY"),
tagCompund.getInt("SpawnZ"), tagCompund.getInt("SpawnDim"));
Dimension dim = UniverseRegistry.getDimension(tagCompund.getString("SpawnDim"));
this.spawnPos = dim == null ? null : new WorldPos(tagCompund.getInt("SpawnX"), tagCompund.getInt("SpawnY"),
tagCompund.getInt("SpawnZ"), dim);
// this.spawnForced = tagCompund.getBoolean("SpawnForced");
}
if (tagCompund.hasInt("OriginX") && tagCompund.hasInt("OriginY") && tagCompund.hasInt("OriginZ"))
if (tagCompund.hasInt("OriginX") && tagCompund.hasInt("OriginY") && tagCompund.hasInt("OriginZ") && tagCompund.hasString("OriginDim"))
{
this.originPos = new WorldPos(tagCompund.getInt("OriginX"), tagCompund.getInt("OriginY"),
tagCompund.getInt("OriginZ"), tagCompund.getInt("OriginDim"));
Dimension dim = UniverseRegistry.getDimension(tagCompund.getString("OriginDim"));
this.originPos = dim == null ? new WorldPos(0, 64, 0, Space.INSTANCE) : new WorldPos(tagCompund.getInt("OriginX"), tagCompund.getInt("OriginY"),
tagCompund.getInt("OriginZ"), dim);
}
// this.foodStats.readNBT(tagCompund);
@ -3572,19 +3576,25 @@ public abstract class EntityNPC extends EntityLiving
if (this.spawnPos != null)
{
tagCompound.setInt("SpawnX", this.spawnPos.getX());
tagCompound.setInt("SpawnY", this.spawnPos.getY());
tagCompound.setInt("SpawnZ", this.spawnPos.getZ());
tagCompound.setInt("SpawnDim", this.spawnPos.getDimension());
Dimension dim = this.spawnPos.getDimension();
if(dim != null) {
tagCompound.setInt("SpawnX", this.spawnPos.getX());
tagCompound.setInt("SpawnY", this.spawnPos.getY());
tagCompound.setInt("SpawnZ", this.spawnPos.getZ());
tagCompound.setString("SpawnDim", UniverseRegistry.getName(dim));
}
// tagCompound.setBoolean("SpawnForced", this.spawnForced);
}
if (this.originPos != null)
{
tagCompound.setInt("OriginX", this.originPos.getX());
tagCompound.setInt("OriginY", this.originPos.getY());
tagCompound.setInt("OriginZ", this.originPos.getZ());
tagCompound.setInt("OriginDim", this.originPos.getDimension());
Dimension dim = this.originPos.getDimension();
if(dim != null) {
tagCompound.setInt("OriginX", this.originPos.getX());
tagCompound.setInt("OriginY", this.originPos.getY());
tagCompound.setInt("OriginZ", this.originPos.getZ());
tagCompound.setString("OriginDim", UniverseRegistry.getName(dim));
}
}
// this.foodStats.writeNBT(tagCompound);

File diff suppressed because it is too large Load diff

View file

@ -16,9 +16,9 @@ public class ItemInfoWand 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 bei Level %d: %.3f %.3f %.3f, %s [%d], %.2f °C", world.dimension.getDimensionId(),
player.connection.addHotbar(TextColor.NEON + "* Position in %s: %.3f %.3f %.3f, %s, %.2f °C", world.dimension.getFormattedName(false),
vec.xCoord, vec.yCoord, vec.zCoord,
biome.display, biome.id, world.getTemperatureC(new BlockPos(vec)));
biome.display, world.getTemperatureC(new BlockPos(vec)));
}
public int getRange(ItemStack stack, EntityNPC player) {

View file

@ -34,8 +34,8 @@ public class ItemSpaceNavigator extends ItemMagnetic {
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());
String.format("%s bei %d, %d, %d", player.worldObj.dimension.getFormattedName(false) + TextColor.ORANGE,
pos.getX(), pos.getY(), pos.getZ());
}
public void addInformation(ItemStack stack, EntityNPC player, List<String> tooltip) {
@ -45,7 +45,7 @@ public class ItemSpaceNavigator extends ItemMagnetic {
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()));
tooltip.add(TextColor.ORANGE + String.format("%s bei %d, %d, %d", player.worldObj.dimension.getFormattedName(false)
+ TextColor.ORANGE, pos.getX(), pos.getY(), pos.getZ()));
}
}

View file

@ -2,6 +2,7 @@ package common.network;
import java.util.List;
import common.dimension.Dimension;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
@ -76,8 +77,8 @@ public interface IPlayer extends NetHandler {
void addHotbar(String format, Object... args);
void sendThrowMessage(ItemStack stack);
void resetLastExperience();
void travelToDimension(int dimension, BlockPos pos, float yaw, float pitch, PortalType portal);
void teleport(double x, double y, double z, float yaw, float pitch, int dimension);
void travelToDimension(Dimension dimension, BlockPos pos, float yaw, float pitch, PortalType portal);
void teleport(double x, double y, double z, float yaw, float pitch, Dimension dimension);
void onItemPickup(Entity entity, int amount);
void mountEntity(Entity entity);
void openEditSign(TileEntitySign signTile);

View file

@ -16,8 +16,7 @@ public class SPacketDimensionName implements Packet<IClientPlayer> {
public SPacketDimensionName(Dimension dim) {
this.fullName = dim.getFormattedName(true);
this.customName = dim.getCustomName() != null && dim.getCustomName().length() > 64 ? dim.getCustomName().substring(0, 64) :
dim.getCustomName();
this.customName = dim.getCustomName();
}
public void processPacket(IClientPlayer handler) {
@ -25,14 +24,13 @@ public class SPacketDimensionName implements Packet<IClientPlayer> {
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.fullName = buf.readString(64);
this.customName = buf.readString(64);
this.customName = this.customName.isEmpty() ? null : this.customName;
this.fullName = buf.readString(4096);
this.customName = buf.readString(1024);
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeString(this.fullName);
buf.writeString(this.customName == null ? "" : this.customName);
buf.writeString(this.customName);
}
public String getFullName() {

View file

@ -4,38 +4,27 @@ import java.io.IOException;
import common.dimension.Dimension;
import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
import common.tags.TagObject;
public class SPacketJoinGame implements Packet<IClientPlayer> {
public class SPacketJoinGame extends SPacketRespawn {
private int entityId;
private TagObject dimension;
private int type;
private boolean editor;
public SPacketJoinGame() {
}
public SPacketJoinGame(int entityIdIn, Dimension dimensionIn, int type, boolean editor) {
this.entityId = entityIdIn;
this.dimension = dimensionIn.toTags(false);
this.type = type;
this.editor = editor;
public SPacketJoinGame(int id, Dimension dim, int type, boolean editor) {
super(dim, type, editor);
this.entityId = id;
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.entityId = buf.readInt();
this.dimension = buf.readTag();
this.type = buf.readUnsignedShort();
this.editor = buf.readBoolean();
super.readPacketData(buf);
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeInt(this.entityId);
buf.writeTag(this.dimension);
buf.writeShort(this.type & 65535);
buf.writeBoolean(this.editor);
super.writePacketData(buf);
}
public void processPacket(IClientPlayer handler) {
@ -45,16 +34,4 @@ public class SPacketJoinGame implements Packet<IClientPlayer> {
public int getEntityId() {
return this.entityId;
}
public Dimension getDimension() {
return Dimension.getByTag(this.dimension, false);
}
public int getEntityType() {
return this.type;
}
public boolean isInEditor() {
return this.editor;
}
}

View file

@ -2,59 +2,107 @@ package common.packet;
import java.io.IOException;
import common.dimension.DimType;
import common.dimension.Dimension;
import common.init.UniverseRegistry;
import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
import common.tags.TagObject;
public class SPacketRespawn implements Packet<IClientPlayer>
{
private TagObject dimension;
private int type;
private boolean editor;
public class SPacketRespawn implements Packet<IClientPlayer> {
private int dimId;
private long seed;
private DimType dimType;
private TagObject dimData;
private String dimName;
private String dimDisplay;
private String dimFull;
private int type;
private boolean editor;
public SPacketRespawn()
{
}
public SPacketRespawn() {
}
public SPacketRespawn(Dimension dimensionIn, int type, boolean editor)
{
this.dimension = dimensionIn.toTags(false);
this.type = type;
public SPacketRespawn(Dimension dim, int type, boolean editor) {
if(dim == null) {
this.dimId = -2;
}
else {
this.seed = dim.getSeed();
if(dim.isCustom()) {
this.dimType = dim.getType();
this.dimData = new TagObject();
dim.toTags(this.dimData);
this.dimName = UniverseRegistry.getName(dim);
this.dimDisplay = dim.getCustomName();
this.dimFull = dim.getFormattedName(true);
this.dimId = -1;
}
else {
this.dimId = UniverseRegistry.getId(dim);
}
}
this.type = type;
this.editor = editor;
}
public void processPacket(IClientPlayer handler)
{
handler.handleRespawn(this);
}
public void readPacketData(PacketBuffer buf) throws IOException
{
this.dimension = buf.readTag();
this.type = buf.readUnsignedShort();
this.editor = buf.readBoolean();
}
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeTag(this.dimension);
buf.writeShort(this.type & 65535);
buf.writeBoolean(this.editor);
}
}
public Dimension getDimension()
{
return Dimension.getByTag(this.dimension, false);
}
public void processPacket(IClientPlayer handler) {
handler.handleRespawn(this);
}
public int getEntityType()
{
return this.type;
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.dimId = buf.readVarInt();
if(this.dimId >= -1)
this.seed = buf.readLong();
if(this.dimId == -1) {
this.dimType = buf.readEnumValue(DimType.class);
this.dimData = buf.readTag();
this.dimName = buf.readString(1024);
this.dimDisplay = buf.readString(1024);
this.dimFull = buf.readString(4096);
}
this.type = buf.readUnsignedShort();
this.editor = buf.readBoolean();
}
public boolean isInEditor() {
return this.editor;
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeVarInt(this.dimId);
if(this.dimId >= -1)
buf.writeLong(this.seed);
if(this.dimId == -1) {
buf.writeEnumValue(this.dimType);
buf.writeTag(this.dimData);
buf.writeString(this.dimName);
buf.writeString(this.dimDisplay);
buf.writeString(this.dimFull);
}
buf.writeShort(this.type & 65535);
buf.writeBoolean(this.editor);
}
public Dimension getDimension() {
if(this.dimId < -1)
return null;
Dimension dim = this.dimId >= 0 ? UniverseRegistry.getDimension(this.dimId) : Dimension.create(this.dimType);
dim.setSeed(this.seed);
if(!dim.isCustom())
return dim;
dim.fromTags(this.dimData);
dim.setCustomName(this.dimDisplay);
dim.setDisplayName(this.dimFull);
return dim;
}
public String getDimName() {
return this.dimName;
}
public int getEntityType() {
return this.type;
}
public boolean isInEditor() {
return this.editor;
}
}

View file

@ -1,4 +1,71 @@
package common.util;
public record Position(double x, double y, double z, float yaw, float pitch, int dim) {
import common.dimension.Dimension;
import common.init.UniverseRegistry;
import common.world.World;
public class Position extends Vec3 {
private final float yaw;
private final float pitch;
private final int dim;
private Position(double x, double y, double z, float yaw, float pitch, int dim) {
super(x, y, z);
this.yaw = yaw;
this.pitch = pitch;
this.dim = dim;
}
public Position(double x, double y, double z, float yaw, float pitch, Dimension dim) {
this(x, y, z, yaw, pitch, UniverseRegistry.getId(dim));
}
public Position(double x, double y, double z, float yaw, float pitch, World world) {
this(x, y, z, yaw, pitch, UniverseRegistry.getId(world.dimension));
}
public double x() {
return this.xCoord;
}
public double y() {
return this.yCoord;
}
public double z() {
return this.zCoord;
}
public float yaw() {
return this.yaw;
}
public float pitch() {
return this.pitch;
}
public Dimension getDimension() {
return UniverseRegistry.getDimension(this.dim);
}
public boolean isValid() {
return this.getDimension() != null;
}
public boolean equals(Object obj) {
if(this == obj) {
return true;
}
else if(!(obj instanceof Position)) {
return false;
}
else {
Position pos = (Position)obj;
return this.xCoord == pos.xCoord && this.yCoord == pos.yCoord && this.zCoord == pos.zCoord && this.yaw == pos.yaw && this.pitch == pos.pitch && this.dim == pos.dim;
}
}
public String toString() {
return "(" + this.getDimension() + ", " + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + ", " + this.yaw + ", " + this.pitch + ")";
}
}

View file

@ -0,0 +1,4 @@
package common.util;
public record Quartet<A, B, C, D>(A first, B second, C third, D fourth) {
}

View file

@ -1,19 +1,35 @@
package common.util;
import common.dimension.Dimension;
import common.init.UniverseRegistry;
import common.world.World;
public class WorldPos extends BlockPos {
private final int dim;
public WorldPos(int x, int y, int z, int dim) {
private WorldPos(int x, int y, int z, int dim) {
super(x, y, z);
this.dim = dim;
}
public WorldPos(BlockPos pos, int dim) {
this(pos.getX(), pos.getY(), pos.getZ(), dim);
public WorldPos(int x, int y, int z, Dimension dim) {
this(x, y, z, UniverseRegistry.getId(dim));
}
public WorldPos(int x, int y, int z, World world) {
this(x, y, z, UniverseRegistry.getId(world.dimension));
}
public WorldPos(BlockPos pos, Dimension dim) {
this(pos.getX(), pos.getY(), pos.getZ(), UniverseRegistry.getId(dim));
}
public WorldPos(BlockPos pos, World world) {
this(pos.getX(), pos.getY(), pos.getZ(), UniverseRegistry.getId(world.dimension));
}
public int getDimension() {
return this.dim;
public Dimension getDimension() {
return UniverseRegistry.getDimension(this.dim);
}
public boolean equals(Object obj) {
@ -34,6 +50,6 @@ public class WorldPos extends BlockPos {
}
public String toString() {
return this.dim + ";" + this.getX() + ";" + this.getY() + ";" + this.getZ();
return "" + this.getDimension() + ";" + this.getX() + ";" + this.getY() + ";" + this.getZ();
}
}

View file

@ -22,7 +22,7 @@ public abstract class AWorldServer extends World {
}
public abstract List<IPlayer> getAllPlayers();
public abstract AWorldServer getOtherWorld(int dimension);
public abstract AWorldServer getOtherWorld(Dimension dimension);
public abstract void placeInDimension(Entity entity, AWorldServer oldWorld, AWorldServer world, BlockPos pos, PortalType portal);
public abstract boolean addLoader(BlockPos pos);
public abstract boolean removeLoader(BlockPos pos);

View file

@ -247,7 +247,6 @@ public final class Server implements IThreadListener, Executor {
for(SVar svar : this.variables.values()) {
svar.set(svar.def, svar.noDef, false);
}
UniverseRegistry.clear();
}
}
Log.IO.info("Erstelle neue Welt und Konfiguration");
@ -374,8 +373,8 @@ public final class Server implements IThreadListener, Executor {
double posZ = tag.getDouble("PosZ");
float rotYaw = tag.getFloat("Yaw");
float rotPitch = tag.getFloat("Pitch");
int dimension = tag.getInt("Dimension");
return new Position(posX, posY, posZ, rotYaw, rotPitch, dimension);
Dimension dimension = UniverseRegistry.getDimension(tag.getString("Dimension"));
return dimension == null ? null : new Position(posX, posY, posZ, rotYaw, rotPitch, dimension);
}
public void saveAllWorlds(boolean message) {
@ -393,12 +392,12 @@ public final class Server implements IThreadListener, Executor {
}
private void unloadWorld(Dimension dim) {
WorldServer world = this.dimensions.get(dim.getDimensionId());
WorldServer world = this.dimensions.get(UniverseRegistry.getId(dim));
if(world != null && world.players.isEmpty()) {
world.saveAllChunks();
Region.finishWrite();
this.worlds.remove(world);
this.dimensions.remove(dim.getDimensionId());
this.dimensions.remove(UniverseRegistry.getId(dim));
}
}
@ -411,12 +410,12 @@ public final class Server implements IThreadListener, Executor {
}
User.loadDatabase(this.users);
this.worlds.add(this.space = new WorldServer(this, wtime, Space.INSTANCE));
this.dimensions.put(this.space.dimension.getDimensionId(), this.space);
this.dimensions.put(UniverseRegistry.getId(this.space.dimension), this.space);
new File("players").mkdirs();
this.setTpsTarget(20.0f);
for(Dimension dim : UniverseRegistry.getDimensions()) {
if(WorldServer.needsLoading(dim)) {
this.getWorld(dim.getDimensionId()).loadForcedChunks();
this.getWorld(dim).loadForcedChunks();
}
WorldServer.loadWarps(dim, this.warps);
}
@ -570,26 +569,25 @@ public final class Server implements IThreadListener, Executor {
return this.space;
}
public WorldServer getWorld(int dimension) {
WorldServer world = this.dimensions.get(dimension);
public WorldServer getWorld(Dimension dim) {
if(dim == null)
return null;
WorldServer world = this.dimensions.get(UniverseRegistry.getId(dim));
if(world == null) {
Dimension dim = UniverseRegistry.getDimension(dimension);
if(dim == null)
return null;
world = new WorldServer(this, this.space.getDayTime(), dim);
this.worlds.add(world);
this.dimensions.put(dimension, world);
this.dimensions.put(UniverseRegistry.getId(dim), world);
}
return world;
}
public WorldServer getWorldNoLoad(int dimension) {
return this.dimensions.get(dimension);
public WorldServer getWorldNoLoad(Dimension dim) {
return dim == null ? null : this.dimensions.get(UniverseRegistry.getId(dim));
}
public WorldServer getWorld(String alias) {
Dimension dim = UniverseRegistry.getDimension(alias);
return dim == null ? null : this.getWorld(dim.getDimensionId());
return dim == null ? null : this.getWorld(dim);
}
public List<WorldServer> getWorlds() {
@ -698,7 +696,7 @@ public final class Server implements IThreadListener, Executor {
int y = pos.getY();
while(world.getState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock().getMaterial().blocksMovement() && y < 511)
y++;
return new Position(pos.getX() + 0.5, (double)y, pos.getZ() + 0.5, -180.0f + world.rand.floatv() * 360.0f, 0.0f, world.dimension.getDimensionId());
return new Position(pos.getX() + 0.5, (double)y, pos.getZ() + 0.5, -180.0f + world.rand.floatv() * 360.0f, 0.0f, world);
}
public void addUser(User user) {
@ -727,7 +725,7 @@ public final class Server implements IThreadListener, Executor {
this.online.put(loginUser, conn);
tag = conn.readCharacter();
WorldServer world = tag == null ? this.space : this.getWorld(tag.getInt("Dimension"));
WorldServer world = tag == null ? this.space : this.getWorld(tag.getString("Dimension"));
world = world == null ? this.space : world;
EntityNPC player = conn.createPlayer(world, tag == null ? EntityRegistry.getEntityString(EntityHuman.class) : tag.getString("id"));
if(tag != null)
@ -738,7 +736,7 @@ public final class Server implements IThreadListener, Executor {
player.moveToBlockPosAndAngles(new BlockPos(0, 16384, 0), 0.0f, 0.0f);
Log.NETWORK.info(loginUser + "[" + connection.getCutAddress() + "] hat sich mit Objekt-ID "
+ player.getId() + " auf Level " + world.dimension.getDimensionId() + ": "
+ player.getId() + " auf " + UniverseRegistry.getName(world.dimension) + ": "
+ String.format("%.2f %.2f %.2f", player.posX, player.posY, player.posZ) + " verbunden (" + (tag == null ? "Charakter-Editor" : "'" + player.getCommandName() + "'") + ")");
conn.sendPacket(new SPacketJoinGame(player.getId(), world.dimension, EntityRegistry.getEntityID(player), tag == null));
@ -811,7 +809,7 @@ public final class Server implements IThreadListener, Executor {
if(entity != null) {
TagObject etag = new TagObject();
entity.writeTags(etag);
etag.setInt("Dimension", entity.worldObj.dimension.getDimensionId());
etag.setString("Dimension", UniverseRegistry.getName(entity.worldObj.dimension));
etag.setString("id", EntityRegistry.getEntityString(entity));
conn.writeCharacter(etag);
}
@ -878,7 +876,7 @@ public final class Server implements IThreadListener, Executor {
nplayer.setPosition(nplayer.posX, nplayer.posY + 1.0D, nplayer.posZ);
}
}
conn.sendPacket(new SPacketRespawn(world.dimension, EntityRegistry.getEntityID(nplayer), conn.isInEditor()));
conn.sendPacket(new SPacketRespawn(world.dimension != oldWorld.dimension ? 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);
@ -898,7 +896,7 @@ public final class Server implements IThreadListener, Executor {
old.unmount();
TagObject oldTag = new TagObject();
old.writeTags(oldTag);
oldTag.setInt("Dimension", old.worldObj.dimension.getDimensionId());
oldTag.setString("Dimension", UniverseRegistry.getName(old.worldObj.dimension));
oldTag.setString("id", EntityRegistry.getEntityString(old));
WorldServer oldWorld = (WorldServer)old.getServerWorld();
@ -907,7 +905,7 @@ public final class Server implements IThreadListener, Executor {
oldWorld.removePlayer(old);
oldWorld.removePlayerEntityDangerously(old);
WorldServer world = tag == null ? this.space : this.getWorld(tag.getInt("Dimension"));
WorldServer world = tag == null ? this.space : this.getWorld(tag.getString("Dimension"));
world = world == null ? this.space : world;
EntityNPC nplayer = conn.createPlayer(world, tag == null ? EntityRegistry.getEntityString(clazz) : tag.getString("id"));
if(tag != null)
@ -920,7 +918,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, EntityRegistry.getEntityID(nplayer), conn.isInEditor()));
conn.sendPacket(new SPacketRespawn(world.dimension != oldWorld.dimension ? 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));
@ -935,7 +933,7 @@ public final class Server implements IThreadListener, Executor {
return oldTag;
}
public void transferToDimension(EntityNPC player, int dimension, BlockPos pos, float yaw, float pitch, PortalType portal) {
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, EntityRegistry.getEntityID(player), player.connection.isInEditor()));
@ -998,32 +996,6 @@ public final class Server implements IThreadListener, Executor {
}
}
public void sendPacket(Packet packet, int dimension) {
for(Player conn : this.players) {
if(conn.getEntity() != null && conn.getEntity().worldObj.dimension.getDimensionId() == dimension) {
conn.sendPacket(packet);
}
}
}
public void sendNear(double x, double y, double z, double radius, int dimension, Packet packet) {
this.sendNearExcept(null, x, y, z, radius, dimension, packet);
}
public void sendNearExcept(EntityNPC except, double x, double y, double z, double radius, int dimension, Packet packet) {
for(Player conn : this.players) {
EntityNPC player = conn.getEntity();
if(player != null && player != except && player.worldObj.dimension.getDimensionId() == dimension) {
double dx = x - player.posX;
double dy = y - player.posY;
double dz = z - player.posZ;
if(dx * dx + dy * dy + dz * dz < radius * radius) {
conn.sendPacket(packet);
}
}
}
}
public void saveAllPlayerData(boolean message) {
if(message) {
Log.TICK.info("Speichere Spielerdaten");

View file

@ -16,15 +16,6 @@ public class DimensionParser extends CompletingParser {
public Object parse(CommandEnvironment env, String input) {
Dimension dim = UniverseRegistry.getDimension(input);
if(dim != null)
return dim;
int id = Integer.MIN_VALUE;
try {
id = Integer.parseInt(input);
}
catch(NumberFormatException e) {
}
dim = UniverseRegistry.getDimension(id);
if(dim == null)
throw new RunException("Unbekannte Dimension '%s'", input);
return dim;
@ -34,7 +25,7 @@ public class DimensionParser extends CompletingParser {
if(!this.useSender)
return null;
Position pos = env.getExecutor().getExecPos();
return pos == null ? null : UniverseRegistry.getDimension(pos.dim());
return pos == null ? null : pos.getDimension();
// if(dim == null)
// throw new ScriptException("Unbekannte Dimension '%s'");
}

View file

@ -5,6 +5,7 @@ import java.util.List;
import common.collect.Lists;
import common.dimension.Dimension;
import common.init.UniverseRegistry;
import server.world.WorldServer;
public class WorldParser extends DimensionParser {
@ -17,7 +18,7 @@ public class WorldParser extends DimensionParser {
public WorldServer parse(CommandEnvironment env, String input) {
Dimension dim = (Dimension)super.parse(env, input);
WorldServer world = this.loadedOnly ? env.getServer().getWorldNoLoad(dim.getDimensionId()) : env.getServer().getWorld(dim.getDimensionId());
WorldServer world = this.loadedOnly ? env.getServer().getWorldNoLoad(dim) : env.getServer().getWorld(dim);
if(world == null)
throw new RunException("Dimension '%s' ist nicht geladen", dim.getFormattedName(false));
return world;
@ -27,7 +28,7 @@ public class WorldParser extends DimensionParser {
Dimension dim = (Dimension)super.getDefault(env);
if(dim == null)
return null;
return this.loadedOnly ? env.getServer().getWorldNoLoad(dim.getDimensionId()) : env.getServer().getWorld(dim.getDimensionId());
return this.loadedOnly ? env.getServer().getWorldNoLoad(dim) : env.getServer().getWorld(dim);
// if(world == null)
// throw new ScriptException("Dimension '%s' ist nicht geladen", dim.getFormattedName(false));
// return world;
@ -37,7 +38,7 @@ public class WorldParser extends DimensionParser {
if(this.loadedOnly) {
List<String> loaded = Lists.newArrayList();
for(WorldServer world : env.getServer().getWorlds()) {
loaded.add(world.dimension.getDimensionName());
loaded.add(UniverseRegistry.getName(world.dimension));
}
return loaded;
}

View file

@ -4,7 +4,6 @@ import java.util.List;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.init.UniverseRegistry;
import common.util.Position;
import server.command.Command;
import server.command.CommandEnvironment;
@ -28,7 +27,7 @@ public class CommandDeathspot extends Command {
throw new RunException("%s hat keinen letzten Todespunkt", player.getCommandName());
for(Entity entity : entities) {
entity.teleport(pos);
exec.log("%s zum Todespunkt von %s (%d, %d, %d in %s) teleportiert", entity.getCommandName(), player.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false));
exec.log("%s zum Todespunkt von %s (%d, %d, %d in %s) teleportiert", entity.getCommandName(), player.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getFormattedName(false));
}
return entities.size();
}

View file

@ -53,7 +53,7 @@ public class CommandLoad extends Command {
long orbit, long rotation, double offset, double gravity, double temperature, int brightness) {
if(teleport && !exec.isPlayer())
throw new RunException("Nur Spieler können teleportiert werden");
if(UniverseRegistry.getDimension(name) != null)
if(UniverseRegistry.isRegistered(name))
throw new RunException("Dimension '%s' existiert bereits", name);
if(name.equals(this.loadingDim))
throw new RunException("Dimension '%s' wird gerade geladen", name);
@ -76,7 +76,7 @@ public class CommandLoad extends Command {
if(teleport && pos != null) {
Player player = env.getServer().getPlayer(((Player)exec).getUser());
if(player != null && player.getPresentEntity() != null)
player.getPresentEntity().teleport(CommandWorld.adjust(env.getServer().getWorld(planet.getDimensionId()), pos), planet.getDimensionId());
player.getPresentEntity().teleport(CommandWorld.adjust(env.getServer().getWorld(planet), pos), planet);
}
})) == null) {
this.loadingDim = null;
@ -91,6 +91,6 @@ public class CommandLoad extends Command {
planet.setBiome(biome);
exec.log(TextColor.GREEN + "Dimension '%s' wurde registriert", display);
if(teleport && ((Player)exec).getPresentEntity() != null)
((Player)exec).getPresentEntity().teleport(CommandWorld.adjust(env.getServer().getWorld(planet.getDimensionId()), ((Player)exec).getPresentEntity().getPosition()), planet.getDimensionId());
((Player)exec).getPresentEntity().teleport(CommandWorld.adjust(env.getServer().getWorld(planet), ((Player)exec).getPresentEntity().getPosition()), planet);
}
}

View file

@ -4,7 +4,6 @@ import java.util.Collection;
import java.util.List;
import common.entity.Entity;
import common.init.UniverseRegistry;
import common.util.Position;
import server.command.Command;
import server.command.CommandEnvironment;
@ -34,7 +33,7 @@ public class CommandOfflinetp extends Command {
throw new RunException("Spieler '%s' konnte nicht gefunden werden", user);
for(Entity entity : entities) {
entity.teleport(pos);
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false));
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getFormattedName(false));
}
return entities.size();
}

View file

@ -3,7 +3,6 @@ package server.command.commands;
import java.util.List;
import common.entity.npc.EntityNPC;
import common.init.UniverseRegistry;
import common.util.Position;
import server.command.Command;
import server.command.CommandEnvironment;
@ -24,7 +23,7 @@ public class CommandReturn extends Command {
Position pos = ((Player)player.connection).getLastTeleport();
if(pos != null) {
player.teleport(pos);
exec.log("%s zum letzten Punkt (%d, %d, %d in %s) teleportiert", player.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false));
exec.log("%s zum letzten Punkt (%d, %d, %d in %s) teleportiert", player.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getFormattedName(false));
done++;
}
}

View file

@ -26,7 +26,7 @@ public class CommandTele extends Command {
public Object exec(CommandEnvironment env, Executor exec, Vec3 position, Dimension dim, Double yaw, Double pitch, List<Entity> entities) {
for(Entity entity : entities) {
entity.teleport(position.xCoord, position.yCoord, position.zCoord, yaw == null ? entity.rotYaw : yaw.floatValue(), pitch == null ? entity.rotPitch : pitch.floatValue(), dim.getDimensionId());
entity.teleport(position.xCoord, position.yCoord, position.zCoord, yaw == null ? entity.rotYaw : yaw.floatValue(), pitch == null ? entity.rotPitch : pitch.floatValue(), dim);
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)position.xCoord, (int)position.yCoord, (int)position.zCoord, dim.getFormattedName(false));
}
return entities.size();

View file

@ -70,7 +70,7 @@ public class CommandTime extends Command {
public Object exec(CommandEnvironment env, Executor exec, String timeStr, boolean absolute) {
Position pos = exec.getExecPos();
WorldServer world = pos == null ? env.getServer().getSpace() : env.getServer().getWorld(pos.dim());
WorldServer world = pos == null ? env.getServer().getSpace() : env.getServer().getWorld(pos.getDimension());
long time = absolute ? 0L : world.getDayTime();
long fwd = parseDayTime(world.dimension, timeStr);
if(fwd >= 0L) {

View file

@ -3,7 +3,6 @@ package server.command.commands;
import java.util.List;
import common.entity.Entity;
import common.init.UniverseRegistry;
import common.util.Position;
import server.command.Command;
import server.command.CommandEnvironment;
@ -23,7 +22,7 @@ public class CommandTp extends Command {
Position pos = target.getPos();
for(Entity entity : entities) {
entity.teleport(pos);
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false));
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getFormattedName(false));
}
return entities.size();
}

View file

@ -4,7 +4,6 @@ import java.util.Collection;
import java.util.List;
import common.entity.Entity;
import common.init.UniverseRegistry;
import common.util.Position;
import server.command.Command;
import server.command.CommandEnvironment;
@ -43,12 +42,12 @@ public class CommandWarp extends Command {
pos = env.getServer().getWarps().get(warp);
if(pos == null)
throw new RunException("Warp '%s' existiert nicht", warp);
else if(env.getServer().getWorld(pos.dim()) == null)
throw new RunException("Warp '%s' hat kein Level (%s)", warp, pos.dim());
else if(pos.getDimension() == null)
throw new RunException("Warp '%s' hat keine Dimension", warp);
// }
for(Entity entity : entities) {
entity.teleport(pos);
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false));
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getFormattedName(false));
}
return entities.size();
}

View file

@ -22,7 +22,7 @@ public class CommandWorld extends Command {
public Object exec(CommandEnvironment env, Executor exec, WorldServer world, List<Entity> entities) {
for(Entity entity : entities) {
BlockPos pos = adjust(world, entity.getPosition());
entity.teleport(pos, world.dimension.getDimensionId());
entity.teleport(pos, world);
exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), world.dimension.getFormattedName(false));
}
return entities.size();

View file

@ -628,21 +628,21 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.lastExperience = -1;
}
public void travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
public void travelToDimension(Dimension dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal)
{
this.server.transferToDimension(this.entity, dimensionId, pos, yaw, pitch, portal);
this.lastExperience = -1;
this.lastHealth = -1.0F;
}
public void teleport(double x, double y, double z, float yaw, float pitch, int dimension) {
public void teleport(double x, double y, double z, float yaw, float pitch, Dimension dimension) {
this.teleportPos = this.entity.getPos();
x = ExtMath.clampd(x, -World.MAX_SIZE + 1, World.MAX_SIZE - 1);
z = ExtMath.clampd(z, -World.MAX_SIZE + 1, World.MAX_SIZE - 1);
// this.setLastTeleport(this.getLocation());
this.entity.unmount();
// this.mountEntity(null);
if(this.entity.worldObj.dimension.getDimensionId() != dimension)
if(this.entity.worldObj.dimension != dimension)
this.travelToDimension(dimension, new BlockPos(x, y, z), yaw, pitch, null);
this.setPlayerLocation(x, y, z, yaw, pitch);
this.entity.setRotationYawHead(yaw);
@ -816,7 +816,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
public void playSound(SoundEvent name, float volume)
{
this.server.sendNearExcept(this.entity, this.entity.posX, this.entity.posY, this.entity.posZ, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, this.entity.worldObj.dimension.getDimensionId(), new SPacketSoundEffect(name, this.entity.posX, this.entity.posY, this.entity.posZ, volume));
this.getEntityWorld().sendNearExcept(this.entity, this.entity.posX, this.entity.posY, this.entity.posZ, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, new SPacketSoundEffect(name, this.entity.posX, this.entity.posY, this.entity.posZ, volume));
}
@ -1362,8 +1362,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer
}
private String selectPoint(BlockPos position, boolean second) {
if(this.selectionDim == Integer.MIN_VALUE || this.selectionDim != this.entity.worldObj.dimension.getDimensionId()) {
this.selectionDim = this.entity.worldObj.dimension.getDimensionId();
if(this.selectionDim == Integer.MIN_VALUE || this.selectionDim != UniverseRegistry.getId(this.entity.worldObj.dimension)) {
this.selectionDim = UniverseRegistry.getId(this.entity.worldObj.dimension);
this.selPos1 = null;
this.selPos2 = null;
}
@ -1390,13 +1390,16 @@ public class Player extends User implements ICrafting, Executor, IPlayer
msg += String.format("; Zwischenablage: %dx%dx%d (%d)", nx, ny, nz, nx * ny * nz);
}
if(this.edit == EditAction.SELECT && this.selectionDim != Integer.MIN_VALUE && (this.selPos1 != null || this.selPos2 != null)) {
msg += "; Bereich Level " + this.selectionDim + ": ";
msg += (this.selPos1 != null ? this.selPos1 : "*") + " -> " + (this.selPos2 != null ? this.selPos2 : "*");
if(this.selPos1 != null && this.selPos2 != null) {
msg += " = " + (1 + Math.max(this.selPos1.getX(), this.selPos2.getX()) - Math.min(this.selPos1.getX(), this.selPos2.getX())) +
"x" + (1 + Math.max(this.selPos1.getY(), this.selPos2.getY()) - Math.min(this.selPos1.getY(), this.selPos2.getY())) +
"x" + (1 + Math.max(this.selPos1.getZ(), this.selPos2.getZ()) - Math.min(this.selPos1.getZ(), this.selPos2.getZ())) + " (" + this.getSelectionArea() + ")";
}
Dimension dim = UniverseRegistry.getDimension(this.selectionDim);
if(dim != null) {
msg += "; Bereich " + dim.getFormattedName(false) + ": ";
msg += (this.selPos1 != null ? this.selPos1 : "*") + " -> " + (this.selPos2 != null ? this.selPos2 : "*");
if(this.selPos1 != null && this.selPos2 != null) {
msg += " = " + (1 + Math.max(this.selPos1.getX(), this.selPos2.getX()) - Math.min(this.selPos1.getX(), this.selPos2.getX())) +
"x" + (1 + Math.max(this.selPos1.getY(), this.selPos2.getY()) - Math.min(this.selPos1.getY(), this.selPos2.getY())) +
"x" + (1 + Math.max(this.selPos1.getZ(), this.selPos2.getZ()) - Math.min(this.selPos1.getZ(), this.selPos2.getZ())) + " (" + this.getSelectionArea() + ")";
}
}
}
if(this.edit == EditAction.TRANSFORM && (this.rotation != 0 || this.flipX || this.flipZ))
msg += "; " + this.getRotationInfo();
@ -1487,7 +1490,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
}
private boolean copyClipboard() {
if(this.selectionDim == Integer.MIN_VALUE || this.selectionDim != this.entity.worldObj.dimension.getDimensionId() ||
if(this.selectionDim == Integer.MIN_VALUE || this.selectionDim != UniverseRegistry.getId(this.entity.worldObj.dimension) ||
this.selPos1 == null || this.selPos2 == null)
return false;
WorldServer source = this.getEntityWorld();
@ -1591,7 +1594,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
if(info != null && info.isEmpty())
info = null;
Alignment align = Alignment.getByName(tag.getString("Align"));
Dimension dimension = UniverseRegistry.getDimension(tag.getInt("Dimension"));
Dimension dimension = UniverseRegistry.getDimension(tag.getString("Dimension"));
String dim = dimension == null ? "???" : dimension.getFormattedName(false);
BlockPos pos = new BlockPos(tag.getDouble("PosX"), tag.getDouble("PosY"), tag.getDouble("PosZ"));
String type = EntityRegistry.getEntityName(tag.getString("id"));
@ -2452,10 +2455,9 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.charEditor = false;
this.selected = this.characters.size();
this.characters.add(new TagObject());
WorldServer world = this.server.getWorld(packetIn.getAuxData());
WorldServer world = this.server.getWorld(UniverseRegistry.getDimension(packetIn.getAuxData()));
world = world == null ? this.server.getSpace() : world;
WorldPos origin = new WorldPos(world.rand.range(-SVars.originRadius, SVars.originRadius), 64, world.rand.range(-SVars.originRadius, SVars.originRadius),
world.dimension.getDimensionId());
WorldPos origin = new WorldPos(world.rand.range(-SVars.originRadius, SVars.originRadius), 64, world.rand.range(-SVars.originRadius, SVars.originRadius), world);
this.entity.setOrigin(origin);
Position pos = this.server.getRandomSpawnPosition(origin);
this.entity.teleport(pos);
@ -2757,7 +2759,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
});
for(Entity entity : list) {
entity.teleport(this.entity.posX, this.entity.posY, this.entity.posZ,
this.entity.rotYaw, this.entity.rotPitch, this.entity.worldObj.dimension.getDimensionId());
this.entity.rotYaw, this.entity.rotPitch, this.entity.worldObj);
}
}
break;
@ -3065,11 +3067,11 @@ public class Player extends User implements ICrafting, Executor, IPlayer
}
public Position getLastTeleport() {
return this.teleportPos;
return this.teleportPos != null && this.teleportPos.isValid() ? this.teleportPos : null;
}
public Position getLastDeath() {
return this.deathPos;
return this.deathPos != null && this.deathPos.isValid() ? this.deathPos : null;
}
public String getEntityName() {

View file

@ -10,14 +10,12 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
import common.biome.Biome;
import common.block.Block;
import common.block.artificial.BlockBed;
import common.block.artificial.BlockBed.EnumPartType;
@ -1837,9 +1835,6 @@ public abstract class Converter {
}
}
ntag.setList("Sections", sections);
byte[] biomes = new byte[256];
Arrays.fill(biomes, (byte)(Biome.DEF_BIOME.id & 255));
ntag.setByteArray("Biomes", biomes);
}
else {
ntag.setIntArray("HeightMap", tag.getIntArray("HeightMap"));

View file

@ -183,6 +183,32 @@ public final class WorldServer extends AWorldServer {
public static float clampGravity() {
return ExtMath.clampf(SVars.gravity, -10.0f, 10.0f);
}
public void sendPacket(Packet packet) {
for(Player conn : this.server.getPlayers()) {
if(conn.getEntity() != null && conn.getEntity().worldObj == this) {
conn.sendPacket(packet);
}
}
}
public void sendNear(double x, double y, double z, double radius, Packet packet) {
this.sendNearExcept(null, x, y, z, radius, packet);
}
public void sendNearExcept(EntityNPC except, double x, double y, double z, double radius, Packet packet) {
for(Player conn : this.server.getPlayers()) {
EntityNPC player = conn.getEntity();
if(player != null && player != except && player.worldObj == this) {
double dx = x - player.posX;
double dy = y - player.posY;
double dz = z - player.posZ;
if(dx * dx + dy * dy + dz * dz < radius * radius) {
conn.sendPacket(packet);
}
}
}
}
private BiomeGenerator createBiomeGenerator(Random rand) {
return this.dimension.getBiomeSize() > 0 ? new BiomeGenLayered(rand.longv(), this.dimension.getDefaultBiome(), this.dimension.isSemiFixed(), this.dimension.getBiomeSize(), this.dimension.getRiverSize(),
@ -289,10 +315,10 @@ public final class WorldServer extends AWorldServer {
// this.time = time;
this.daytime = dtime;
this.updateViewRadius();
this.chunkDir = new File(new File("chunk"), dim.getDimensionName());
this.chunkDir = new File(new File("chunk"), UniverseRegistry.getName(dim));
this.chunkDir.mkdirs();
if(!SVars.seed.isEmpty())
this.rand.setSeed((long)SVars.seed.hashCode() ^ ~((long)dim.getDimensionName().hashCode()));
this.rand.setSeed((long)SVars.seed.hashCode() ^ ~((long)UniverseRegistry.getName(dim).hashCode()));
this.seed = this.rand.longv();
this.dimension.setSeed(this.seed);
TagObject tag = null;
@ -308,7 +334,7 @@ public final class WorldServer extends AWorldServer {
this.exterminated = tag.getBool("Exterminated");
this.time = tag.getLong("Time");
if(tag.hasObject("Generator")) {
this.dimension.fromTags(tag.getObject("Generator"));
this.dimension.readGenerator(tag.getObject("Generator"));
if(this.dimension.getType().weather && !this.exterminated)
this.weather = this.dimension.getWeather();
this.seed = this.dimension.getSeed();
@ -871,7 +897,7 @@ public final class WorldServer extends AWorldServer {
public static boolean needsLoading(Dimension dim) {
TagObject tag = null;
try {
File dat = new File(new File(new File("chunk"), dim.getDimensionName()), "loaders.cdt");
File dat = new File(new File(new File("chunk"), UniverseRegistry.getName(dim)), "loaders.cdt");
if(dat.exists() && dat.isFile())
tag = TagObject.readGZip(dat);
}
@ -884,7 +910,7 @@ public final class WorldServer extends AWorldServer {
public static void loadWarps(Dimension dim, Map<String, Position> warps) {
TagObject tag = null;
try {
File dat = new File(new File(new File("chunk"), dim.getDimensionName()), "warps.cdt");
File dat = new File(new File(new File("chunk"), UniverseRegistry.getName(dim)), "warps.cdt");
if(dat.exists() && dat.isFile())
tag = TagObject.readGZip(dat);
}
@ -897,7 +923,7 @@ public final class WorldServer extends AWorldServer {
for(int z = 0; z < list.size(); z++) {
TagObject pos = list.get(z);
warps.put(pos.getString("Name"), new Position(pos.getDouble("X"), pos.getDouble("Y"), pos.getDouble("Z"),
pos.getFloat("Yaw"), pos.getFloat("Pitch"), dim.getDimensionId()));
pos.getFloat("Yaw"), pos.getFloat("Pitch"), dim));
}
}
}
@ -905,11 +931,12 @@ public final class WorldServer extends AWorldServer {
public static void saveWarps(Map<String, Position> warps) {
Map<Integer, List<TagObject>> map = Maps.newHashMap();
for(Entry<String, Position> pos : warps.entrySet()) {
Dimension dim = UniverseRegistry.getDimension(pos.getValue().dim());
Dimension dim = pos.getValue().getDimension();
if(dim != null) {
List<TagObject> list = map.get(pos.getValue().dim());
int id = UniverseRegistry.getId(dim);
List<TagObject> list = map.get(id);
if(list == null)
map.put(pos.getValue().dim(), list = Lists.newArrayList());
map.put(id, list = Lists.newArrayList());
TagObject warp = new TagObject();
warp.setString("Name", pos.getKey());
warp.setDouble("X", pos.getValue().x());
@ -921,8 +948,8 @@ public final class WorldServer extends AWorldServer {
}
}
for(Dimension dim : UniverseRegistry.getDimensions()) {
List<TagObject> list = map.get(dim.getDimensionId());
File file = new File(new File(new File("chunk"), dim.getDimensionName()), "warps.cdt");
List<TagObject> list = map.get(UniverseRegistry.getId(dim));
File file = new File(new File(new File("chunk"), UniverseRegistry.getName(dim)), "warps.cdt");
if(list == null) {
file.delete();
}
@ -1000,7 +1027,7 @@ public final class WorldServer extends AWorldServer {
// this.dataModified = false;
TagObject data = new TagObject();
// data.setLong("Seed", this.seed);
data.setObject("Generator", this.dimension.toTags(true));
data.setObject("Generator", this.dimension.writeGenerator());
data.setLong("Time", this.time);
data.setBool("Exterminated", this.exterminated);
data.setString("Weather", this.weather.getName());
@ -1072,7 +1099,7 @@ public final class WorldServer extends AWorldServer {
public void strikeLightning(double x, double y, double z, int color, int damage, boolean fire, EntityLiving summoner) {
EntityLightning entity = new EntityLightning(this, x, y, z, color, damage, fire, summoner);
this.effects.add(entity);
this.server.sendNear(entity.posX, entity.posY, entity.posZ, 512.0D, this.dimension.getDimensionId(),
this.sendNear(entity.posX, entity.posY, entity.posZ, 512.0D,
new SPacketSpawnGlobalEntity(entity, 1, entity.color));
if(fire && SVars.fire) {
BlockPos pos = new BlockPos(entity);
@ -1130,8 +1157,8 @@ public final class WorldServer extends AWorldServer {
for(TickEvent blockeventdata : this.queue[i]) {
if(this.fireBlockEvent(blockeventdata)) {
this.server.sendNear((double)blockeventdata.position().getX(), (double)blockeventdata.position().getY(),
(double)blockeventdata.position().getZ(), 64.0D, this.dimension.getDimensionId(),
this.sendNear((double)blockeventdata.position().getX(), (double)blockeventdata.position().getY(),
(double)blockeventdata.position().getZ(), 64.0D,
new SPacketBlockAction(blockeventdata.position(), blockeventdata.block(), blockeventdata.id(),
blockeventdata.parameter()));
}
@ -1156,8 +1183,8 @@ public final class WorldServer extends AWorldServer {
public void setWeather(Weather weather) {
this.weather = weather;
// this.dataModified = true;
this.server.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.SET_WEATHER,
weather.getID()), this.dimension.getDimensionId());
this.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.SET_WEATHER,
weather.getID()));
}
protected void updateWeather(boolean force) {
@ -1228,15 +1255,15 @@ public final class WorldServer extends AWorldServer {
}
if(prevRain != this.rain || force) {
this.server.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.RAIN_STRENGTH, this.rain), this.dimension.getDimensionId());
this.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.RAIN_STRENGTH, this.rain));
}
if(prevDarkness != this.darkness || force) {
this.server.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.DARKNESS, this.darkness), this.dimension.getDimensionId());
this.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.DARKNESS, this.darkness));
}
if(prevFog != this.fog || force) {
this.server.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.FOG_STRENGTH, this.fog), this.dimension.getDimensionId());
this.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.FOG_STRENGTH, this.fog));
}
}
@ -1252,7 +1279,7 @@ public final class WorldServer extends AWorldServer {
}
if(prevTemp != this.temp || force) {
this.server.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.TEMPERATURE, this.temp), this.dimension.getDimensionId());
this.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.TEMPERATURE, this.temp));
}
}
@ -1612,7 +1639,7 @@ public final class WorldServer extends AWorldServer {
this.loaderList.clear();
for(Iterator<Entry<String, Position>> iter = this.server.getWarps().entrySet().iterator(); iter.hasNext();) {
Entry<String, Position> pos = iter.next();
if(pos.getValue().dim() == this.dimension.getDimensionId())
if(pos.getValue().getDimension() == this.dimension)
iter.remove();
}
Region.finishWrite();
@ -1752,7 +1779,7 @@ public final class WorldServer extends AWorldServer {
public void playSound(SoundEvent sound, double x, double y, double z, float volume)
{
this.server.sendNear(x, y, z, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, this.dimension.getDimensionId(), new SPacketSoundEffect(sound, x, y, z, volume));
this.sendNear(x, y, z, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, new SPacketSoundEffect(sound, x, y, z, volume));
}
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2)
@ -1765,7 +1792,7 @@ public final class WorldServer extends AWorldServer {
public void playAuxSFX(EntityNPC player, int sfxType, BlockPos blockPosIn, int data)
{
this.server.sendNearExcept(player, (double)blockPosIn.getX(), (double)blockPosIn.getY(), (double)blockPosIn.getZ(), 64.0D, this.dimension.getDimensionId(), new SPacketEffect(sfxType, blockPosIn, data));
this.sendNearExcept(player, (double)blockPosIn.getX(), (double)blockPosIn.getY(), (double)blockPosIn.getZ(), 64.0D, new SPacketEffect(sfxType, blockPosIn, data));
}
// public void broadcastSound(int soundID, BlockPos pos, int data)
@ -2684,7 +2711,7 @@ public final class WorldServer extends AWorldServer {
this.server.placeInDimension(entity, (WorldServer)oldWorld, (WorldServer)world, pos, portal);
}
public AWorldServer getOtherWorld(int dimension) {
public AWorldServer getOtherWorld(Dimension dimension) {
return this.server.getWorld(dimension);
}