1818package com.lambda.util.world
1919
2020import com.lambda.context.SafeContext
21- import com.lambda.core.annotations.InternalApi
2221import com.lambda.util.math.distSq
2322import com.lambda.util.world.WorldUtils.internalGetBlockEntities
2423import com.lambda.util.world.WorldUtils.internalGetEntities
@@ -57,7 +56,6 @@ annotation class BlockMarker
5756 *
5857 * @return A map of positions to block states
5958 */
60- @OptIn(InternalApi ::class )
6159@BlockMarker
6260fun SafeContext.blockSearch (
6361 range : Vec3i ,
@@ -118,7 +116,6 @@ annotation class BlockEntityMarker
118116 * @param pos The position to start the search from
119117 * @param filter The predicate to filter entities
120118 */
121- @OptIn(InternalApi ::class )
122119@BlockEntityMarker
123120inline fun <reified T : BlockEntity > SafeContext.blockEntitySearch (
124121 range : Double = 64.0,
@@ -170,13 +167,12 @@ inline fun <reified T : Entity> SafeContext.closestEntity(
170167 *
171168 * @return A list of entity [T]
172169 */
173- @OptIn(InternalApi ::class )
174170@EntityMarker
175171inline fun <reified T : Entity > SafeContext.entitySearch (
176172 range : Double ,
177173 pos : BlockPos = player.blockPos,
178174 noinline filter : (T ) -> Boolean = { true },
179- ) = internalGetEntities<T >(pos.toFastVec(), range, predicate = filter)
175+ ) = internalGetEntities<T >(pos.toFastVec(), range, filter = filter)
180176
181177/* *
182178 * Initiates an optimized entity search operation in the world at the specified position
@@ -193,15 +189,14 @@ inline fun <reified T : Entity> SafeContext.entitySearch(
193189 * @param pos The position to start the search from
194190 * @param filter The predicate to filter entities
195191 *
196- * @return A list of entity [T]
192+ * @return A sequence of [T]
197193 */
198- @OptIn(InternalApi ::class )
199194@EntityMarker
200195inline fun <reified T : Entity > SafeContext.fastEntitySearch (
201196 range : Double ,
202197 pos : BlockPos = player.blockPos,
203198 noinline filter : (T ) -> Boolean = { true },
204- ) = internalGetFastEntities<T >(pos.toFastVec(), range, predicate = filter).toSet( )
199+ ) = internalGetFastEntities<T >(pos.toFastVec(), range, filter = filter)
205200
206201@DslMarker
207202annotation class FluidMarker
@@ -227,21 +222,19 @@ annotation class FluidMarker
227222 *
228223 * @return A map of positions to fluid states
229224 */
230- @OptIn(InternalApi ::class )
231225@FluidMarker
232226inline fun <reified T : Fluid > SafeContext.fluidSearch (
233227 range : Vec3i ,
234228 pos : BlockPos = player.blockPos,
235229 step : Vec3i = Vec3i (1, 1, 1),
236- noinline filter : (BlockPos , FluidState ) -> Boolean ,
230+ noinline filter : (BlockPos , FluidState ) -> Boolean = { _, _ -> true } ,
237231) =
238232 internalSearchFluids<T >(
239233 pos.toFastVec(),
240234 range.toFastVec(),
241235 step.toFastVec()
242- ) { fastPos, state ->
243- filter(fastPos.toBlockPos(), state)
244- }.mapKeys { it.key.toBlockPos() }
236+ ) { pos, state -> filter(pos.toBlockPos(), state) }
237+ .mapKeys { it.key.toBlockPos() }
245238
246239/* *
247240 * Searches for fluids in the world
0 commit comments