mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Fix hit criteria advancement triggered before changing state (#10409)
* Fix hit criteria advancement being triggered before changing block state. * Rebase --------- Co-authored-by: Bjarne Koll <git@lynxplay.dev>
This commit is contained in:
parent
0d8e6831c3
commit
dd8fa8eefb
1 changed files with 12 additions and 1 deletions
|
@ -24,6 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
int i = getRedstoneStrength(hitResult, hitResult.getLocation());
|
||||
int j = entity instanceof AbstractArrow ? 20 : 8;
|
||||
+ // Paper start - Add TargetHitEvent
|
||||
+ boolean shouldAward = false;
|
||||
+ if (entity instanceof Projectile) {
|
||||
+ final Projectile projectile = (Projectile) entity;
|
||||
+ final org.bukkit.craftbukkit.block.CraftBlock craftBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, hitResult.getBlockPos());
|
||||
|
@ -31,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ final io.papermc.paper.event.block.TargetHitEvent targetHitEvent = new io.papermc.paper.event.block.TargetHitEvent((org.bukkit.entity.Projectile) projectile.getBukkitEntity(), craftBlock, blockFace, i);
|
||||
+ if (targetHitEvent.callEvent()) {
|
||||
+ i = targetHitEvent.getSignalStrength();
|
||||
+ awardTargetHitCriteria(projectile, hitResult, i);
|
||||
+ shouldAward = true;
|
||||
+ } else {
|
||||
+ return i;
|
||||
+ }
|
||||
|
@ -40,3 +41,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
if (!world.getBlockTicks().hasScheduledTick(hitResult.getBlockPos(), state.getBlock())) {
|
||||
setOutputPower(world, state, i, hitResult.getBlockPos(), j);
|
||||
}
|
||||
|
||||
+ // Paper start - Award Hit Criteria after Block Update
|
||||
+ if (shouldAward) {
|
||||
+ awardTargetHitCriteria((Projectile) entity, hitResult, i);
|
||||
+ }
|
||||
+ // Paper end - Award Hit Criteria after Block Update
|
||||
+
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue