use of org.dragonet.net.packet.minecraft.RemoveEntityPacket 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]);
}
Aggregations