Paper/nms-patches/EntityHorse.patch

110 lines
3.7 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityHorse.java
+++ b/net/minecraft/server/EntityHorse.java
2016-05-10 13:47:39 +02:00
@@ -7,6 +7,8 @@
2016-02-29 22:32:46 +01:00
import java.util.UUID;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
+
2016-02-29 22:32:46 +01:00
public class EntityHorse extends EntityAnimal implements IInventoryListener, IJumpable {
2016-06-09 03:43:49 +02:00
private static final Predicate<Entity> bD = new Predicate() {
@@ -52,6 +54,7 @@
private int ce;
private String cf;
private final String[] cg = new String[3];
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
public EntityHorse(World world) {
super(world);
2016-06-09 03:43:49 +02:00
@@ -320,7 +323,7 @@
public void loadChest() {
InventoryHorseChest inventoryhorsechest = this.inventoryChest;
2016-06-09 03:43:49 +02:00
- this.inventoryChest = new InventoryHorseChest("HorseChest", this.dN());
+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.dN(), this); // CraftBukkit
this.inventoryChest.a(this.getName());
if (inventoryhorsechest != null) {
inventoryhorsechest.b(this);
2016-06-09 03:43:49 +02:00
@@ -473,7 +476,7 @@
}
public int getMaxDomestication() {
- return 100;
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
}
2016-06-09 03:43:49 +02:00
protected float ch() {
@@ -563,7 +566,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
- this.heal(f);
+ this.heal(f, RegainReason.EATING); // CraftBukkit
flag = true;
}
2016-06-09 03:43:49 +02:00
@@ -654,11 +657,11 @@
2016-04-26 01:26:20 +02:00
}
public void die(DamageSource damagesource) {
2016-04-26 01:26:20 +02:00
- super.die(damagesource);
+ // super.die(damagesource); // Moved down
2015-02-26 23:41:06 +01:00
if (!this.world.isClientSide) {
this.dropChest();
}
2016-04-26 01:26:20 +02:00
-
+ super.die(damagesource); // CraftBukkit
}
2016-02-29 22:32:46 +01:00
public void n() {
2016-06-09 03:43:49 +02:00
@@ -669,7 +672,7 @@
2016-02-29 22:32:46 +01:00
super.n();
2015-02-26 23:41:06 +01:00
if (!this.world.isClientSide) {
if (this.random.nextInt(900) == 0 && this.deathTicks == 0) {
- this.heal(1.0F);
+ this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
}
2016-06-09 03:43:49 +02:00
if (!this.dr() && !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) {
@@ -929,6 +932,7 @@
2016-02-29 22:32:46 +01:00
if (this.getOwnerUUID() != null) {
nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString());
}
+ nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
2016-02-29 22:32:46 +01:00
if (this.hasChest()) {
NBTTagList nbttaglist = new NBTTagList();
2016-06-09 03:43:49 +02:00
@@ -984,6 +988,12 @@
2016-02-29 22:32:46 +01:00
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) {
2016-06-09 03:43:49 +02:00
@@ -1156,6 +1166,18 @@
2016-02-29 22:32:46 +01:00
}
2016-02-29 22:32:46 +01:00
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);
2016-02-29 22:32:46 +01:00
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.canSlide = true;
this.setStanding();
}