Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import net.minecraft.world.entity.Entity;
- import net.minecraft.world.entity.player.Player;
- import net.minecraft.core.BlockPos;
- import net.minecraft.world.level.Level;
- import java.util.List;
- public class EntityHelper {
- public static List<Entity> getEntitiesAroundBlock(Level world, BlockPos blockPos, double radius) {
- // define the axis-aligned bounding box around the block
- AABB boundingBox = new AABB(
- blockPos.getX() - radius, blockPos.getY() - radius, blockPos.getZ() - radius,
- blockPos.getX() + radius, blockPos.getY() + radius, blockPos.getZ() + radius
- );
- // get entities within the bounding box
- List<Entity> entities = world.getEntities(null, boundingBox, entity -> !(entity instanceof Player));
- return entities;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment