Guest User

Untitled

a guest
Jun 4th, 2024
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import net.minecraft.world.entity.Entity;
  2. import net.minecraft.world.entity.player.Player;
  3. import net.minecraft.core.BlockPos;
  4. import net.minecraft.world.level.Level;
  5. import java.util.List;
  6. public class EntityHelper {
  7. public static List<Entity> getEntitiesAroundBlock(Level world, BlockPos blockPos, double radius) {
  8. // define the axis-aligned bounding box around the block
  9. AABB boundingBox = new AABB(
  10. blockPos.getX() - radius, blockPos.getY() - radius, blockPos.getZ() - radius,
  11. blockPos.getX() + radius, blockPos.getY() + radius, blockPos.getZ() + radius
  12. );
  13. // get entities within the bounding box
  14. List<Entity> entities = world.getEntities(null, boundingBox, entity -> !(entity instanceof Player));
  15. return entities;
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment