--- a/net/minecraft/util/SortedArraySet.java
+++ b/net/minecraft/util/SortedArraySet.java
@@ -22,13 +22,48 @@
             this.contents = (T[])castRawArray(new Object[initialCapacity]);
         }
     }
+    // Paper start - optimise removeIf
+    @Override
+    public boolean removeIf(java.util.function.Predicate<? super T> filter) {
+        // prev. impl used an iterator, which could be n^2 and creates garbage
+        int i = 0, len = this.size;
+        T[] backingArray = this.contents;
+
+        for (;;) {
+            if (i >= len) {
+                return false;
+            }
+            if (!filter.test(backingArray[i])) {
+                ++i;
+                continue;
+            }
+            break;
+        }
+
+        // we only want to write back to backingArray if we really need to
+
+        int lastIndex = i; // this is where new elements are shifted to
+
+        for (; i < len; ++i) {
+            T curr = backingArray[i];
+            if (!filter.test(curr)) { // if test throws we're screwed
+                backingArray[lastIndex++] = curr;
+            }
+        }
+
+        // cleanup end
+        Arrays.fill(backingArray, lastIndex, len, null);
+        this.size = lastIndex;
+        return true;
+    }
+    // Paper end - optimise removeIf
 
     public static <T extends Comparable<T>> SortedArraySet<T> create() {
         return create(10);
     }
 
     public static <T extends Comparable<T>> SortedArraySet<T> create(int initialCapacity) {
-        return new SortedArraySet<>(initialCapacity, Comparator.naturalOrder());
+        return new SortedArraySet<>(initialCapacity, Comparator.<T>naturalOrder()); // Paper - decompile fix
     }
 
     public static <T> SortedArraySet<T> create(Comparator<T> comparator) {
