|
3 | 3 | import com.mmodding.mmodding_lib.library.MModdingDamageSources; |
4 | 4 | import com.mmodding.mmodding_lib.library.worldgen.veins.CustomVeinType; |
5 | 5 | import net.minecraft.client.world.ClientWorld; |
| 6 | +import net.minecraft.server.network.ServerPlayerEntity; |
6 | 7 | import net.minecraft.server.world.ServerWorld; |
7 | 8 | import net.minecraft.util.Identifier; |
8 | 9 | import net.minecraft.util.math.BlockPos; |
| 10 | +import net.minecraft.util.math.Vec3d; |
9 | 11 | import net.minecraft.util.registry.Registry; |
10 | 12 | import net.minecraft.util.registry.RegistryKey; |
11 | 13 | import net.minecraft.world.World; |
12 | 14 | import net.minecraft.world.WorldAccess; |
13 | 15 | import net.minecraft.world.explosion.Explosion; |
14 | 16 |
|
15 | 17 | import java.util.List; |
| 18 | +import java.util.Set; |
| 19 | +import java.util.function.Predicate; |
| 20 | +import java.util.stream.Collectors; |
16 | 21 |
|
17 | 22 | public class WorldUtils { |
18 | 23 |
|
@@ -81,6 +86,13 @@ public static void pushExplosion(WorldAccess world, BlockPos pos, float power) { |
81 | 86 | explosion.affectWorld(false); |
82 | 87 | } |
83 | 88 |
|
| 89 | + public static Set<ServerPlayerEntity> getPlayersAround(ServerWorld serverWorld, Vec3d pos, Predicate<Double> length) { |
| 90 | + return serverWorld.getPlayers() |
| 91 | + .stream() |
| 92 | + .filter(player -> length.test(player.getPos().subtract(pos).length())) |
| 93 | + .collect(Collectors.toSet()); |
| 94 | + } |
| 95 | + |
84 | 96 | public interface TickTaskServer { |
85 | 97 |
|
86 | 98 | void mmodding_lib$doTaskAfter(long ticksToWait, Runnable run); |
|
0 commit comments