allow the robot to swing at anything that would block its movement

closes #1840
This commit is contained in:
payonel 2018-03-17 19:58:23 -07:00
parent 0095f33522
commit 4a83d4426d

View File

@ -150,6 +150,17 @@ trait Agent extends traits.WorldControl with traits.InventoryControl with traits
reason = reason.orElse(Option(what))
}
// all side attempts failed - but there could be a partial block that is hard to "see"
val (hasBlock, _) = blockContent(facing)
if (hasBlock) {
val blockPos = position.offset(facing)
val player = rotatedPlayer(facing, facing)
player.setSneaking(sneaky)
val (ok, why) = click(player, blockPos.x, blockPos.y, blockPos.z, facing.ordinal())
player.setSneaking(false)
return result(ok, why)
}
result(false, reason.orNull)
}