Search in sources :

Example 26 with Message

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;
}
Also used : EntityHeadRotationMessage(net.glowstone.net.message.play.entity.EntityHeadRotationMessage) SpawnPlayerMessage(net.glowstone.net.message.play.entity.SpawnPlayerMessage) EntityHeadRotationMessage(net.glowstone.net.message.play.entity.EntityHeadRotationMessage) SpawnPlayerMessage(net.glowstone.net.message.play.entity.SpawnPlayerMessage) EntityEquipmentMessage(net.glowstone.net.message.play.entity.EntityEquipmentMessage) Message(com.flowpowered.network.Message) EntityEquipment(org.bukkit.inventory.EntityEquipment) EntityEquipmentMessage(net.glowstone.net.message.play.entity.EntityEquipmentMessage) LinkedList(java.util.LinkedList)

Example 27 with Message

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();
}
Also used : EntityCategory(org.bukkit.entity.EntityCategory) GlowBlock(net.glowstone.block.GlowBlock) Arrays(java.util.Arrays) BlockType(net.glowstone.block.blocktype.BlockType) ItemTable(net.glowstone.block.ItemTable) SlimeSplitEvent(org.bukkit.event.entity.SlimeSplitEvent) EntityRemoveEffectMessage(net.glowstone.net.message.play.entity.EntityRemoveEffectMessage) PlayerUnleashEntityEvent(org.bukkit.event.player.PlayerUnleashEntityEvent) BlockIterator(org.bukkit.util.BlockIterator) TaskManager(net.glowstone.entity.ai.TaskManager) Location(org.bukkit.Location) Monster(org.bukkit.entity.Monster) Map(java.util.Map) EntityAnimation(org.bukkit.EntityAnimation) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) Position(net.glowstone.util.Position) Entity(org.bukkit.entity.Entity) Set(java.util.Set) Math.sin(java.lang.Math.sin) EntityResurrectEvent(org.bukkit.event.entity.EntityResurrectEvent) Action(net.glowstone.net.message.play.player.InteractEntityMessage.Action) ItemStack(org.bukkit.inventory.ItemStack) TargetEntityInfo(com.destroystokyo.paper.entity.TargetEntityInfo) MetadataIndex(net.glowstone.entity.meta.MetadataIndex) LootingManager(net.glowstone.util.loot.LootingManager) ProjectileLaunchEvent(org.bukkit.event.entity.ProjectileLaunchEvent) GlowSlime(net.glowstone.entity.monster.GlowSlime) PotionEffectType(org.bukkit.potion.PotionEffectType) Key(net.glowstone.entity.AttributeManager.Key) EntityToggleGlideEvent(org.bukkit.event.entity.EntityToggleGlideEvent) Message(com.flowpowered.network.Message) ArrayList(java.util.ArrayList) MobState(net.glowstone.entity.ai.MobState) GlowLeashHitch(net.glowstone.entity.objects.GlowLeashHitch) GameRules(net.glowstone.constants.GameRules) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) MemoryKey(org.bukkit.entity.memory.MemoryKey) EventFactory(net.glowstone.EventFactory) Vector(org.bukkit.util.Vector) Criterias(org.bukkit.scoreboard.Criterias) EntityEffect(org.bukkit.EntityEffect) AttributeInstance(org.bukkit.attribute.AttributeInstance) Statistic(org.bukkit.Statistic) Projectile(org.bukkit.entity.Projectile) BlockFace(org.bukkit.block.BlockFace) Player(org.bukkit.entity.Player) Objective(org.bukkit.scoreboard.Objective) Block(org.bukkit.block.Block) GlowProjectile(net.glowstone.entity.projectile.GlowProjectile) EquipmentMonitor(net.glowstone.inventory.EquipmentMonitor) InteractEntityMessage(net.glowstone.net.message.play.player.InteractEntityMessage) EntityHeadRotationMessage(net.glowstone.net.message.play.entity.EntityHeadRotationMessage) ExperienceSplitter(net.glowstone.util.ExperienceSplitter) LootData(net.glowstone.util.loot.LootData) EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) Math.cos(java.lang.Math.cos) DamageCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause) CollectItemMessage(net.glowstone.net.message.play.entity.CollectItemMessage) Collection(java.util.Collection) PlayerLeashEntityEvent(org.bukkit.event.entity.PlayerLeashEntityEvent) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Sound(org.bukkit.Sound) UUID(java.util.UUID) EntityType(org.bukkit.entity.EntityType) LivingEntity(org.bukkit.entity.LivingEntity) EntityEffectMessage(net.glowstone.net.message.play.entity.EntityEffectMessage) EntityAirChangeEvent(org.bukkit.event.entity.EntityAirChangeEvent) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) PlayerDeathEvent(org.bukkit.event.entity.PlayerDeathEvent) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull) FluidCollisionMode(org.bukkit.FluidCollisionMode) Setter(lombok.Setter) Getter(lombok.Getter) EntityEquipmentMessage(net.glowstone.net.message.play.entity.EntityEquipmentMessage) Item(org.bukkit.entity.Item) EntityAnimationMessage(net.glowstone.net.message.play.entity.EntityAnimationMessage) GlowExperienceOrb(net.glowstone.entity.objects.GlowExperienceOrb) GlowWolf(net.glowstone.entity.passive.GlowWolf) InventoryUtil(net.glowstone.util.InventoryUtil) EntityDeathEvent(org.bukkit.event.entity.EntityDeathEvent) GameMode(org.bukkit.GameMode) RayUtil(net.glowstone.util.RayUtil) GlowSession(net.glowstone.net.GlowSession) GlowPotionEffect(net.glowstone.constants.GlowPotionEffect) LinkedList(java.util.LinkedList) Color(org.bukkit.Color) EntityDamageEvent(org.bukkit.event.entity.EntityDamageEvent) HumanEntity(org.bukkit.entity.HumanEntity) Attribute(org.bukkit.attribute.Attribute) Iterator(java.util.Iterator) SoundUtil(net.glowstone.util.SoundUtil) PotionEffect(org.bukkit.potion.PotionEffect) TargetBlockInfo(com.destroystokyo.paper.block.TargetBlockInfo) RayTraceResult(org.bukkit.util.RayTraceResult) Fireball(org.bukkit.entity.Fireball) EntityEquipment(org.bukkit.inventory.EntityEquipment) Collections(java.util.Collections) CollectItemMessage(net.glowstone.net.message.play.entity.CollectItemMessage)

Example 28 with Message

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;
}
Also used : EntityHeadRotationMessage(net.glowstone.net.message.play.entity.EntityHeadRotationMessage) EntityRemoveEffectMessage(net.glowstone.net.message.play.entity.EntityRemoveEffectMessage) Message(com.flowpowered.network.Message) InteractEntityMessage(net.glowstone.net.message.play.player.InteractEntityMessage) EntityHeadRotationMessage(net.glowstone.net.message.play.entity.EntityHeadRotationMessage) CollectItemMessage(net.glowstone.net.message.play.entity.CollectItemMessage) EntityEffectMessage(net.glowstone.net.message.play.entity.EntityEffectMessage) EntityEquipmentMessage(net.glowstone.net.message.play.entity.EntityEquipmentMessage) EntityAnimationMessage(net.glowstone.net.message.play.entity.EntityAnimationMessage) EntityEquipmentMessage(net.glowstone.net.message.play.entity.EntityEquipmentMessage)

Example 29 with Message

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();
}
Also used : InventoryOpenEvent(org.bukkit.event.inventory.InventoryOpenEvent) CloseWindowMessage(net.glowstone.net.message.play.inv.CloseWindowMessage) OpenWindowMessage(net.glowstone.net.message.play.inv.OpenWindowMessage) TitleMessage(net.glowstone.net.message.play.game.TitleMessage) EntityMetadataMessage(net.glowstone.net.message.play.entity.EntityMetadataMessage) OpenWindowMessage(net.glowstone.net.message.play.inv.OpenWindowMessage) BlockBreakAnimationMessage(net.glowstone.net.message.play.game.BlockBreakAnimationMessage) WindowPropertyMessage(net.glowstone.net.message.play.inv.WindowPropertyMessage) UpdateBlockEntityMessage(net.glowstone.net.message.play.game.UpdateBlockEntityMessage) RespawnMessage(net.glowstone.net.message.play.game.RespawnMessage) EntityVelocityMessage(net.glowstone.net.message.play.entity.EntityVelocityMessage) PositionRotationMessage(net.glowstone.net.message.play.game.PositionRotationMessage) HealthMessage(net.glowstone.net.message.play.game.HealthMessage) PluginMessage(net.glowstone.net.message.play.game.PluginMessage) SetWindowSlotMessage(net.glowstone.net.message.play.inv.SetWindowSlotMessage) PlayEffectMessage(net.glowstone.net.message.play.game.PlayEffectMessage) BlockChangeMessage(net.glowstone.net.message.play.game.BlockChangeMessage) MultiBlockChangeMessage(net.glowstone.net.message.play.game.MultiBlockChangeMessage) UnloadChunkMessage(net.glowstone.net.message.play.game.UnloadChunkMessage) StateChangeMessage(net.glowstone.net.message.play.game.StateChangeMessage) SpawnPositionMessage(net.glowstone.net.message.play.game.SpawnPositionMessage) ExperienceMessage(net.glowstone.net.message.play.game.ExperienceMessage) NamedSoundEffectMessage(net.glowstone.net.message.play.game.NamedSoundEffectMessage) UserListHeaderFooterMessage(net.glowstone.net.message.play.game.UserListHeaderFooterMessage) HeldItemMessage(net.glowstone.net.message.play.inv.HeldItemMessage) MapDataMessage(net.glowstone.net.message.play.game.MapDataMessage) StopSoundMessage(net.glowstone.net.message.play.game.StopSoundMessage) CloseWindowMessage(net.glowstone.net.message.play.inv.CloseWindowMessage) ChunkDataMessage(net.glowstone.net.message.play.game.ChunkDataMessage) TimeMessage(net.glowstone.net.message.play.game.TimeMessage) Message(com.flowpowered.network.Message) SetWindowContentsMessage(net.glowstone.net.message.play.inv.SetWindowContentsMessage) PlayParticleMessage(net.glowstone.net.message.play.game.PlayParticleMessage) ResourcePackSendMessage(net.glowstone.net.message.play.player.ResourcePackSendMessage) DestroyEntitiesMessage(net.glowstone.net.message.play.entity.DestroyEntitiesMessage) JoinGameMessage(net.glowstone.net.message.play.game.JoinGameMessage) SignEditorMessage(net.glowstone.net.message.play.game.SignEditorMessage) SetPassengerMessage(net.glowstone.net.message.play.entity.SetPassengerMessage) EntityAnimationMessage(net.glowstone.net.message.play.entity.EntityAnimationMessage) TextMessage(net.glowstone.util.TextMessage) UpdateSignMessage(net.glowstone.net.message.play.game.UpdateSignMessage) UserListItemMessage(net.glowstone.net.message.play.game.UserListItemMessage) ChatMessage(net.glowstone.net.message.play.game.ChatMessage) InventoryMonitor(net.glowstone.inventory.InventoryMonitor) PlayerInventory(org.bukkit.inventory.PlayerInventory)

Example 30 with Message

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;
}
Also used : SpawnObjectMessage(net.glowstone.net.message.play.entity.SpawnObjectMessage) Message(com.flowpowered.network.Message) SpawnObjectMessage(net.glowstone.net.message.play.entity.SpawnObjectMessage) LinkedList(java.util.LinkedList)

Aggregations

Message (com.flowpowered.network.Message)34 LinkedList (java.util.LinkedList)13 EntityMetadataMessage (net.glowstone.net.message.play.entity.EntityMetadataMessage)11 List (java.util.List)10 DestroyEntitiesMessage (net.glowstone.net.message.play.entity.DestroyEntitiesMessage)10 ItemStack (org.bukkit.inventory.ItemStack)10 Vector (org.bukkit.util.Vector)10 ArrayList (java.util.ArrayList)9 Collections (java.util.Collections)8 Getter (lombok.Getter)8 Setter (lombok.Setter)8 EventFactory (net.glowstone.EventFactory)8 EntityVelocityMessage (net.glowstone.net.message.play.entity.EntityVelocityMessage)8 SetPassengerMessage (net.glowstone.net.message.play.entity.SetPassengerMessage)8 TextMessage (net.glowstone.util.TextMessage)8 NotNull (org.jetbrains.annotations.NotNull)8 GlowBlock (net.glowstone.block.GlowBlock)7 GlowPlayer (net.glowstone.entity.GlowPlayer)7 EntityAnimationMessage (net.glowstone.net.message.play.entity.EntityAnimationMessage)7 UserListItemMessage (net.glowstone.net.message.play.game.UserListItemMessage)7