Archived
0

fix: Location (setWorld)

This commit is contained in:
2018-08-12 23:40:02 +03:00
parent d4785cda14
commit 0cf51120c0
3 changed files with 21 additions and 4 deletions

View File

@@ -38,6 +38,7 @@ public class InMemoryPlayerManager implements PlayerManager, Runnable {
player.setName(name); player.setName(name);
player.getLocation().setXYZ(defaultLocation); player.getLocation().setXYZ(defaultLocation);
player.getLocation().setYawPitch(defaultLocation); player.getLocation().setYawPitch(defaultLocation);
player.getLocation().setWorld(defaultLocation.getWorld());
player.setSettings(new PlayerSettings()); player.setSettings(new PlayerSettings());
synchronized (lock) { synchronized (lock) {

View File

@@ -7,6 +7,7 @@ package mc.world.flat;
import com.flowpowered.nbt.Tag; import com.flowpowered.nbt.Tag;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import mc.core.EntityLocation; import mc.core.EntityLocation;
import mc.core.world.IWorldType; import mc.core.world.IWorldType;
import mc.core.world.Region; import mc.core.world.Region;
@@ -17,6 +18,7 @@ import mc.core.world.chunk.ChunkSection;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Stream; import java.util.stream.Stream;
@Slf4j
public class FlatWorld implements World { public class FlatWorld implements World {
@Getter @Getter
@@ -26,9 +28,7 @@ public class FlatWorld implements World {
@Setter @Setter
private String name; private String name;
@Getter private EntityLocation spawn;
@Setter
private EntityLocation spawn = new EntityLocation(0d, 6d, 0d, 0f, 0f, this);
private ChunkSection chunkSection = new SimpleChunkSection(); private ChunkSection chunkSection = new SimpleChunkSection();
@Override @Override
@@ -36,6 +36,22 @@ public class FlatWorld implements World {
return WorldType.GENERAL; return WorldType.GENERAL;
} }
@Override
public EntityLocation getSpawn() {
if (this.spawn == null) {
log.warn("Spawn is not defined! Set spawn [0, 6, 0]");
this.spawn = new EntityLocation(0d, 6d, 0d, 0f, 0f, this);
}
return this.spawn;
}
@Override
public void setSpawn(EntityLocation location) {
this.spawn = location;
this.spawn.setWorld(this);
}
@Override @Override
public ChunkSection getChunk(int x, int y, int z) { public ChunkSection getChunk(int x, int y, int z) {
return chunkSection; return chunkSection;

View File

@@ -83,7 +83,7 @@ public class PlayHandler extends AbstractStateHandler implements PlayStateHandle
packet.getX(), packet.getY(), packet.getZ(), packet.getX(), packet.getY(), packet.getZ(),
player.getLocation().getYaw(), player.getLocation().getYaw(),
player.getLocation().getPitch(), player.getLocation().getPitch(),
null player.getLocation().getWorld()
)); ));
EventBusGetter.INSTANCE.post(event); EventBusGetter.INSTANCE.post(event);
} }