aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0444-Don-t-use-streams-for-VoxelShape-calls.patch
blob: 480c131fb1de12c62bdfbca37b4b82ce30e215a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
From 9e8e04410f7dc524803de83707aef94dd74f2b48 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Sun, 21 Jul 2019 11:21:06 -0500
Subject: [PATCH] Don't use streams for VoxelShape calls


diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
index 2e460a7f6..3ed599ed7 100644
--- a/src/main/java/net/minecraft/server/Block.java
+++ b/src/main/java/net/minecraft/server/Block.java
@@ -4,6 +4,7 @@ import com.google.common.collect.UnmodifiableIterator;
 import it.unimi.dsi.fastutil.objects.Object2ByteLinkedOpenHashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Collections; // Paper
 import java.util.Objects;
 import java.util.Random;
 import java.util.stream.Stream;
@@ -75,7 +76,7 @@ public class Block implements IMaterial {
 
         while (iterator.hasNext()) {
             Entity entity = (Entity) iterator.next();
-            double d0 = VoxelShapes.a(EnumDirection.EnumAxis.Y, entity.getBoundingBox().d(0.0D, 1.0D, 0.0D), Stream.of(voxelshape), -1.0D);
+            double d0 = VoxelShapes.a(EnumDirection.EnumAxis.Y, entity.getBoundingBox().d(0.0D, 1.0D, 0.0D), Collections.singletonList(voxelshape), -1.0D); // Paper
 
             entity.enderTeleportTo(entity.locX, entity.locY + 1.0D + d0, entity.locZ);
         }
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 581c78e00..894a2a34b 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -704,22 +704,22 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
             AxisAlignedBB axisalignedbb = this.getBoundingBox();
 
             if (d0 != 0.0D || d1 != 0.0D || d2 != 0.0D) {
-                StreamAccumulator<VoxelShape> streamaccumulator = new StreamAccumulator<>(this.world.a(this, this.getBoundingBox(), d0, d1, d2));
+                List<VoxelShape> shapes = this.world.a_list(this, this.getBoundingBox(), d0, d1, d2); // Paper - Use list impl
 
                 if (d1 != 0.0D) {
-                    d1 = VoxelShapes.a(EnumDirection.EnumAxis.Y, this.getBoundingBox(), streamaccumulator.a(), d1);
+                    d1 = VoxelShapes.a(EnumDirection.EnumAxis.Y, this.getBoundingBox(), shapes, d1); // Paper - Use list impl
                     this.a(this.getBoundingBox().d(0.0D, d1, 0.0D));
                 }
 
                 if (d0 != 0.0D) {
-                    d0 = VoxelShapes.a(EnumDirection.EnumAxis.X, this.getBoundingBox(), streamaccumulator.a(), d0);
+                    d0 = VoxelShapes.a(EnumDirection.EnumAxis.X, this.getBoundingBox(), shapes, d0); // Paper - Use list impl
                     if (d0 != 0.0D) {
                         this.a(this.getBoundingBox().d(d0, 0.0D, 0.0D));
                     }
                 }
 
                 if (d2 != 0.0D) {
-                    d2 = VoxelShapes.a(EnumDirection.EnumAxis.Z, this.getBoundingBox(), streamaccumulator.a(), d2);
+                    d2 = VoxelShapes.a(EnumDirection.EnumAxis.Z, this.getBoundingBox(), shapes, d2); // Paper - Use list impl
                     if (d2 != 0.0D) {
                         this.a(this.getBoundingBox().d(0.0D, 0.0D, d2));
                     }
@@ -740,41 +740,41 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
                 d1 = (double) this.Q;
                 d2 = d9;
                 if (d7 != 0.0D || d1 != 0.0D || d9 != 0.0D) {
-                    StreamAccumulator<VoxelShape> streamaccumulator1 = new StreamAccumulator<>(this.world.a(this, this.getBoundingBox(), d7, d1, d9));
+                    List<VoxelShape> shapes = this.world.a_list(this, this.getBoundingBox(), d7, d1, d9); // Paper - Use list impl
                     AxisAlignedBB axisalignedbb2 = this.getBoundingBox();
                     AxisAlignedBB axisalignedbb3 = axisalignedbb2.b(d7, 0.0D, d9);
 
-                    d11 = VoxelShapes.a(EnumDirection.EnumAxis.Y, axisalignedbb3, streamaccumulator1.a(), d1);
+                    d11 = VoxelShapes.a(EnumDirection.EnumAxis.Y, axisalignedbb3, shapes, d1); // Paper - Use list impl
                     if (d11 != 0.0D) {
                         axisalignedbb2 = axisalignedbb2.d(0.0D, d11, 0.0D);
                     }
 
-                    double d15 = VoxelShapes.a(EnumDirection.EnumAxis.X, axisalignedbb2, streamaccumulator1.a(), d7);
+                    double d15 = VoxelShapes.a(EnumDirection.EnumAxis.X, axisalignedbb2, shapes, d7); // Paper - Use list impl
 
                     if (d15 != 0.0D) {
                         axisalignedbb2 = axisalignedbb2.d(d15, 0.0D, 0.0D);
                     }
 
-                    double d16 = VoxelShapes.a(EnumDirection.EnumAxis.Z, axisalignedbb2, streamaccumulator1.a(), d9);
+                    double d16 = VoxelShapes.a(EnumDirection.EnumAxis.Z, axisalignedbb2, shapes, d9); // Paper - Use list impl
 
                     if (d16 != 0.0D) {
                         axisalignedbb2 = axisalignedbb2.d(0.0D, 0.0D, d16);
                     }
 
                     AxisAlignedBB axisalignedbb4 = this.getBoundingBox();
-                    double d17 = VoxelShapes.a(EnumDirection.EnumAxis.Y, axisalignedbb4, streamaccumulator1.a(), d1);
+                    double d17 = VoxelShapes.a(EnumDirection.EnumAxis.Y, axisalignedbb4, shapes, d1); // Paper - Use list impl
 
                     if (d17 != 0.0D) {
                         axisalignedbb4 = axisalignedbb4.d(0.0D, d17, 0.0D);
                     }
 
-                    double d18 = VoxelShapes.a(EnumDirection.EnumAxis.X, axisalignedbb4, streamaccumulator1.a(), d7);
+                    double d18 = VoxelShapes.a(EnumDirection.EnumAxis.X, axisalignedbb4, shapes, d7); // Paper - Use list impl
 
                     if (d18 != 0.0D) {
                         axisalignedbb4 = axisalignedbb4.d(d18, 0.0D, 0.0D);
                     }
 
-                    double d19 = VoxelShapes.a(EnumDirection.EnumAxis.Z, axisalignedbb4, streamaccumulator1.a(), d9);
+                    double d19 = VoxelShapes.a(EnumDirection.EnumAxis.Z, axisalignedbb4, shapes, d9); // Paper - Use list impl
 
                     if (d19 != 0.0D) {
                         axisalignedbb4 = axisalignedbb4.d(0.0D, 0.0D, d19);
@@ -795,7 +795,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
                         this.a(axisalignedbb4);
                     }
 
-                    d1 = VoxelShapes.a(EnumDirection.EnumAxis.Y, this.getBoundingBox(), streamaccumulator1.a(), d1);
+                    d1 = VoxelShapes.a(EnumDirection.EnumAxis.Y, this.getBoundingBox(), shapes, d1); // Paper - Use list impl
                     if (d1 != 0.0D) {
                         this.a(this.getBoundingBox().d(0.0D, d1, 0.0D));
                     }
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
index 24ca35119..1268f8887 100644
--- a/src/main/java/net/minecraft/server/EntityTypes.java
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
@@ -3,6 +3,7 @@ package net.minecraft.server;
 import com.mojang.datafixers.DataFixUtils;
 import com.mojang.datafixers.types.Type;
 
+import java.util.List; // Paper
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
@@ -218,9 +219,9 @@ public class EntityTypes<T extends Entity> {
             axisalignedbb1 = axisalignedbb1.b(0.0D, -1.0D, 0.0D);
         }
 
-        Stream<VoxelShape> stream = iworldreader.b((Entity) null, axisalignedbb1);
+        List<VoxelShape> shapes = iworldreader.b_list(null, axisalignedbb1); // Paper - Use list impl
 
-        return 1.0D + VoxelShapes.a(EnumDirection.EnumAxis.Y, axisalignedbb, stream, flag ? -2.0D : -1.0D);
+        return 1.0D + VoxelShapes.a(EnumDirection.EnumAxis.Y, axisalignedbb, shapes, flag ? -2.0D : -1.0D); // Paper - Use list impl
     }
 
     public static void a(World world, @Nullable EntityHuman entityhuman, @Nullable Entity entity, @Nullable NBTTagCompound nbttagcompound) {
diff --git a/src/main/java/net/minecraft/server/IEntityAccess.java b/src/main/java/net/minecraft/server/IEntityAccess.java
index 175f242a8..c21f9c65d 100644
--- a/src/main/java/net/minecraft/server/IEntityAccess.java
+++ b/src/main/java/net/minecraft/server/IEntityAccess.java
@@ -2,6 +2,9 @@ package net.minecraft.server;
 
 import java.util.List;
 import java.util.Objects;
+import java.util.Arrays; // Paper
+import java.util.ArrayList; // Paper
+import java.util.Collections; // Paper
 import java.util.Set;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
@@ -16,18 +19,30 @@ public interface IEntityAccess {
     }
 
     default Stream<VoxelShape> a(@Nullable Entity entity, VoxelShape voxelshape, Set<Entity> set) {
+        return getEmptyCollisionShapes(entity, voxelshape, set).stream(); // Paper
+    }
+
+    // Paper start - Use lists instead of streams
+    default List<VoxelShape> getEmptyCollisionShapes(@Nullable Entity entity, VoxelShape voxelshape, Set<Entity> set) {
         if (voxelshape.isEmpty()) {
-            return Stream.empty();
+            return Collections.emptyList();
         } else {
             AxisAlignedBB axisalignedbb = voxelshape.getBoundingBox();
 
-            return this.getEntities(entity, axisalignedbb.g(0.25D)).stream().filter((entity1) -> {
-                return !set.contains(entity1) && (entity == null || !entity.x(entity1));
-            }).flatMap((entity1) -> {
-                return Stream.of(entity1.al(), entity == null ? null : entity.j(entity1)).filter(Objects::nonNull).filter((axisalignedbb1) -> {
-                    return axisalignedbb1.c(axisalignedbb);
-                }).map(VoxelShapes::a);
-            });
+            List<VoxelShape> shapes = new ArrayList<>();
+            for (Entity e : this.getEntities(entity, axisalignedbb.g(0.25D))) {
+                if (!set.contains(e) && (entity == null || !entity.x(e))) continue;
+
+                List<AxisAlignedBB> alignedBBs = Arrays.asList(e.al(), entity == null ? null : entity.j(e));
+                for (AxisAlignedBB axisAlignedBB : alignedBBs) {
+                    if (axisAlignedBB != null && axisAlignedBB.c(axisalignedbb)) {
+                        shapes.add(VoxelShapes.a(axisalignedbb));
+                    }
+                }
+            }
+
+            return shapes;
         }
     }
+    // Paper end
 }
diff --git a/src/main/java/net/minecraft/server/IWorldReader.java b/src/main/java/net/minecraft/server/IWorldReader.java
index 554825ec1..6a1d8afd0 100644
--- a/src/main/java/net/minecraft/server/IWorldReader.java
+++ b/src/main/java/net/minecraft/server/IWorldReader.java
@@ -1,6 +1,8 @@
 package net.minecraft.server;
 
+import java.util.ArrayList; // Paper
 import java.util.Collections;
+import java.util.List; // Paper
 import java.util.Set;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
@@ -111,7 +113,13 @@ public interface IWorldReader extends IBlockAccess {
         return this.a(entity, VoxelShapes.a(axisalignedbb));
     }
 
+    // Paper start - Use list instead of stream
     default Stream<VoxelShape> a(VoxelShape voxelshape, VoxelShape voxelshape1, boolean flag) {
+        return a_list(voxelshape, voxelshape1, flag).stream();
+    }
+
+    default List<VoxelShape> a_list(VoxelShape voxelshape, VoxelShape voxelshape1, boolean flag) {
+        // Paper end
         int i = MathHelper.floor(voxelshape.b(EnumDirection.EnumAxis.X)) - 1;
         int j = MathHelper.f(voxelshape.c(EnumDirection.EnumAxis.X)) + 1;
         int k = MathHelper.floor(voxelshape.b(EnumDirection.EnumAxis.Y)) - 1;
@@ -121,10 +129,13 @@ public interface IWorldReader extends IBlockAccess {
         WorldBorder worldborder = this.getWorldBorder();
         boolean flag1 = worldborder.b() < (double) i && (double) j < worldborder.d() && worldborder.c() < (double) i1 && (double) j1 < worldborder.e();
         VoxelShapeBitSet voxelshapebitset = new VoxelShapeBitSet(j - i, l - k, j1 - i1);
-        Predicate<VoxelShape> predicate = (voxelshape2) -> {
-            return !voxelshape2.isEmpty() && VoxelShapes.c(voxelshape, voxelshape2, OperatorBoolean.AND);
-        };
-        Stream<VoxelShape> stream = StreamSupport.stream(BlockPosition.MutableBlockPosition.b(i, k, i1, j - 1, l - 1, j1 - 1).spliterator(), false).map((blockposition_mutableblockposition) -> {
+
+        // Paper start - Use list instead of stream
+        List<VoxelShape> voxels = new ArrayList<>();
+
+        Iterable<BlockPosition.MutableBlockPosition> blockPosIterable = BlockPosition.MutableBlockPosition.b(i, k, i1, j - 1, l - 1, j1 - 1);
+        for (BlockPosition.MutableBlockPosition blockposition_mutableblockposition : blockPosIterable) {
+            // Paper end
             int k1 = blockposition_mutableblockposition.getX();
             int l1 = blockposition_mutableblockposition.getY();
             int i2 = blockposition_mutableblockposition.getZ();
@@ -132,53 +143,85 @@ public interface IWorldReader extends IBlockAccess {
             boolean flag3 = l1 == k || l1 == l - 1;
             boolean flag4 = i2 == i1 || i2 == j1 - 1;
 
-            if ((!flag2 || !flag3) && (!flag3 || !flag4) && (!flag4 || !flag2) && this.isLoaded(blockposition_mutableblockposition)) {
-                VoxelShape voxelshape2;
+            // Paper start - changes throughout this block to rid it of streams
+            VoxelShape shape;
 
+            if ((!flag2 || !flag3) && (!flag3 || !flag4) && (!flag4 || !flag2) && this.isLoaded(blockposition_mutableblockposition)) {
                 if (flag && !flag1 && !worldborder.a((BlockPosition) blockposition_mutableblockposition)) {
-                    voxelshape2 = VoxelShapes.b();
+                    shape = VoxelShapes.b();
                 } else {
-                    voxelshape2 = this.getType(blockposition_mutableblockposition).getCollisionShape(this, blockposition_mutableblockposition);
+                    shape = this.getType(blockposition_mutableblockposition).getCollisionShape(this, blockposition_mutableblockposition);
                 }
 
                 VoxelShape voxelshape3 = voxelshape1.a((double) (-k1), (double) (-l1), (double) (-i2));
 
-                if (VoxelShapes.c(voxelshape3, voxelshape2, OperatorBoolean.AND)) {
-                    return VoxelShapes.a();
-                } else if (voxelshape2 == VoxelShapes.b()) {
+                if (VoxelShapes.c(voxelshape3, shape, OperatorBoolean.AND)) {
+                    shape = VoxelShapes.a();
+                } else if (shape == VoxelShapes.b()) {
                     voxelshapebitset.a(k1 - i, l1 - k, i2 - i1, true, true);
-                    return VoxelShapes.a();
+                    shape = VoxelShapes.a();
                 } else {
-                    return voxelshape2.a((double) k1, (double) l1, (double) i2);
+                    shape = shape.a((double) k1, (double) l1, (double) i2);
                 }
             } else {
-                return VoxelShapes.a();
+                shape = VoxelShapes.a();
             }
-        }).filter(predicate);
 
-        return Stream.concat(stream, Stream.generate(() -> {
-            return new VoxelShapeWorldRegion(voxelshapebitset, i, k, i1);
-        }).limit(1L).filter(predicate));
+            if (!shape.isEmpty() && VoxelShapes.c(voxelshape, shape, OperatorBoolean.AND)) {
+                voxels.add(shape);
+            }
+        }
+
+        VoxelShapeWorldRegion worldShape = new VoxelShapeWorldRegion(voxelshapebitset, i, k, i1);
+        if (!worldShape.isEmpty() && VoxelShapes.c(voxelshape, worldShape, OperatorBoolean.AND)) {
+            voxels.add(worldShape);
+        }
+
+        return voxels;
+        // Paper end
     }
 
+    // Paper start - Use lists instead of streams
     default Stream<VoxelShape> a(@Nullable Entity entity, AxisAlignedBB axisalignedbb, double d0, double d1, double d2) {
-        return this.a(entity, axisalignedbb, Collections.emptySet(), d0, d1, d2);
+        return a_list(entity, axisalignedbb, d0, d1, d2).stream();
+    }
+
+    default List<VoxelShape> a_list(@Nullable Entity entity, AxisAlignedBB axisalignedbb, double d0, double d1, double d2) {
+        return this.a_list(entity, axisalignedbb, Collections.emptySet(), d0, d1, d2);
+        // Paper end
     }
 
+    // Paper start - Use lists instead of streams
     default Stream<VoxelShape> a(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set, double d0, double d1, double d2) {
+        return a_list(entity, axisalignedbb, set, d0, d1, d2).stream();
+    }
+    default List<VoxelShape> a_list(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set, double d0, double d1, double d2) {
+        // Paper end
         double d3 = 1.0E-7D;
         VoxelShape voxelshape = VoxelShapes.a(axisalignedbb);
         VoxelShape voxelshape1 = VoxelShapes.a(axisalignedbb.d(d0 > 0.0D ? -1.0E-7D : 1.0E-7D, d1 > 0.0D ? -1.0E-7D : 1.0E-7D, d2 > 0.0D ? -1.0E-7D : 1.0E-7D));
         VoxelShape voxelshape2 = VoxelShapes.b(VoxelShapes.a(axisalignedbb.b(d0, d1, d2).g(1.0E-7D)), voxelshape1, OperatorBoolean.ONLY_FIRST);
 
-        return this.a(entity, voxelshape2, voxelshape, set);
+        return this.a_list(entity, voxelshape2, voxelshape, set); // Paper - use list impl
     }
 
+    // Paper start - Use lists instead of streams
     default Stream<VoxelShape> b(@Nullable Entity entity, AxisAlignedBB axisalignedbb) {
-        return this.a(entity, VoxelShapes.a(axisalignedbb), VoxelShapes.a(), Collections.emptySet());
+        return b_list(entity, axisalignedbb).stream();
     }
 
+    default List<VoxelShape> b_list(@Nullable Entity entity, AxisAlignedBB axisalignedbb) {
+        return this.a_list(entity, VoxelShapes.a(axisalignedbb), VoxelShapes.a(), Collections.emptySet());
+        // Paper end
+    }
+
+    // Paper start - Use lists instead of streams
     default Stream<VoxelShape> a(@Nullable Entity entity, VoxelShape voxelshape, VoxelShape voxelshape1, Set<Entity> set) {
+        return this.a_list(entity, voxelshape, voxelshape1, set).stream();
+    }
+
+    default List<VoxelShape> a_list(@Nullable Entity entity, VoxelShape voxelshape, VoxelShape voxelshape1, Set<Entity> set) {
+        // Paper end
         boolean flag = entity != null && entity.bG();
         boolean flag1 = entity != null && this.i(entity);
 
@@ -186,7 +229,7 @@ public interface IWorldReader extends IBlockAccess {
             entity.n(!flag1);
         }
 
-        return this.a(voxelshape, voxelshape1, flag1);
+        return this.a_list(voxelshape, voxelshape1, flag1); // Paper - use list impl
     }
 
     default boolean i(Entity entity) {
@@ -212,7 +255,12 @@ public interface IWorldReader extends IBlockAccess {
     }
 
     default boolean a(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set) {
-        return this.a(entity, VoxelShapes.a(axisalignedbb), VoxelShapes.a(), set).allMatch(VoxelShape::isEmpty);
+        // Paper start - use lists instead of streams
+        for (VoxelShape shape : this.a_list(entity, VoxelShapes.a(axisalignedbb), VoxelShapes.a(), set)) {
+            if (!shape.isEmpty()) return false;
+        }
+        return true;
+        // Paper end
     }
 
     default boolean getCubes(@Nullable Entity entity, AxisAlignedBB axisalignedbb) {
diff --git a/src/main/java/net/minecraft/server/VoxelShapes.java b/src/main/java/net/minecraft/server/VoxelShapes.java
index 8c33bf159..7b51647f2 100644
--- a/src/main/java/net/minecraft/server/VoxelShapes.java
+++ b/src/main/java/net/minecraft/server/VoxelShapes.java
@@ -6,6 +6,7 @@ import com.google.common.math.IntMath;
 import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
 import it.unimi.dsi.fastutil.doubles.DoubleList;
 import java.util.Iterator;
+import java.util.List; // paper
 import java.util.Objects;
 import java.util.stream.Stream;
 
@@ -176,6 +177,18 @@ public final class VoxelShapes {
         return d0;
     }
 
+    // Paper start - copy of above without the use of the streams API
+    public static double a(EnumDirection.EnumAxis enumdirection_enumaxis, AxisAlignedBB axisalignedbb, List<VoxelShape> shapes, double d0) {
+        for (Iterator iterator = shapes.iterator(); iterator.hasNext(); d0 = ((VoxelShape) iterator.next()).a(enumdirection_enumaxis, axisalignedbb, d0)) {
+            // Paper end
+            if (Math.abs(d0) < 1.0E-7D) {
+                return 0.0D;
+            }
+        }
+
+        return d0;
+    }
+
     public static boolean b(VoxelShape voxelshape, VoxelShape voxelshape1, EnumDirection enumdirection) {
         if (voxelshape != b() && voxelshape1 != b()) {
             EnumDirection.EnumAxis enumdirection_enumaxis = enumdirection.k();
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 57b0f1a38..f5afaf42b 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -2387,10 +2387,20 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
         }
     }
 
+    // Paper start - Use lists instead of streams
     public Stream<VoxelShape> a(@Nullable Entity entity, VoxelShape voxelshape, VoxelShape voxelshape1, Set<Entity> set) {
-        Stream<VoxelShape> stream = IIBlockAccess.super.a(entity, voxelshape, voxelshape1, set); // CraftBukkit - decompile error
+        return a_list(entity, voxelshape, voxelshape1, set).stream();
+    }
 
-        return entity == null ? stream : Stream.concat(stream, this.a(entity, voxelshape, set));
+    public List<VoxelShape> a_list(@Nullable Entity entity, VoxelShape voxelshape, VoxelShape voxelshape1, Set<Entity> set) {
+        List<VoxelShape> shapes = IIBlockAccess.super.a_list(entity, voxelshape, voxelshape1, set); // CraftBukkit - decompile error // Paper - Use list impl
+        if (entity == null) {
+            return shapes;
+        } else {
+            shapes.addAll(this.getEmptyCollisionShapes(entity, voxelshape, set));
+            return shapes;
+        }
+        // Paper end
     }
 
     public List<Entity> getEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, @Nullable Predicate<? super Entity> predicate) {
-- 
2.22.0