Skip to content

Commit

Permalink
fix magic arrow block collision
Browse files Browse the repository at this point in the history
fixes #170
  • Loading branch information
iron431 committed Oct 4, 2023
1 parent 77dda68 commit d784de0
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,19 @@ protected void onHitEntity(EntityHitResult entityHitResult) {
}
}

BlockPos lastHitBlock;

@Override
protected void onHit(HitResult result) {
//IronsSpellbooks.LOGGER.debug("onHit ({})", result.getType());

penetration++;
if (!level.isClientSide) {
if (result.getType() == HitResult.Type.ENTITY) {
var blockPos = new BlockPos(result.getLocation());
if (result.getType() == HitResult.Type.BLOCK && !blockPos.equals(lastHitBlock)) {
penetration++;
lastHitBlock = blockPos;
} else if (result.getType() == HitResult.Type.ENTITY) {
penetration++;
level.playSound(null, new BlockPos(position()), SoundRegistry.FORCE_IMPACT.get(), SoundSource.NEUTRAL, 2, .65f);
//IronsSpellbooks.LOGGER.debug("Playing Sound");
}
Expand Down

0 comments on commit d784de0

Please sign in to comment.