use of org.spongepowered.api.util.AABB in project LanternServer by LanternPowered.
the class ShulkerBoxInteractionBehavior method validateOpenableSpace.
@Override
protected boolean validateOpenableSpace(BehaviorContext context, Location<World> location, List<Runnable> tasks) {
final Direction facing = location.getBlock().getTraitValue(LanternEnumTraits.FACING).get();
final Location<World> relLocation = location.getBlockRelative(facing);
final AABB aabb = relLocation.getExtent().getBlockSelectionBox(relLocation.getBlockPosition()).orElse(null);
if (aabb != null && getExtendedAABB(facing).offset(relLocation.getBlockPosition()).intersects(aabb)) {
final ReplaceableProperty replaceableProperty = relLocation.getProperty(ReplaceableProperty.class).orElse(null);
// Replaceable blocks will be replaced when opened
if (replaceableProperty != null && replaceableProperty.getValue()) {
tasks.add(() -> context.addBlockChange(BlockSnapshotBuilder.create().location(relLocation).blockState(BlockTypes.AIR.getDefaultState()).build()));
// TODO: Use break block pipeline instead
return true;
}
return false;
}
return true;
}
Aggregations