From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Paul Sauve <paul@technove.co>
Date: Sat, 23 Jan 2021 16:42:24 -0600
Subject: [PATCH] Remove streams

Airplane
Copyright (C) 2020 Technove LLC

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorBetterJob.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorBetterJob.java
index 72f1031e95b375823790f8cac4c102ba1205c9e8..e4821c1a7ceac582b019102230dbe5221add9050 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorBetterJob.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorBetterJob.java
@@ -3,6 +3,7 @@ package net.minecraft.world.entity.ai.behavior;
 import com.google.common.collect.ImmutableMap;
 import net.minecraft.core.GlobalPos;
 import net.minecraft.server.level.WorldServer;
+import net.minecraft.world.entity.EntityLiving;
 import net.minecraft.world.entity.ai.memory.MemoryModuleType;
 import net.minecraft.world.entity.ai.memory.MemoryStatus;
 import net.minecraft.world.entity.ai.village.poi.VillagePlaceType;
@@ -21,11 +22,31 @@ public class BehaviorBetterJob extends Behavior<EntityVillager> {
     protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) {
         GlobalPos globalpos = (GlobalPos) entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE).get();
 
+        // Airplane start - remove stream
+        /*
         worldserver.y().c(globalpos.getBlockPosition()).ifPresent((villageplacetype) -> {
             BehaviorUtil.a(entityvillager, (entityvillager1) -> {
                 return this.a(globalpos, villageplacetype, entityvillager1);
             }).reduce(entityvillager, BehaviorBetterJob::a);
         });
+         */
+        java.util.Optional<VillagePlaceType> optVillagePlaceType = worldserver.y().c(globalpos.getBlockPosition());
+        if (optVillagePlaceType.isPresent()) {
+            VillagePlaceType villageplacetype = optVillagePlaceType.get();
+            java.util.Optional<java.util.List<EntityLiving>> optList = entityvillager.getBehaviorController().getMemory(MemoryModuleType.MOBS);
+            if (optList.isPresent()) {
+                EntityVillager previous = entityvillager;
+                for (EntityLiving entityliving : optList.get()) {
+                    if (entityliving instanceof EntityVillager && entityliving != entityvillager && entityliving.isAlive()) {
+                        EntityVillager entityvillager1 = (EntityVillager) entityliving;
+                        if (this.a(globalpos, villageplacetype, entityvillager1)) {
+                            previous = a(previous, entityvillager1);
+                        }
+                    }
+                }
+            }
+        }
+        // Airplane end
     }
 
     private static EntityVillager a(EntityVillager entityvillager, EntityVillager entityvillager1) {
