Search in sources :

Example 1 with org.bukkit.craftbukkit.v1_14_R1.entity

use of org.bukkit.craftbukkit.v1_14_R1.entity in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method getNearbyItems.

@Override
public Stream<Item> getNearbyItems(Location location, int range, boolean onlyChunk, KeySet blacklisted, KeySet whitelisted) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    List<Entity> entityList = new ArrayList<>();
    if (onlyChunk) {
        Chunk chunk = ((CraftChunk) location.getChunk()).getHandle();
        for (int i = 0; i < chunk.entitySlices.length; i++) entityList.addAll(chunk.entitySlices[i]);
        entityList = entityList.stream().filter(entity -> entity instanceof EntityItem).collect(Collectors.toList());
    } else {
        AxisAlignedBB boundingBox = new AxisAlignedBB(location.getX() + range, location.getY() + range, location.getZ() + range, location.getX() - range, location.getY() - range, location.getZ() - range);
        entityList = world.getEntities(null, boundingBox, entity -> entity instanceof EntityItem);
    }
    return entityList.stream().map(entity -> (Item) entity.getBukkitEntity()).filter(item -> !blacklisted.contains(item.getItemStack()) && (whitelisted.isEmpty() || whitelisted.contains(item.getItemStack())));
}
Also used : AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) InventoryHolder(com.bgsoftware.wildchests.objects.inventory.InventoryHolder) DataInputStream(java.io.DataInputStream) AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Entity(net.minecraft.server.v1_16_R3.Entity) Item(org.bukkit.entity.Item) Inventory(org.bukkit.inventory.Inventory) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) ArrayList(java.util.ArrayList) Location(org.bukkit.Location) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) BigInteger(java.math.BigInteger) ChestType(com.bgsoftware.wildchests.api.objects.ChestType) KeySet(com.bgsoftware.wildchests.key.KeySet) Material(org.bukkit.Material) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) NBTTagList(net.minecraft.server.v1_16_R3.NBTTagList) TileEntityChest(net.minecraft.server.v1_16_R3.TileEntityChest) World(net.minecraft.server.v1_16_R3.World) HumanEntity(org.bukkit.entity.HumanEntity) EntityItem(net.minecraft.server.v1_16_R3.EntityItem) DataOutput(java.io.DataOutput) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) EntityHuman(net.minecraft.server.v1_16_R3.EntityHuman) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) Collectors(java.util.stream.Collectors) Particle(org.bukkit.Particle) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) Base64(java.util.Base64) List(java.util.List) Stream(java.util.stream.Stream) NBTReadLimiter(net.minecraft.server.v1_16_R3.NBTReadLimiter) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) NBTCompressedStreamTools(net.minecraft.server.v1_16_R3.NBTCompressedStreamTools) Entity(net.minecraft.server.v1_16_R3.Entity) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) HumanEntity(org.bukkit.entity.HumanEntity) Item(org.bukkit.entity.Item) EntityItem(net.minecraft.server.v1_16_R3.EntityItem) ArrayList(java.util.ArrayList) World(net.minecraft.server.v1_16_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) EntityItem(net.minecraft.server.v1_16_R3.EntityItem)

Example 2 with org.bukkit.craftbukkit.v1_14_R1.entity

use of org.bukkit.craftbukkit.v1_14_R1.entity in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_14_R1 method getEquipmentPacket.

private PacketPlayOutEntityEquipment[] getEquipmentPacket() {
    if (!type.isAlive())
        return null;
    EntityLiving livingEntity = (EntityLiving) entity;
    List<PacketPlayOutEntityEquipment> temp = new ArrayList<>(SLOTS.length);
    for (EnumItemSlot slot : SLOTS) {
        ItemStack item = livingEntity.getEquipment(slot);
        if (item != null && !item.isEmpty()) {
            temp.add(new PacketPlayOutEntityEquipment(cache, slot, item));
        }
    }
    return temp.isEmpty() ? null : temp.toArray(new PacketPlayOutEntityEquipment[0]);
}
Also used : ArrayList(java.util.ArrayList) CraftItemStack(org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack)

Example 3 with org.bukkit.craftbukkit.v1_14_R1.entity

use of org.bukkit.craftbukkit.v1_14_R1.entity in project MechanicsMain by WeaponMechanics.

the class Scope_1_14_R1 method removeNightVision.

@Override
public void removeNightVision(Player player) {
    if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
        EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
        // Simply remove the entity effect
        PacketPlayOutRemoveEntityEffect removeEntityEffect = new PacketPlayOutRemoveEntityEffect(player.getEntityId(), MobEffectList.fromId(PotionEffectType.NIGHT_VISION.getId()));
        entityPlayer.playerConnection.sendPacket(removeEntityEffect);
        // resend the existing one
        MobEffect mobEffect = entityPlayer.getEffect(MobEffectList.fromId(PotionEffectType.NIGHT_VISION.getId()));
        PacketPlayOutEntityEffect entityEffect = new PacketPlayOutEntityEffect(player.getEntityId(), mobEffect);
        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(entityEffect);
        return;
    }
    // Simply remove the entity effect
    PacketPlayOutRemoveEntityEffect removeEntityEffect = new PacketPlayOutRemoveEntityEffect(player.getEntityId(), MobEffectList.fromId(PotionEffectType.NIGHT_VISION.getId()));
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(removeEntityEffect);
}
Also used : PacketPlayOutEntityEffect(net.minecraft.server.v1_14_R1.PacketPlayOutEntityEffect) MobEffect(net.minecraft.server.v1_14_R1.MobEffect) EntityPlayer(net.minecraft.server.v1_14_R1.EntityPlayer) PacketPlayOutRemoveEntityEffect(net.minecraft.server.v1_14_R1.PacketPlayOutRemoveEntityEffect) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer)

Example 4 with org.bukkit.craftbukkit.v1_14_R1.entity

use of org.bukkit.craftbukkit.v1_14_R1.entity in project MechanicsMain by WeaponMechanics.

the class v1_14_R1 method logDamage.

@Override
public void logDamage(LivingEntity victim, LivingEntity source, double health, double damage, boolean isMelee) {
    DamageSource damageSource;
    if (isMelee) {
        if (source instanceof Player) {
            damageSource = DamageSource.playerAttack(((org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) source).getHandle());
        } else {
            damageSource = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
        }
    } else {
        damageSource = DamageSource.projectile(null, ((CraftLivingEntity) source).getHandle());
    }
    EntityLiving nms = ((CraftLivingEntity) victim).getHandle();
    nms.combatTracker.trackDamage(damageSource, (float) damage, (float) health);
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) DamageSource(net.minecraft.server.v1_14_R1.DamageSource) EntityLiving(net.minecraft.server.v1_14_R1.EntityLiving) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) CraftLivingEntity(org.bukkit.craftbukkit.v1_14_R1.entity.CraftLivingEntity)

Example 5 with org.bukkit.craftbukkit.v1_14_R1.entity

use of org.bukkit.craftbukkit.v1_14_R1.entity in project entity-service by hypertrace.

the class EntityDataServiceTest method testCreateWithIdentifyingAttributes.

@Test
public void testCreateWithIdentifyingAttributes() {
    AttributeValue randomUUIDAttrValue = generateRandomUUIDAttrValue();
    Entity entity = Entity.newBuilder().setTenantId(TENANT_ID).setEntityType(EntityType.K8S_POD.name()).setEntityName("Some Service").putIdentifyingAttributes(EntityConstants.getValue(CommonAttribute.COMMON_ATTRIBUTE_EXTERNAL_ID), randomUUIDAttrValue).build();
    Entity createdEntity = entityDataServiceClient.upsert(entity);
    assertNotNull(createdEntity.getEntityId());
    Entity entity1 = Entity.newBuilder().setTenantId(TENANT_ID).setEntityType(EntityType.K8S_POD.name()).setEntityName("Some Service 1").putIdentifyingAttributes(EntityConstants.getValue(CommonAttribute.COMMON_ATTRIBUTE_EXTERNAL_ID), randomUUIDAttrValue).build();
    Entity createdEntity1 = entityDataServiceClient.upsert(entity1);
    // Should be same entity since identifying attributes are the same
    assertEquals(createdEntity.getEntityId(), createdEntity1.getEntityId());
}
Also used : EnrichedEntity(org.hypertrace.entity.data.service.v1.EnrichedEntity) Entity(org.hypertrace.entity.data.service.v1.Entity) AttributeValue(org.hypertrace.entity.data.service.v1.AttributeValue) Test(org.junit.jupiter.api.Test)

Aggregations

Entity (org.hypertrace.entity.data.service.v1.Entity)110 LivingEntity (org.bukkit.entity.LivingEntity)96 Test (org.junit.jupiter.api.Test)95 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)88 net.minecraft.world.entity (net.minecraft.world.entity)40 org.bukkit.entity (org.bukkit.entity)40 Location (org.bukkit.Location)35 ArrayList (java.util.ArrayList)34 Entity (com.google.datastore.v1.Entity)33 EnrichedEntity (org.hypertrace.entity.data.service.v1.EnrichedEntity)32 Event (org.hypertrace.core.datamodel.Event)27 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)22 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)21 Mob (net.minecraft.world.entity.Mob)20 Player (org.bukkit.entity.Player)19 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)18 Entity (net.minecraft.server.v1_8_R3.Entity)18 AnnotateVideoProgress (com.google.cloud.videointelligence.v1.AnnotateVideoProgress)17 AnnotateVideoRequest (com.google.cloud.videointelligence.v1.AnnotateVideoRequest)17 AnnotateVideoResponse (com.google.cloud.videointelligence.v1.AnnotateVideoResponse)17