use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.
the class GlowBat method createSpawnMessage.
@Override
public List<Message> createSpawnMessage() {
List<Message> result = new LinkedList<>();
// spawn mob
double x = location.getX();
double y = location.getY();
double z = location.getZ();
int yaw = Position.getIntYaw(location);
int pitch = Position.getIntPitch(location);
//TODO 1.9 - Real UUID
result.add(new SpawnMobMessage(id, UUID.randomUUID(), getType().getTypeId(), x, y, z, yaw, pitch, pitch, 0, 0, 0, metadata.getEntryList()));
// head facing
result.add(new EntityHeadRotationMessage(id, yaw));
return result;
}
use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.
the class GlowHorse method createSpawnMessage.
@Override
public List<Message> createSpawnMessage() {
List<Message> messages = super.createSpawnMessage();
MetadataMap map = new MetadataMap(GlowHorse.class);
map.set(MetadataIndex.HORSE_STYLE, getHorseStyleData());
map.set(MetadataIndex.HORSE_ARMOR, getHorseArmorData());
messages.add(new EntityMetadataMessage(id, map.getEntryList()));
return messages;
}
use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.
the class GlowAbstractHorse method createSpawnMessage.
@Override
public List<Message> createSpawnMessage() {
List<Message> messages = super.createSpawnMessage();
MetadataMap map = new MetadataMap(GlowHorse.class);
map.set(MetadataIndex.ABSTRACT_HORSE_FLAGS, getHorseFlags());
messages.add(new EntityMetadataMessage(id, map.getEntryList()));
return messages;
}
use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.
the class ItemItemFrame method rightClickBlock.
@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc) {
GlowItemFrame entity = new GlowItemFrame(player, target.getLocation().getBlock().getRelative(face).getLocation(), face);
List<Message> spawnMessage = entity.createSpawnMessage();
entity.getWorld().getRawPlayers().stream().filter(p -> p.canSeeEntity(entity)).forEach(p -> p.getSession().sendAll(spawnMessage.toArray(new Message[spawnMessage.size()])));
}
use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.
the class GlowSession method pulse.
/**
* Pulse this session, performing any updates needed.
*/
void pulse() {
// drop the previous placement if needed
if (previousPlacementTicks > 0 && --previousPlacementTicks == 0) {
previousPlacement = null;
}
// process messages
Message message;
while ((message = messageQueue.poll()) != null) {
if (disconnected) {
// disconnected, we are just seeing extra messages now
break;
}
super.messageReceived(message);
}
// check if the client is disconnected
if (disconnected) {
connectionManager.sessionInactivated(this);
if (player == null) {
return;
}
player.remove();
Message userListMessage = UserListItemMessage.removeOne(player.getUniqueId());
for (GlowPlayer player : server.getRawOnlinePlayers()) {
if (player.canSee(this.player)) {
player.getSession().send(userListMessage);
} else {
player.stopHidingDisconnectedPlayer(this.player);
}
}
GlowServer.logger.info(player.getName() + " [" + address + "] lost connection");
if (player.isSleeping()) {
player.leaveBed(false);
}
server.getBossBarManager().clearBossBars(player);
String text = EventFactory.onPlayerQuit(player).getQuitMessage();
if (online && text != null && !text.isEmpty()) {
server.broadcastMessage(text);
}
// statistics
player.incrementStatistic(Statistic.LEAVE_GAME);
for (Player p : server.getOnlinePlayers()) {
if (p.getUniqueId().equals(player.getUniqueId())) {
continue;
}
GlowPlayer other = (GlowPlayer) p;
if (!other.canSee(player)) {
continue;
}
other.getSession().send(new DestroyEntitiesMessage(Collections.singletonList(player.getEntityId())));
}
// in case we are disposed twice
player = null;
}
}
Aggregations