13
0
geforkt von Mirrors/Paper

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>
Dieser Commit ist enthalten in:
Cross 2024-04-12 20:42:00 +01:00
Ursprung 0d8e6831c3
Commit dd8fa8eefb

Datei anzeigen

@ -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;
}