aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0064-Add-methods-for-working-with-arrows-stuck-in-living-.patch
blob: 6da97b4baac7d59e106733729e5cfdd91fed4239 (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
57
58
59
60
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: mrapple <tony@oc.tc>
Date: Sun, 25 Nov 2012 13:43:39 -0600
Subject: [PATCH] Add methods for working with arrows stuck in living entities

Upstream added methods for this, original methods are now
deprecated

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index ea7cbb5b5e7f140c06029ef05a01567d51b39f91..6bb32e4eab357c5f67a3daafa2de035b0d125635 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -289,10 +289,29 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
     }
 
     @Override
-    public void setArrowsInBody(int count) {
+    public void setArrowsInBody(final int count, final boolean fireEvent) { // Paper
         Preconditions.checkArgument(count >= 0, "New arrow amount must be >= 0");
+        if (!fireEvent) { // Paper
         this.getHandle().getEntityData().set(net.minecraft.world.entity.LivingEntity.DATA_ARROW_COUNT_ID, count);
+        // Paper start
+        } else {
+            this.getHandle().setArrowCount(count);
+        }
+        // Paper end
+    }
+
+    // Paper start - Add methods for working with arrows stuck in living entities
+    @Override
+    public void setNextArrowRemoval(final int ticks) {
+        Preconditions.checkArgument(ticks >= 0, "New amount of ticks before next arrow removal must be >= 0");
+        this.getHandle().removeArrowTime = ticks;
+    }
+
+    @Override
+    public int getNextArrowRemoval() {
+        return this.getHandle().removeArrowTime;
     }
+    // Paper end - Add methods for working with arrows stuck in living entities
 
     @Override
     public boolean isInvulnerable() {
@@ -833,4 +852,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
         this.getHandle().persistentInvisibility = invisible;
         this.getHandle().setSharedFlag(5, invisible);
     }
+
+    // Paper start
+    @Override
+    public int getArrowsStuck() {
+        return this.getHandle().getArrowCount();
+    }
+
+    @Override
+    public void setArrowsStuck(final int arrows) {
+        this.getHandle().setArrowCount(arrows);
+    }
+    // Paper end
 }