use of net.glowstone.net.message.play.game.RespawnMessage in project Glowstone by GlowstoneMC.
the class GlowPlayer method spawnAt.
/**
* Spawn the player at the given location after they have already joined.
*
* <p>Used for changing worlds and respawning after death.
*
* @param location The location to place the player.
*/
private void spawnAt(Location location) {
GlowWorld oldWorld;
// switch worlds
worldLock.writeLock().lock();
try {
oldWorld = world;
world.getEntityManager().unregister(this);
world = (GlowWorld) location.getWorld();
world.getEntityManager().register(this);
updateBossBars();
} finally {
worldLock.writeLock().unlock();
}
// switch chunk set
// no need to send chunk unload messages - respawn unloads all chunks
knownChunks.clear();
chunkLock.clear();
chunkLock = world.newChunkLock(getName());
// spawn into world
session.send(new RespawnMessage(world.getName(), world.getSeedHash(), getGameMode().getValue(), -1, false, world.getWorldType() == WorldType.FLAT, oldWorld.getEnvironment() != world.getEnvironment()));
// take us to spawn position
setRawLocation(location, false);
session.send(new PositionRotationMessage(location));
teleportedTo = location.clone();
// set our compass target
setCompassTarget(world.getSpawnLocation());
// stream blocks
streamBlocks();
sendWeather();
sendRainDensity();
sendSkyDarkness();
sendTime();
updateInventory();
// fire world change if needed
if (oldWorld != world) {
session.send(((GlowWorldBorder) world.getWorldBorder()).createMessage());
EventFactory.getInstance().callEvent(new PlayerChangedWorldEvent(this, oldWorld));
}
}
use of net.glowstone.net.message.play.game.RespawnMessage in project Glowstone by GlowstoneMC.
the class RespawnCodec method decode.
@Override
public RespawnMessage decode(ByteBuf buf) throws IOException {
CompoundTag dimension = readCompound(buf);
String world = readUTF8(buf);
byte[] seedHash = buf.readBytes(8).array();
int mode = buf.readByte();
int previousMode = buf.readByte();
boolean debug = buf.readBoolean();
boolean flat = buf.readBoolean();
boolean copyMetadata = buf.readBoolean();
return new RespawnMessage(world, seedHash, mode, previousMode, debug, flat, copyMetadata);
}
Aggregations