/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.skree.content.mobdensity;

import com.skelril.nitro.probability.Probability;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.entity.living.animal.Animal;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.entity.CollideEntityEvent;

public class MobDensityListener {
    @Listener
    public void onEntityCollide(CollideEntityEvent event) {
        event.getEntities().forEach(e -> {
            if (e instanceof Animal && Probability.getChance(20) && event.getCause().containsType(e.getClass())) {
                e.offer(Keys.FIRE_TICKS, 20 * 20);
            }
        });
    }
}

@@ -261,49 +261,43 @@
 ort 
-com.skelril.nitro.probability.Probability
+org.spongepowered.api.data.key.Keys
 ;%0Aim
@@ -319,37 +319,37 @@
 powered.api.
-data.key.Keys
+entity.Entity
 ;%0Aimport org
@@ -504,16 +504,76 @@
 Event;%0A%0A
+import java.util.List;%0Aimport java.util.stream.Collectors;%0A%0A
 public c
@@ -684,155 +684,192 @@
     
-event.getEntities().forEach(e -%3E %7B%0A            if (e instanceof Animal && Probability.getChance(20) && event.getCause().containsType(e.getClass()))
+List%3CEntity%3E entities = event.getEntities().stream().filter(e -%3E e instanceof Animal).collect(Collectors.toList());%0A        if (entities.size() %3E 5) %7B%0A            entities.forEach(e -%3E
  %7B%0A 
@@ -931,16 +931,18 @@
        %7D
+);
 %0A       
@@ -939,23 +939,21 @@
 );%0A        %7D
-);
 %0A    %7D%0A%7D%0A

Kill animals if more than 5 collide at the same time