File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
sources/net/minecraft/world/entity Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -533,10 +533,10 @@ index e7889c9c7b155db46730f5e168bb7fd3d1732a8c..334859c5ff7023c730513301cc11c983
533533 movement = this.maybeBackOffFromEdge(movement, type);
534534 Vec3 vec3 = this.collide(movement);
535535diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
536- index a71a153a91de5a564b946091d8d3ccbb330e4b89..195e1151f7b2a32d6c4eb67edd1952e38f58b266 100644
536+ index ff513e8c87bf42be756e46f4dbfec8dda2b8cb60..239c443ddc9bacc08a39a8ef2ab17016a2480549 100644
537537--- a/net/minecraft/world/entity/LivingEntity.java
538538+++ b/net/minecraft/world/entity/LivingEntity.java
539- @@ -3094 ,6 +3094 ,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
539+ @@ -3096 ,6 +3096 ,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
540540 return false;
541541 }
542542
Original file line number Diff line number Diff line change 654654 }
655655
656656 private boolean checkTotemDeathProtection(DamageSource damageSource) {
657- @@ -1274,18 +_,37 @@
657+ @@ -1274,18 +_,39 @@
658658 ItemStack itemStack = null;
659659 DeathProtection deathProtection = null;
660660
673673+ }
674674+ }
675675+
676- + org.bukkit.inventory.EquipmentSlot handSlot = (hand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand) : null;
677- + EntityResurrectEvent event = new EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), handSlot);
676+ + final org.bukkit.inventory.EquipmentSlot handSlot = (hand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand) : null;
677+ + final EntityResurrectEvent event = new EntityResurrectEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), handSlot);
678678+ event.setCancelled(itemStack == null);
679679+ this.level().getCraftServer().getPluginManager().callEvent(event);
680- +
681- + if (!event.isCancelled()) {
680+ + if (event.isCancelled()) {
681+ + // Set death protection to null as the event was cancelled. Prevent any attempt at ressurection.
682+ + deathProtection = null;
683+ + } else {
682684+ if (!itemInHand.isEmpty() && itemStack != null) { // Paper - only reduce item if actual totem was found
683685 itemInHand.shrink(1);
684686- break;
694696+ deathProtection = DeathProtection.TOTEM_OF_UNDYING;
695697+ }
696698+ // Paper end - fix NPE when pre-cancelled EntityResurrectEvent is uncancelled
697- + if (itemStack != null && this instanceof ServerPlayer serverPlayer) {
698- + // CraftBukkit end
699+ + if (itemStack != null && this instanceof final ServerPlayer serverPlayer) {
700+ + // CraftBukkit end
699701 serverPlayer.awardStat(Stats.ITEM_USED.get(itemStack.getItem()));
700702 CriteriaTriggers.USED_TOTEM.trigger(serverPlayer, itemStack);
701703 this.gameEvent(GameEvent.ITEM_INTERACT_FINISH);
You can’t perform that action at this time.
0 commit comments