2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityHorse.java
|
|
|
|
+++ b/net/minecraft/server/EntityHorse.java
|
2014-11-25 22:32:16 +01:00
|
|
|
@@ -4,6 +4,8 @@
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
|
|
|
|
+
|
|
|
|
public class EntityHorse extends EntityAnimal implements IInventoryListener {
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
private static final Predicate<Entity> bs = new Predicate() {
|
|
|
|
@@ -44,6 +46,7 @@
|
|
|
|
private String bO;
|
|
|
|
private String[] bP = new String[3];
|
|
|
|
private boolean bQ = false;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
|
|
|
|
|
|
|
|
public EntityHorse(World world) {
|
|
|
|
super(world);
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -320,13 +323,13 @@
|
|
|
|
private int cZ() {
|
2014-11-25 22:32:16 +01:00
|
|
|
int i = this.getType();
|
|
|
|
|
|
|
|
- return this.hasChest() && (i == 1 || i == 2) ? 17 : 2;
|
|
|
|
+ return this.hasChest() /* && (i == 1 || i == 2) */ ? 17 : 2; // CraftBukkit - Remove type check
|
|
|
|
}
|
|
|
|
|
2015-06-06 11:33:48 +02:00
|
|
|
public void loadChest() {
|
2014-11-25 22:32:16 +01:00
|
|
|
InventoryHorseChest inventoryhorsechest = this.inventoryChest;
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
- this.inventoryChest = new InventoryHorseChest("HorseChest", this.cZ());
|
|
|
|
+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.cZ(), this); // CraftBukkit - add this horse
|
2014-11-25 22:32:16 +01:00
|
|
|
this.inventoryChest.a(this.getName());
|
|
|
|
if (inventoryhorsechest != null) {
|
|
|
|
inventoryhorsechest.b(this);
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -491,7 +494,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getMaxDomestication() {
|
|
|
|
- return 100;
|
|
|
|
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
protected float bB() {
|
|
|
|
@@ -591,7 +594,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
|
|
|
|
- this.heal(f);
|
|
|
|
+ this.heal(f, RegainReason.EATING); // CraftBukkit
|
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -698,11 +701,24 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void die(DamageSource damagesource) {
|
|
|
|
super.die(damagesource);
|
|
|
|
+ /* CraftBukkit start - Handle chest dropping in dropDeathLoot below
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!this.world.isClientSide) {
|
2014-11-25 22:32:16 +01:00
|
|
|
this.dropChest();
|
|
|
|
}
|
|
|
|
+ // CraftBukkit end */
|
|
|
|
+ }
|
2014-12-02 18:53:34 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Add method
|
|
|
|
+ @Override
|
|
|
|
+ protected void dropDeathLoot(boolean flag, int i) {
|
|
|
|
+ super.dropDeathLoot(flag, i);
|
2014-12-02 18:53:34 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // Moved from die method above
|
2015-02-26 23:41:06 +01:00
|
|
|
+ if (!this.world.isClientSide) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.dropChest();
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
public void m() {
|
|
|
|
if (this.random.nextInt(200) == 0) {
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -712,7 +728,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
super.m();
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!this.world.isClientSide) {
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.random.nextInt(900) == 0 && this.deathTicks == 0) {
|
|
|
|
- this.heal(1.0F);
|
|
|
|
+ this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!this.cy() && this.passenger == null && 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) {
|
|
|
|
@@ -955,6 +971,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
nbttagcompound.setInt("Temper", this.getTemper());
|
|
|
|
nbttagcompound.setBoolean("Tame", this.isTame());
|
|
|
|
nbttagcompound.setString("OwnerUUID", this.getOwnerUUID());
|
|
|
|
+ nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
|
|
|
|
if (this.hasChest()) {
|
|
|
|
NBTTagList nbttaglist = new NBTTagList();
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -1007,6 +1024,12 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
this.setOwnerUUID(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) {
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -1172,18 +1195,25 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void v(int i) {
|
2015-02-26 23:41:06 +01:00
|
|
|
if (this.cG()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - fire HorseJumpEvent, use event power
|
|
|
|
if (i < 0) {
|
|
|
|
i = 0;
|
|
|
|
- } else {
|
2015-02-26 23:41:06 +01:00
|
|
|
- this.bG = true;
|
|
|
|
- this.dh();
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ float power;
|
|
|
|
if (i >= 90) {
|
2015-02-26 23:41:06 +01:00
|
|
|
- this.br = 1.0F;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ power = 1.0F;
|
|
|
|
} else {
|
2015-02-26 23:41:06 +01:00
|
|
|
- this.br = 0.4F + 0.4F * (float) i / 90.0F;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ power = 0.4F + 0.4F * (float) i / 90.0F;
|
|
|
|
+ }
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power);
|
2015-02-26 23:41:06 +01:00
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ this.bG = true;
|
|
|
|
+ this.dh();
|
|
|
|
+ this.br = power;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|