use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.
the class GlowHumanEntity method createSpawnMessage.
// //////////////////////////////////////////////////////////////////////////
// Internals
@Override
public List<Message> createSpawnMessage() {
List<Message> result = new LinkedList<>();
// spawn player
double x = location.getX();
double y = location.getY();
double z = location.getZ();
int yaw = Position.getIntYaw(location);
int pitch = Position.getIntPitch(location);
result.add(new SpawnPlayerMessage(entityId, profile.getId(), x, y, z, yaw, pitch, metadata.getEntryList()));
// head facing
result.add(new EntityHeadRotationMessage(entityId, yaw));
// equipment
EntityEquipment equipment = getEquipment();
result.add(new EntityEquipmentMessage(entityId, EntityEquipmentMessage.HELD_ITEM, equipment.getItemInMainHand()));
result.add(new EntityEquipmentMessage(entityId, EntityEquipmentMessage.OFF_HAND, equipment.getItemInOffHand()));
for (int i = 0; i < 4; i++) {
result.add(new EntityEquipmentMessage(entityId, EntityEquipmentMessage.BOOTS_SLOT + i, equipment.getArmorContents()[i]));
}
return result;
}
use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.
the class GlowLivingEntity method playPickupItemAnimation.
@Override
public void playPickupItemAnimation(@NotNull Item item, int quantity) {
CollectItemMessage message = new CollectItemMessage(item.getEntityId(), getEntityId(), quantity);
world.playSound(location, Sound.ENTITY_ITEM_PICKUP, 0.3f, (float) (1 + Math.random()));
world.getRawPlayers().stream().filter(other -> other.canSeeEntity(this)).forEach(other -> other.getSession().send(message));
item.remove();
}
use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.
the class GlowLivingEntity method createUpdateMessage.
@Override
public List<Message> createUpdateMessage(GlowSession session) {
List<Message> messages = super.createUpdateMessage(session);
messages.addAll(equipmentMonitor.getChanges().stream().map(change -> new EntityEquipmentMessage(entityId, change.slot, change.item)).collect(Collectors.toList()));
if (headRotated) {
messages.add(new EntityHeadRotationMessage(entityId, Position.getIntHeadYaw(headYaw)));
}
attributeManager.applyMessages(messages);
return messages;
}
use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.
the class GlowPlayer method openInventory.
@Override
public void openInventory(InventoryView view) {
session.send(new CloseWindowMessage(invMonitor.getId()));
super.openInventory(view);
invMonitor = new InventoryMonitor(getOpenInventory());
int viewId = invMonitor.getId();
if (viewId != 0) {
InventoryOpenEvent event = EventFactory.getInstance().callEvent(new InventoryOpenEvent(view));
if (event.isCancelled()) {
// close the inventory but don't fire the InventoryCloseEvent
resetInventoryView();
return;
}
String title = view.getTitle();
boolean defaultTitle = Objects.equals(view.getType().getDefaultTitle(), title);
if (view.getTopInventory() instanceof PlayerInventory && defaultTitle) {
title = ((PlayerInventory) view.getTopInventory()).getHolder().getName();
}
Message open = new OpenWindowMessage(viewId, invMonitor.getType(), title, ((GlowInventory) view.getTopInventory()).getRawSlots());
session.send(open);
}
updateInventory();
}
use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.
the class GlowEvokerFangs method createSpawnMessage.
@Override
public List<Message> createSpawnMessage() {
List<Message> result = new LinkedList<>();
double x = location.getX();
double y = location.getY();
double z = location.getZ();
int yaw = Position.getIntYaw(location);
int pitch = Position.getIntPitch(location);
result.add(new SpawnObjectMessage(entityId, this.getUniqueId(), 79, x, y, z, pitch, yaw, 0, 0, 0, 0));
return result;
}
Aggregations