Paper/nms-patches/EntityHorse.patch
2016-05-10 21:47:39 +10:00

110 lines
3.7 KiB
Diff

--- a/net/minecraft/server/EntityHorse.java
+++ b/net/minecraft/server/EntityHorse.java
@@ -7,6 +7,8 @@
import java.util.UUID;
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
+
public class EntityHorse extends EntityAnimal implements IInventoryListener, IJumpable {
private static final Predicate<Entity> bC = new Predicate() {
@@ -53,6 +55,7 @@
private String ce;
private String[] cf = new String[3];
private boolean cg = false;
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
public EntityHorse(World world) {
super(world);
@@ -321,7 +324,7 @@
public void loadChest() {
InventoryHorseChest inventoryhorsechest = this.inventoryChest;
- this.inventoryChest = new InventoryHorseChest("HorseChest", this.dJ());
+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.dJ(), this); // CraftBukkit
this.inventoryChest.a(this.getName());
if (inventoryhorsechest != null) {
inventoryhorsechest.b(this);
@@ -474,7 +477,7 @@
}
public int getMaxDomestication() {
- return 100;
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
}
protected float ce() {
@@ -564,7 +567,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
- this.heal(f);
+ this.heal(f, RegainReason.EATING); // CraftBukkit
flag = true;
}
@@ -655,11 +658,11 @@
}
public void die(DamageSource damagesource) {
- super.die(damagesource);
+ // super.die(damagesource); // Moved down
if (!this.world.isClientSide) {
this.dropChest();
}
-
+ super.die(damagesource); // CraftBukkit
}
public void n() {
@@ -670,7 +673,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.dn() && !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) {
@@ -921,6 +924,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();
@@ -976,6 +980,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) {
@@ -1148,6 +1158,18 @@
}
public void b(int i) {
+ // CraftBukkit start
+ float power;
+ if (i >= 90) {
+ power = 1.0F;
+ } else {
+ power = 0.4F + 0.4F * (float) i / 90.0F;
+ }
+ org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power);
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.canSlide = true;
this.setStanding();
}