Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Only hit at line of sight #9966

Merged
merged 1 commit into from
May 29, 2024
Merged

Only hit at line of sight #9966

merged 1 commit into from
May 29, 2024

Conversation

Raycoms
Copy link
Contributor

@Raycoms Raycoms commented May 29, 2024

Closes #
Closes #
Closes #

Changes proposed in this pull request:

  • Make Archer Trainees only shoot if there is a line of sight

[ x ] Yes I tested this before submitting it.
[ ] I also did a multiplayer test.

Review please

@@ -111,7 +114,8 @@ private IAIState selectTarget()
return DECIDE;
}
final BlockPos targetPos = archeryBuilding.getRandomShootingTarget(worker.getRandom());
if (targetPos == null)
if (targetPos == null || !WorldUtil.isBlockLoaded(world, targetPos) ||
!world.clip(new ClipContext(new Vec3(worker.getX(), worker.getEyeY(), worker.getZ()), new Vec3(targetPos.getX() + HALF_BLOCK, targetPos.getY() + HALF_BLOCK, targetPos.getZ() + HALF_BLOCK), ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, worker)).getBlockPos().equals(targetPos))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure to test it with different target blocks, it may be depending on the target shape that the check fails

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only use full block target blocks here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ok thought we had added tags

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the shooting position only

@Raycoms Raycoms merged commit 391b6eb into version/main May 29, 2024
2 checks passed
@Raycoms Raycoms deleted the hit-at-line-of-sight branch May 29, 2024 14:55
Raycoms added a commit that referenced this pull request Jul 27, 2024
Make Archer Trainees only shoot if there is a line of sight
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants