Search in sources :

Example 1 with RemovePlayerPacket

use of org.dragonet.net.packet.minecraft.RemovePlayerPacket in project Dragonet-Legacy by DragonetMC.

the class DestroyEntitiesMessageTranslator method handleSpecific.

@Override
public PEPacket[] handleSpecific(DestroyEntitiesMessage packet) {
    //Remove from the list
    this.getTranslator().cachedEntityIDs.removeAll(packet.ids);
    int[] ids = ArrayUtils.toPrimitive(packet.ids.toArray(new Integer[0]));
    ArrayList<PEPacket> pkRemoveEntity = new ArrayList<>();
    for (int i = 0; i < ids.length; i++) {
        if (!this.getTranslator().cachedPlayerEntities.contains(ids[i])) {
            PEPacket tmp = new RemoveEntityPacket();
            ((RemoveEntityPacket) tmp).eid = ids[i];
            pkRemoveEntity.add(tmp);
        } else {
            GlowPlayer glow = ((GlowPlayer) this.getSession().getPlayer().getWorld().getEntityManager().getEntity(ids[i]));
            PEPacket tmp = new RemovePlayerPacket();
            ((RemovePlayerPacket) tmp).uuid = glow.getUniqueId();
            ((RemovePlayerPacket) tmp).eid = ids[i];
            this.getTranslator().cachedPlayerEntities.remove(new Integer(ids[i]));
            PlayerListPacket pl = new PlayerListPacket(new PlayerListPacket.PlayerInfo(glow.getUniqueId(), -1, null, true, true, null));
            pl.isAdding = false;
            pkRemoveEntity.add(tmp);
            pkRemoveEntity.add(pl);
        }
    }
    return pkRemoveEntity.toArray(new PEPacket[0]);
}
Also used : RemoveEntityPacket(org.dragonet.net.packet.minecraft.RemoveEntityPacket) GlowPlayer(net.glowstone.entity.GlowPlayer) RemovePlayerPacket(org.dragonet.net.packet.minecraft.RemovePlayerPacket) ArrayList(java.util.ArrayList) PEPacket(org.dragonet.net.packet.minecraft.PEPacket) PlayerListPacket(org.dragonet.net.packet.minecraft.PlayerListPacket)

Aggregations

ArrayList (java.util.ArrayList)1 GlowPlayer (net.glowstone.entity.GlowPlayer)1 PEPacket (org.dragonet.net.packet.minecraft.PEPacket)1 PlayerListPacket (org.dragonet.net.packet.minecraft.PlayerListPacket)1 RemoveEntityPacket (org.dragonet.net.packet.minecraft.RemoveEntityPacket)1 RemovePlayerPacket (org.dragonet.net.packet.minecraft.RemovePlayerPacket)1