Skip to content

Commit 51c5c3c

Browse files
committed
Can pass null array to not store
1 parent 519714b commit 51c5c3c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

common/src/main/kotlin/com/lambda/util/collections/Extensions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ package com.lambda.util.collections
1414
* @param predicate The predicate function that determines whether an element should be included based on its type and other criteria.
1515
*/
1616
inline fun <reified R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(
17-
destination: C,
17+
destination: C? = null,
1818
predicate: (R) -> Boolean
1919
) {
20+
if (destination == null) return
2021
for (element in this) if (element is R && predicate(element)) destination.add(element)
2122
}

common/src/main/kotlin/com/lambda/util/world/EntityUtils.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object EntityUtils {
2525
var closest: T? = null
2626
var closestDistance = Double.MAX_VALUE
2727

28-
val iterator: (T) -> Any = {
28+
val iterator: (T) -> Unit = {
2929
val distance = it.squaredDistanceTo(pos)
3030
if (distance < closestDistance) {
3131
closest = it
@@ -72,7 +72,7 @@ object EntityUtils {
7272
inline fun <reified T : Entity> SafeContext.getFastEntities(
7373
pos: Vec3d,
7474
distance: Double,
75-
pointer: MutableList<T>,
75+
pointer: MutableList<T>? = null,
7676
noinline predicate: (T) -> Boolean = { true },
7777
noinline iterator: (T) -> Unit = { },
7878
) {
@@ -107,7 +107,7 @@ object EntityUtils {
107107
* @return A list of entities of type [T] within the specified distance from the position without the player.
108108
*/
109109
inline fun <reified T : Entity> SafeContext.getEntities(
110-
pointer: MutableList<T>,
110+
pointer: MutableList<T>? = null,
111111
noinline predicate: (T) -> Boolean = { true },
112112
noinline iterator: (T) -> Unit = { },
113113
) {

0 commit comments

Comments
 (0)