Skip to content

Commit

Permalink
Initial work on fixes for squeezing
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Nov 28, 2024
1 parent 2cd58b5 commit 1a3a23b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public boolean isCompleted(BotConnection connection) {
var blockMeta = level.getBlockState(blockPosition);
var targetMiddleBlock = VectorHelper.topMiddleOfBlock(blockPosition.toVector3d(), blockMeta);
if (MathHelper.isOutsideTolerance(botPosition.getY(), targetMiddleBlock.getY(), 0.25)) {
System.out.println("Y level is off");
// We want to be on the same Y level
return false;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ public boolean canBreakBlockType(BlockType blockType) {
}

public boolean collidesWithAtEdge(SFVec3i block, BlockState blockState, Vector3d position) {
System.out.println("collidesWithAtEdge block: " + block + " blockState: " + blockState + " position: " + position);
if (DO_NOT_SQUEEZING_THROUGH_DIAGONALS && blockState.collisionShape().hasCollisions()) {
return true;
if (DO_NOT_SQUEEZING_THROUGH_DIAGONALS) {
return blockState.collisionShape().hasCollisions();
}

return blockState.collidesWith(block.toVector3i(), entity.dimensions().makeBoundingBox(position));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ public List<Triplet<SFVec3i, MovementSide, Vector3d>> listDiagonalCollisionBlock

for (var side : MovementSide.VALUES) {
// If these blocks are solid, the bot moves slower because the bot is running around a corner
var corner = direction.side(side).offset(FEET_POSITION_RELATIVE_BLOCK);
var collisionCheck = direction.offset(SFVec3i.ZERO).toVector3d().mul(0.5);
var corner = modifier.offsetIfJump(direction.side(side).offset(FEET_POSITION_RELATIVE_BLOCK));
var collisionCheck = modifier.offsetIfJump(direction.offset(FEET_POSITION_RELATIVE_BLOCK).toVector3d().mul(0.5));
for (var bodyOffset : BodyPart.VALUES) {
// Apply jump shift to target edge and offset for body part
list.add(new Triplet<>(
bodyOffset.offset(modifier.offsetIfJump(corner)),
bodyOffset.offset(corner),
side,
collisionCheck
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.soulfiremc.server.pathfinding.SFVec3i;
import lombok.RequiredArgsConstructor;
import org.cloudburstmc.math.vector.Vector3d;

@RequiredArgsConstructor
public enum MovementModifier {
Expand All @@ -43,4 +44,8 @@ public SFVec3i offset(SFVec3i vector) {
public SFVec3i offsetIfJump(SFVec3i vector) {
return this == MovementModifier.JUMP_UP_BLOCK ? vector.add(0, 1, 0) : vector;
}

public Vector3d offsetIfJump(Vector3d vector) {
return this == MovementModifier.JUMP_UP_BLOCK ? vector.add(0, 1, 0) : vector;
}
}

0 comments on commit 1a3a23b

Please sign in to comment.