Skip to content

Commit

Permalink
feat(utils): method for testing blocks contained in aabb
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Jun 27, 2022
1 parent 057eb93 commit dab0bfa
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/auioc/mcmod/arnicalib/utils/game/AABBUtils.java
@@ -1,6 +1,9 @@
package org.auioc.mcmod.arnicalib.utils.game;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.AABB;

public interface AABBUtils {
Expand All @@ -21,4 +24,16 @@ static AABB moveTo(AABB aabb, BlockPos pos) {
return moveTo(aabb, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D);
}

static boolean isEmpty(AABB aabb, Level level) {
return level.getBlockStates(aabb).allMatch(BlockState::isAir);
}

static boolean containsSolid(AABB aabb, Level level) {
return level.getBlockStates(aabb).map(BlockState::getMaterial).anyMatch(Material::isSolid);
}

static boolean containsLiquid(AABB aabb, Level level) {
return level.getBlockStates(aabb).map(BlockState::getMaterial).anyMatch(Material::isLiquid);
}

}

0 comments on commit dab0bfa

Please sign in to comment.