mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-15 22:55:24 +01:00
More performance improvements.
This commit is contained in:
parent
d229e65388
commit
5874b3bcad
@ -146,9 +146,11 @@ public class StackingTask extends BukkitRunnable {
|
||||
int maxEntityStackSize = getEntityStackSize(livingEntity);
|
||||
|
||||
// Get similar entities around our entity and make sure those entities are both compatible and stackable.
|
||||
List<LivingEntity> stackableFriends = plugin.getEntityUtils().getSimilarEntitiesAroundEntity(livingEntity, location)
|
||||
.stream().filter(entity -> isEntityStackable(entity, location))
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
List<LivingEntity> stackableFriends = new LinkedList<>();
|
||||
for (LivingEntity entity : plugin.getEntityUtils().getSimilarEntitiesAroundEntity(livingEntity, location)) {
|
||||
if (!isEntityStackable(entity, location)) continue;
|
||||
stackableFriends.add(entity);
|
||||
}
|
||||
|
||||
// Loop through our similar stackable entities.
|
||||
for (LivingEntity entity : stackableFriends) {
|
||||
|
@ -254,9 +254,12 @@ public class EntityUtils {
|
||||
|
||||
public List<LivingEntity> getSimilarEntitiesAroundEntity(LivingEntity initialEntity, Location location) {
|
||||
// Create a list of all entities around the initial entity of the same type.
|
||||
List<LivingEntity> entityList = getNearbyEntities(location, searchRadius, stackWholeChunk)
|
||||
.stream().filter(entity -> entity.getType() == initialEntity.getType() && entity != initialEntity)
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
List<LivingEntity> entityList = new LinkedList<>();
|
||||
for (LivingEntity entity : getNearbyEntities(location, searchRadius, stackWholeChunk)) {
|
||||
if (entity.getType() != initialEntity.getType() || entity == initialEntity)
|
||||
continue;
|
||||
entityList.add(entity);
|
||||
}
|
||||
|
||||
if (stackFlyingDown && Methods.canFly(initialEntity))
|
||||
entityList.removeIf(entity -> entity.getLocation().getY() > initialEntity.getLocation().getY());
|
||||
|
Loading…
Reference in New Issue
Block a user