aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0199-Make-shield-blocking-delay-configurable.patch
blob: 9468400c1063220879646a7f4890c3de6962bec9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sat, 16 Jun 2018 01:18:16 -0500
Subject: [PATCH] Make shield blocking delay configurable


diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 21d00a73ad8287d61eda1ab91b88ea3264aff021..cccc60602360f25f0aeddbd16dad2bb63a1728a8 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3966,12 +3966,24 @@ public abstract class LivingEntity extends Entity implements Attackable {
         if (this.isUsingItem() && !this.useItem.isEmpty()) {
             Item item = this.useItem.getItem();
 
-            return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= 5;
+            return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem, this) - this.useItemRemaining >= getShieldBlockingDelay(); // Paper - Make shield blocking delay configurable
         } else {
             return false;
         }
     }
 
+    // Paper start - Make shield blocking delay configurable
+    public int shieldBlockingDelay = this.level().paperConfig().misc.shieldBlockingDelay;
+
+    public int getShieldBlockingDelay() {
+        return shieldBlockingDelay;
+    }
+
+    public void setShieldBlockingDelay(int shieldBlockingDelay) {
+        this.shieldBlockingDelay = shieldBlockingDelay;
+    }
+    // Paper end - Make shield blocking delay configurable
+
     public boolean isSuppressingSlidingDownLadder() {
         return this.isShiftKeyDown();
     }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index fe631496aa551a0029eff7b4d4a5daf16dddac50..bb81e0bfe0692e8f8421758cd21c003978853a08 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -842,5 +842,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
     public void setArrowsStuck(final int arrows) {
         this.getHandle().setArrowCount(arrows);
     }
+
+    @Override
+    public int getShieldBlockingDelay() {
+        return getHandle().getShieldBlockingDelay();
+    }
+
+    @Override
+    public void setShieldBlockingDelay(int delay) {
+        getHandle().setShieldBlockingDelay(delay);
+    }
     // Paper end
 }