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);
|
int maxEntityStackSize = getEntityStackSize(livingEntity);
|
||||||
|
|
||||||
// Get similar entities around our entity and make sure those entities are both compatible and stackable.
|
// Get similar entities around our entity and make sure those entities are both compatible and stackable.
|
||||||
List<LivingEntity> stackableFriends = plugin.getEntityUtils().getSimilarEntitiesAroundEntity(livingEntity, location)
|
List<LivingEntity> stackableFriends = new LinkedList<>();
|
||||||
.stream().filter(entity -> isEntityStackable(entity, location))
|
for (LivingEntity entity : plugin.getEntityUtils().getSimilarEntitiesAroundEntity(livingEntity, location)) {
|
||||||
.collect(Collectors.toCollection(LinkedList::new));
|
if (!isEntityStackable(entity, location)) continue;
|
||||||
|
stackableFriends.add(entity);
|
||||||
|
}
|
||||||
|
|
||||||
// Loop through our similar stackable entities.
|
// Loop through our similar stackable entities.
|
||||||
for (LivingEntity entity : stackableFriends) {
|
for (LivingEntity entity : stackableFriends) {
|
||||||
|
@ -254,9 +254,12 @@ public class EntityUtils {
|
|||||||
|
|
||||||
public List<LivingEntity> getSimilarEntitiesAroundEntity(LivingEntity initialEntity, Location location) {
|
public List<LivingEntity> getSimilarEntitiesAroundEntity(LivingEntity initialEntity, Location location) {
|
||||||
// Create a list of all entities around the initial entity of the same type.
|
// Create a list of all entities around the initial entity of the same type.
|
||||||
List<LivingEntity> entityList = getNearbyEntities(location, searchRadius, stackWholeChunk)
|
List<LivingEntity> entityList = new LinkedList<>();
|
||||||
.stream().filter(entity -> entity.getType() == initialEntity.getType() && entity != initialEntity)
|
for (LivingEntity entity : getNearbyEntities(location, searchRadius, stackWholeChunk)) {
|
||||||
.collect(Collectors.toCollection(LinkedList::new));
|
if (entity.getType() != initialEntity.getType() || entity == initialEntity)
|
||||||
|
continue;
|
||||||
|
entityList.add(entity);
|
||||||
|
}
|
||||||
|
|
||||||
if (stackFlyingDown && Methods.canFly(initialEntity))
|
if (stackFlyingDown && Methods.canFly(initialEntity))
|
||||||
entityList.removeIf(entity -> entity.getLocation().getY() > initialEntity.getLocation().getY());
|
entityList.removeIf(entity -> entity.getLocation().getY() > initialEntity.getLocation().getY());
|
||||||
|
Loading…
Reference in New Issue
Block a user