apply upgraded Location & EntityLocation
This commit is contained in:
@@ -2,7 +2,7 @@ package mc.world.generated_world.serialization;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import mc.core.WarpPosition;
|
||||
import mc.core.EntityLocation;
|
||||
import mc.core.world.World;
|
||||
import mc.world.generated_world.world.CubicWorld;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class WorldReaderWriter {
|
||||
|
||||
@Data
|
||||
public static class WorldInfo implements Serializable {
|
||||
private WarpPosition spawn;
|
||||
private EntityLocation spawn;
|
||||
private String name;
|
||||
private int seed;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@ import com.flowpowered.nbt.Tag;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import mc.core.EntityLocation;
|
||||
import mc.core.Location;
|
||||
import mc.core.WarpPosition;
|
||||
import mc.core.world.block.BlockType;
|
||||
import mc.core.player.Look;
|
||||
import mc.core.world.chunk.Chunk;
|
||||
import mc.core.world.IWorldType;
|
||||
import mc.core.world.Region;
|
||||
@@ -27,7 +26,7 @@ public class CubicWorld implements World {
|
||||
@Getter
|
||||
private final UUID worldId;
|
||||
private final int seed;
|
||||
private volatile WarpPosition warpPosition;
|
||||
private volatile EntityLocation warpPosition;
|
||||
private final transient Object spawnLocationLock = new Object();
|
||||
private final Map<String, Tag<?>> nbtTagMap = new HashMap<>();
|
||||
@Autowired
|
||||
@@ -61,20 +60,20 @@ public class CubicWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WarpPosition getSpawn() {
|
||||
public EntityLocation getSpawn() {
|
||||
if (warpPosition == null) {
|
||||
synchronized (spawnLocationLock) {
|
||||
if (warpPosition == null) {
|
||||
log.warn("Spawn location is not defined. Trying to select best location");
|
||||
warpPosition = new WarpPosition(Location.startPointLocation(), new Look(0, 0));
|
||||
warpPosition = new EntityLocation(0d, 10d, 0d, 0f, 0f, this);
|
||||
for (int y = WORLD_MAX_HEIGHT; y > 0; y --) {
|
||||
Chunk chunk = getChunk(0,y / WORLD_CHUNK_SIZE, 0);
|
||||
if (chunk.getBlock(0, y, 0).getBlockType() != BlockType.AIR) {
|
||||
warpPosition = new WarpPosition(new Location(0, y + 1, 0), new Look(0, 0));
|
||||
warpPosition = new EntityLocation(0d, y + 1d, 0d, 0f, 0f, this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
warpPosition = new WarpPosition(Location.startPointLocation(), new Look(0,0));
|
||||
warpPosition = new EntityLocation(0d, 10d, 0d, 0f, 0f, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +81,7 @@ public class CubicWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpawn(WarpPosition warpPosition) {
|
||||
public void setSpawn(EntityLocation warpPosition) {
|
||||
synchronized (spawnLocationLock) {
|
||||
this.warpPosition = warpPosition;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user