54 lines
2.7 KiB
Diff
54 lines
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cryptite <cryptite@gmail.com>
|
|
Date: Sun, 27 Feb 2022 09:47:57 -0600
|
|
Subject: [PATCH] Add PlayerShieldDisableEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
index b1ae9b0d8b229e2a6797a173cb11ecc0f43e2592..48e933f5d3f35e845bf7b0eed86ce5d9c2114bcf 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -1609,6 +1609,7 @@ public abstract class Mob extends LivingEntity {
|
|
float f = 0.25F + (float) EnchantmentHelper.getBlockEfficiency(this) * 0.05F;
|
|
|
|
if (this.random.nextFloat() < f) {
|
|
+ if (!new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) player.getBukkitEntity(), getBukkitEntity()).callEvent()) return; // Slice
|
|
player.getCooldowns().addCooldown(Items.SHIELD, 100);
|
|
this.level.broadcastEntityEvent(player, (byte) 30);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
index 2483d7df7f1bf94344afd38b37602c645a4a2dff..e909d2cc08a5cea3a8b98ad6faf8eb65c33a35ef 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -949,7 +949,7 @@ public abstract class Player extends LivingEntity {
|
|
protected void blockUsingShield(LivingEntity attacker) {
|
|
super.blockUsingShield(attacker);
|
|
if (attacker.getMainHandItem().getItem() instanceof AxeItem) {
|
|
- this.disableShield(true);
|
|
+ this.disableShield(true, attacker); // Slice
|
|
}
|
|
|
|
}
|
|
@@ -1420,6 +1420,12 @@ public abstract class Player extends LivingEntity {
|
|
}
|
|
|
|
public void disableShield(boolean sprinting) {
|
|
+ // Slice start
|
|
+ disableShield(sprinting, null);
|
|
+ }
|
|
+
|
|
+ public void disableShield(boolean sprinting, @Nullable LivingEntity attacker) {
|
|
+ // Slice end
|
|
float f = 0.25F + (float) EnchantmentHelper.getBlockEfficiency(this) * 0.05F;
|
|
|
|
if (sprinting) {
|
|
@@ -1427,6 +1433,8 @@ public abstract class Player extends LivingEntity {
|
|
}
|
|
|
|
if (this.random.nextFloat() < f) {
|
|
+ org.bukkit.entity.Entity finalAttacker = attacker != null ? attacker.getBukkitEntity() : null; // Slice
|
|
+ if (!new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) getBukkitEntity(), finalAttacker).callEvent()) return; // Slice
|
|
this.getCooldowns().addCooldown(Items.SHIELD, 100);
|
|
this.stopUsingItem();
|
|
this.level.broadcastEntityEvent(this, (byte) 30);
|