mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-03 23:07:40 +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
@ -24,6 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
int i = getRedstoneStrength(hitResult, hitResult.getLocation());
|
int i = getRedstoneStrength(hitResult, hitResult.getLocation());
|
||||||
int j = entity instanceof AbstractArrow ? 20 : 8;
|
int j = entity instanceof AbstractArrow ? 20 : 8;
|
||||||
+ // Paper start - Add TargetHitEvent
|
+ // Paper start - Add TargetHitEvent
|
||||||
|
+ boolean shouldAward = false;
|
||||||
+ if (entity instanceof Projectile) {
|
+ if (entity instanceof Projectile) {
|
||||||
+ final Projectile projectile = (Projectile) entity;
|
+ final Projectile projectile = (Projectile) entity;
|
||||||
+ final org.bukkit.craftbukkit.block.CraftBlock craftBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, hitResult.getBlockPos());
|
+ 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);
|
+ 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()) {
|
+ if (targetHitEvent.callEvent()) {
|
||||||
+ i = targetHitEvent.getSignalStrength();
|
+ i = targetHitEvent.getSignalStrength();
|
||||||
+ awardTargetHitCriteria(projectile, hitResult, i);
|
+ shouldAward = true;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ return i;
|
+ return i;
|
||||||
+ }
|
+ }
|
||||||
@ -40,3 +41,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
if (!world.getBlockTicks().hasScheduledTick(hitResult.getBlockPos(), state.getBlock())) {
|
if (!world.getBlockTicks().hasScheduledTick(hitResult.getBlockPos(), state.getBlock())) {
|
||||||
setOutputPower(world, state, i, hitResult.getBlockPos(), j);
|
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 New Issue
Block a user