Search in sources :

Example 11 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) {
        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 : UseBedMessage(net.glowstone.net.message.play.player.UseBedMessage) Message(com.flowpowered.network.Message) PlayerAbilitiesMessage(net.glowstone.net.message.play.player.PlayerAbilitiesMessage) TextMessage(net.glowstone.util.TextMessage) ResourcePackSendMessage(net.glowstone.net.message.play.player.ResourcePackSendMessage) InventoryMonitor(net.glowstone.inventory.InventoryMonitor)

Example 12 with Message

use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.

the class GlowAgeable method createSpawnMessage.

@Override
public List<Message> createSpawnMessage() {
    List<Message> messages = super.createSpawnMessage();
    MetadataMap map = new MetadataMap(GlowAgeable.class);
    map.set(MetadataIndex.AGE_ISBABY, !isAdult());
    messages.add(new EntityMetadataMessage(id, map.getEntryList()));
    return messages;
}
Also used : MetadataMap(net.glowstone.entity.meta.MetadataMap) EntityMetadataMessage(net.glowstone.net.message.play.entity.EntityMetadataMessage) Message(com.flowpowered.network.Message) InteractEntityMessage(net.glowstone.net.message.play.player.InteractEntityMessage) EntityMetadataMessage(net.glowstone.net.message.play.entity.EntityMetadataMessage)

Example 13 with Message

use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.

the class GlowCreature 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);
    result.add(new SpawnMobMessage(id, getUniqueId(), type.getTypeId(), x, y, z, yaw, pitch, pitch, 0, 0, 0, metadata.getEntryList()));
    // head facing
    result.add(new EntityHeadRotationMessage(id, yaw));
    //result.add(createEquipmentMessage());
    return result;
}
Also used : SpawnMobMessage(net.glowstone.net.message.play.entity.SpawnMobMessage) EntityHeadRotationMessage(net.glowstone.net.message.play.entity.EntityHeadRotationMessage) Message(com.flowpowered.network.Message) EntityHeadRotationMessage(net.glowstone.net.message.play.entity.EntityHeadRotationMessage) SpawnMobMessage(net.glowstone.net.message.play.entity.SpawnMobMessage) LinkedList(java.util.LinkedList)

Example 14 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(id, profile.getUniqueId(), x, y, z, yaw, pitch, metadata.getEntryList()));
    // head facing
    result.add(new EntityHeadRotationMessage(id, yaw));
    // equipment
    EntityEquipment equipment = getEquipment();
    result.add(new EntityEquipmentMessage(id, 0, equipment.getItemInHand()));
    for (int i = 0; i < 4; i++) {
        result.add(new EntityEquipmentMessage(id, i + 1, equipment.getArmorContents()[i]));
    }
    return result;
}
Also used : 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) EntityHeadRotationMessage(net.glowstone.net.message.play.entity.EntityHeadRotationMessage) SpawnPlayerMessage(net.glowstone.net.message.play.entity.SpawnPlayerMessage) EntityEquipment(org.bukkit.inventory.EntityEquipment) EntityEquipmentMessage(net.glowstone.net.message.play.entity.EntityEquipmentMessage)

Example 15 with Message

use of com.flowpowered.network.Message in project Glowstone by GlowstoneMC.

the class GlowTNTPrimed method createSpawnMessage.

@Override
public List<Message> createSpawnMessage() {
    double x = location.getX();
    double y = location.getY();
    double z = location.getZ();
    int pitch = Position.getIntPitch(location);
    int yaw = Position.getIntYaw(location);
    LinkedList<Message> result = new LinkedList<>();
    result.add(new SpawnObjectMessage(id, getUniqueId(), 50, x, y, z, pitch, yaw));
    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)20 LinkedList (java.util.LinkedList)4 GlowPlayer (net.glowstone.entity.GlowPlayer)4 MetadataMap (net.glowstone.entity.meta.MetadataMap)4 EntityHeadRotationMessage (net.glowstone.net.message.play.entity.EntityHeadRotationMessage)4 EntityMetadataMessage (net.glowstone.net.message.play.entity.EntityMetadataMessage)3 AsyncableMessage (com.flowpowered.network.AsyncableMessage)2 IOException (java.io.IOException)2 GlowBlock (net.glowstone.block.GlowBlock)2 Key (net.glowstone.chunk.GlowChunk.Key)2 SpawnObjectMessage (net.glowstone.net.message.play.entity.SpawnObjectMessage)2 HeldItemMessage (net.glowstone.net.message.play.inv.HeldItemMessage)2 ItemStack (org.bukkit.inventory.ItemStack)2 Vector (org.bukkit.util.Vector)2 Codec (com.flowpowered.network.Codec)1 MessageHandler (com.flowpowered.network.MessageHandler)1 ByteBuf (io.netty.buffer.ByteBuf)1 File (java.io.File)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1