summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityHorse.patch
blob: db8f0aad9c2b3c0f5dcaab85dc925628ce88aa06 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
--- a/net/minecraft/server/EntityHorse.java
+++ b/net/minecraft/server/EntityHorse.java
@@ -6,6 +6,8 @@
 import java.util.List;
 import java.util.UUID;
 
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
+
 public class EntityHorse extends EntityAnimal implements IInventoryListener, IJumpable {
 
     private static final Predicate<Entity> bB = new Predicate() {
@@ -52,6 +54,7 @@
     private String cd;
     private String[] ce = new String[3];
     private boolean cf = false;
+    public int maxDomestication = 100; // CraftBukkit - store max domestication value
 
     public EntityHorse(World world) {
         super(world);
@@ -318,7 +321,7 @@
     public void loadChest() {
         InventoryHorseChest inventoryhorsechest = this.inventoryChest;
 
-        this.inventoryChest = new InventoryHorseChest("HorseChest", this.dI());
+        this.inventoryChest = new InventoryHorseChest("HorseChest", this.dI(), this); // CraftBukkit
         this.inventoryChest.a(this.getName());
         if (inventoryhorsechest != null) {
             inventoryhorsechest.b(this);
@@ -470,7 +473,7 @@
     }
 
     public int getMaxDomestication() {
-        return 100;
+        return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
     }
 
     protected float cd() {
@@ -560,7 +563,7 @@
                     }
 
                     if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
-                        this.heal(f);
+                        this.heal(f, RegainReason.EATING); // CraftBukkit
                         flag = true;
                     }
 
@@ -652,11 +655,24 @@
 
     public void die(DamageSource damagesource) {
         super.die(damagesource);
+        /* CraftBukkit start - Handle chest dropping in dropDeathLoot below
         if (!this.world.isClientSide) {
             this.dropChest();
         }
+        // CraftBukkit end */
+    }
+
+    // CraftBukkit start - Add method
+    @Override
+    protected void dropDeathLoot(boolean flag, int i) {
+        super.dropDeathLoot(flag, i);
 
+        // Moved from die method above
+        if (!this.world.isClientSide) {
+            this.dropChest();
+        }
     }
+    // CraftBukkit end
 
     public void n() {
         if (this.random.nextInt(200) == 0) {
@@ -666,7 +682,7 @@
         super.n();
         if (!this.world.isClientSide) {
             if (this.random.nextInt(900) == 0 && this.deathTicks == 0) {
-                this.heal(1.0F);
+                this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
             }
 
             if (!this.dm() && !this.isVehicle() && this.random.nextInt(300) == 0 && this.world.getType(new BlockPosition(MathHelper.floor(this.locX), MathHelper.floor(this.locY) - 1, MathHelper.floor(this.locZ))).getBlock() == Blocks.GRASS) {
@@ -919,6 +935,7 @@
         if (this.getOwnerUUID() != null) {
             nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString());
         }
+        nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
 
         if (this.hasChest()) {
             NBTTagList nbttaglist = new NBTTagList();
@@ -974,6 +991,12 @@
             this.setOwnerUUID(UUID.fromString(s));
         }
 
+        // CraftBukkit start
+        if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) {
+            this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication");
+        }
+        // CraftBukkit end
+
         AttributeInstance attributeinstance = this.getAttributeMap().a("Speed");
 
         if (attributeinstance != null) {
@@ -1145,6 +1168,12 @@
     }
 
     public void b(int i) {
+        // CraftBukkit start
+        org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, this.jumpPower);
+        if (event.isCancelled()) {
+            return;
+        }
+        // CraftBukkit end
         this.canSlide = true;
         this.setStanding();
     }