use of org.hypertrace.entity.data.service.v1.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.hypertrace.entity.data.service.v1.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.hypertrace.entity.data.service.v1.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.hypertrace.entity.data.service.v1.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);
}
use of org.hypertrace.entity.data.service.v1.Entity in project FunnyGuilds by FunnyGuilds.
the class V1_12R1EntityAccessor 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