Search in sources :

Example 1 with PacketOutSpawnEntityImpl

use of com.denizenscript.denizen.nms.v1_16.impl.network.packets.PacketOutSpawnEntityImpl in project Denizen-For-Bukkit by DenizenScript.

the class DenizenNetworkManagerImpl method processHiddenEntitiesForPacket.

public boolean processHiddenEntitiesForPacket(Packet<?> packet) {
    if (!HideEntitiesHelper.hasAnyHides()) {
        return false;
    }
    try {
        if (packet instanceof PacketPlayOutNamedEntitySpawn || packet instanceof PacketPlayOutSpawnEntity || packet instanceof PacketPlayOutSpawnEntityLiving || packet instanceof PacketPlayOutSpawnEntityPainting || packet instanceof PacketPlayOutSpawnEntityExperienceOrb) {
            PacketOutSpawnEntity spawnEntity = new PacketOutSpawnEntityImpl(player, packet);
            Entity entity = player.getWorld().getEntity(spawnEntity.getEntityId());
            if (isHidden(entity)) {
                return true;
            }
            processFakePlayerSpawn(entity);
        }
        int ider = -1;
        if (packet instanceof PacketPlayOutEntity) {
            ider = ENTITY_ID_PACKENT.getInt(packet);
        } else if (packet instanceof PacketPlayOutEntityMetadata) {
            ider = ENTITY_METADATA_EID.getInt(packet);
        } else if (packet instanceof PacketPlayOutEntityVelocity) {
            ider = ENTITY_ID_PACKVELENT.getInt(packet);
        } else if (packet instanceof PacketPlayOutEntityTeleport) {
            ider = ENTITY_ID_PACKTELENT.getInt(packet);
        }
        if (ider != -1) {
            Entity e = player.getWorld().getEntity(ider);
            if (isHidden(e)) {
                return true;
            }
        }
    } catch (Exception ex) {
        Debug.echoError(ex);
    }
    return false;
}
Also used : CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) PacketOutSpawnEntity(com.denizenscript.denizen.nms.interfaces.packets.PacketOutSpawnEntity) IOException(java.io.IOException) PacketOutSpawnEntity(com.denizenscript.denizen.nms.interfaces.packets.PacketOutSpawnEntity) PacketOutSpawnEntityImpl(com.denizenscript.denizen.nms.v1_16.impl.network.packets.PacketOutSpawnEntityImpl)

Aggregations

PacketOutSpawnEntity (com.denizenscript.denizen.nms.interfaces.packets.PacketOutSpawnEntity)1 PacketOutSpawnEntityImpl (com.denizenscript.denizen.nms.v1_16.impl.network.packets.PacketOutSpawnEntityImpl)1 IOException (java.io.IOException)1 CraftEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity)1