use of org.bukkit.craftbukkit.v1_18_R2.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_18_R2.entity in project MechanicsMain by WeaponMechanics.
the class Scope_1_18_R2 method removeNightVision.
@Override
public void removeNightVision(org.bukkit.entity.Player player) {
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
// Simply remove the entity effect
ClientboundRemoveMobEffectPacket removeEntityEffect = new ClientboundRemoveMobEffectPacket(player.getEntityId(), MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
entityPlayer.connection.send(removeEntityEffect);
// resend the existing one
MobEffectInstance mobEffect = entityPlayer.getEffect(MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
ClientboundUpdateMobEffectPacket entityEffect = new ClientboundUpdateMobEffectPacket(player.getEntityId(), mobEffect);
((CraftPlayer) player).getHandle().connection.send(entityEffect);
return;
}
// Simply remove the entity effect
ClientboundRemoveMobEffectPacket removeEntityEffect = new ClientboundRemoveMobEffectPacket(player.getEntityId(), MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
((CraftPlayer) player).getHandle().connection.send(removeEntityEffect);
}
use of org.bukkit.craftbukkit.v1_18_R2.entity in project FunnyGuilds by FunnyGuilds.
the class V1_13R2EntityAccessor method createFakeEntity.
@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
Preconditions.checkNotNull(entityType, "entity type can't be null!");
Preconditions.checkNotNull(location, "location can't be null!");
Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
CraftWorld world = ((CraftWorld) location.getWorld());
if (world == null) {
throw new IllegalStateException("location's world is null!");
}
Entity entity = world.createEntity(location, entityType.getEntityClass());
Packet<?> spawnEntityPacket;
if (entity instanceof EntityLiving) {
spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
} else {
spawnEntityPacket = new PacketPlayOutSpawnEntity(entity, ObjectType.getIdFor(entityType));
}
return new FakeEntity(entity.getId(), spawnEntityPacket);
}
use of org.bukkit.craftbukkit.v1_18_R2.entity in project FunnyGuilds by FunnyGuilds.
the class V1_9R2EntityAccessor method createFakeEntity.
@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
Preconditions.checkNotNull(entityType, "entity type can't be null!");
Preconditions.checkNotNull(location, "location can't be null!");
Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
CraftWorld world = ((CraftWorld) location.getWorld());
if (world == null) {
throw new IllegalStateException("location's world is null!");
}
Entity entity = world.createEntity(location, entityType.getEntityClass());
Packet<?> spawnEntityPacket;
if (entity instanceof EntityLiving) {
spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
} else {
spawnEntityPacket = new PacketPlayOutSpawnEntity(entity, ObjectType.getIdFor(entityType));
}
return new FakeEntity(entity.getId(), spawnEntityPacket);
}
use of org.bukkit.craftbukkit.v1_18_R2.entity in project FunnyGuilds by FunnyGuilds.
the class V1_11R1EntityAccessor method createFakeEntity.
@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
Preconditions.checkNotNull(entityType, "entity type can't be null!");
Preconditions.checkNotNull(location, "location can't be null!");
Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
CraftWorld world = ((CraftWorld) location.getWorld());
if (world == null) {
throw new IllegalStateException("location's world is null!");
}
Entity entity = world.createEntity(location, entityType.getEntityClass());
Packet<?> spawnEntityPacket;
if (entity instanceof EntityLiving) {
spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
} else {
spawnEntityPacket = new PacketPlayOutSpawnEntity(entity, ObjectType.getIdFor(entityType));
}
return new FakeEntity(entity.getId(), spawnEntityPacket);
}
Aggregations