use of me.jellysquid.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper in project lithium-fabric by CaffeineMC.
the class LithiumEntityCollisions method getBlockCollisions.
/**
* [VanillaCopy] CollisionView#getBlockCollisions(Entity, Box)
* This is a much, much faster implementation which uses simple collision testing against full-cube block shapes.
* Checks against the world border are replaced with our own optimized functions which do not go through the
* VoxelShape system.
*/
public static List<VoxelShape> getBlockCollisions(CollisionView world, Entity entity, Box box) {
ArrayList<VoxelShape> shapes = new ArrayList<>();
ChunkAwareBlockCollisionSweeper sweeper = new ChunkAwareBlockCollisionSweeper(world, entity, box);
while (sweeper.hasNext()) {
shapes.add(sweeper.next());
}
return shapes;
}
use of me.jellysquid.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper in project roadrunner by MaxNeedsSnacks.
the class LithiumEntityCollisions method doesBoxCollideWithBlocks.
/**
* See {@link LithiumEntityCollisions#getBlockCollisions(CollisionView, Entity, Box, BlockCollisionPredicate)}
*
* @return True if the box (possibly that of an entity's) collided with any blocks
*/
public static boolean doesBoxCollideWithBlocks(CollisionView world, Entity entity, Box box, BlockCollisionPredicate predicate) {
if (isBoxEmpty(box)) {
return false;
}
final ChunkAwareBlockCollisionSweeper sweeper = new ChunkAwareBlockCollisionSweeper(world, entity, box, predicate);
final VoxelShape shape = sweeper.getNextCollidedShape();
return shape != null;
}
use of me.jellysquid.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper in project roadrunner by MaxNeedsSnacks.
the class EntityMixin method isInsideWall.
/**
* @author JellySquid
* @reason Use optimized block volume iteration, avoid streams
*/
@Redirect(method = "isInsideWall", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockCollisions(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Box;Ljava/util/function/BiPredicate;)Ljava/util/stream/Stream;"))
public Stream<VoxelShape> isInsideWall(World world, Entity entity, Box box, BiPredicate<BlockState, BlockPos> biPredicate) {
final ChunkAwareBlockCollisionSweeper sweeper = new ChunkAwareBlockCollisionSweeper(world, (Entity) (Object) this, box, BlockCollisionPredicate.SUFFOCATES);
final VoxelShape shape = sweeper.getNextCollidedShape();
if (shape != null) {
return Stream.of(shape);
}
return Stream.empty();
}
use of me.jellysquid.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper in project lithium-fabric by CaffeineMC.
the class LithiumEntityCollisions method doesBoxCollideWithBlocks.
/**
* @return True if the box (possibly that of an entity's) collided with any blocks
*/
public static boolean doesBoxCollideWithBlocks(CollisionView world, Entity entity, Box box) {
final ChunkAwareBlockCollisionSweeper sweeper = new ChunkAwareBlockCollisionSweeper(world, entity, box);
final VoxelShape shape = sweeper.computeNext();
return shape != null && !shape.isEmpty();
}
Aggregations