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())));
}
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]);
}
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);
}
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);
}
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());
}
Aggregations