use of com.simibubi.create.content.contraptions.components.actors.BlockBreakingMovementBehaviour in project Create by Creators-of-Create.
the class ContraptionCollider method isCollidingWithWorld.
public static boolean isCollidingWithWorld(Level world, TranslatingContraption contraption, BlockPos anchor, Direction movementDirection) {
for (BlockPos pos : contraption.getColliders(world, movementDirection)) {
BlockPos colliderPos = pos.offset(anchor);
if (!world.isLoaded(colliderPos))
return true;
BlockState collidedState = world.getBlockState(colliderPos);
StructureBlockInfo blockInfo = contraption.getBlocks().get(pos);
boolean emptyCollider = collidedState.getCollisionShape(world, pos).isEmpty();
if (collidedState.getBlock() instanceof CocoaBlock)
continue;
if (AllMovementBehaviours.contains(blockInfo.state.getBlock())) {
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state.getBlock());
if (movementBehaviour instanceof BlockBreakingMovementBehaviour) {
BlockBreakingMovementBehaviour behaviour = (BlockBreakingMovementBehaviour) movementBehaviour;
if (!behaviour.canBreak(world, colliderPos, collidedState) && !emptyCollider)
return true;
continue;
}
if (movementBehaviour instanceof HarvesterMovementBehaviour) {
HarvesterMovementBehaviour harvesterMovementBehaviour = (HarvesterMovementBehaviour) movementBehaviour;
if (!harvesterMovementBehaviour.isValidCrop(world, colliderPos, collidedState) && !harvesterMovementBehaviour.isValidOther(world, colliderPos, collidedState) && !emptyCollider)
return true;
continue;
}
}
if (AllBlocks.PULLEY_MAGNET.has(collidedState) && pos.equals(BlockPos.ZERO) && movementDirection == Direction.UP)
continue;
if (!collidedState.getMaterial().isReplaceable() && !emptyCollider) {
return true;
}
}
return false;
}
Aggregations