mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 20:30:28 +01:00
159 lines
5.9 KiB
Diff
159 lines
5.9 KiB
Diff
--- /home/matt/mc-dev-private//net/minecraft/server/EntityHorse.java 2015-02-26 22:40:22.559608140 +0000
|
|
+++ src/main/java/net/minecraft/server/EntityHorse.java 2015-02-26 22:40:22.563608140 +0000
|
|
@@ -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 {
|
|
|
|
private static final Predicate<Entity> bs = new Predicate() {
|
|
@@ -15,7 +17,7 @@
|
|
return this.a((Entity) object);
|
|
}
|
|
};
|
|
- private static final IAttribute attributeJumpStrength = (new AttributeRanged((IAttribute) null, "horse.jumpStrength", 0.7D, 0.0D, 2.0D)).a("Jump Strength").a(true);
|
|
+ public static final IAttribute attributeJumpStrength = (new AttributeRanged((IAttribute) null, "horse.jumpStrength", 0.7D, 0.0D, 2.0D)).a("Jump Strength").a(true); // CraftBukkit - public
|
|
private static final String[] bu = new String[] { null, "textures/entity/horse/armor/horse_armor_iron.png", "textures/entity/horse/armor/horse_armor_gold.png", "textures/entity/horse/armor/horse_armor_diamond.png"};
|
|
private static final String[] bv = new String[] { "", "meo", "goo", "dio"};
|
|
private static final int[] bw = new int[] { 0, 5, 7, 11};
|
|
@@ -29,7 +31,7 @@
|
|
public int bm;
|
|
public int bo;
|
|
protected boolean bp;
|
|
- private InventoryHorseChest inventoryChest;
|
|
+ public InventoryHorseChest inventoryChest; // CraftBukkit - public
|
|
private boolean bF;
|
|
protected int bq;
|
|
protected float br;
|
|
@@ -44,6 +46,7 @@
|
|
private String bO;
|
|
private String[] bP = new String[3];
|
|
private boolean bQ = false;
|
|
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
|
|
|
|
public EntityHorse(World world) {
|
|
super(world);
|
|
@@ -320,13 +323,13 @@
|
|
private int cZ() {
|
|
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
|
|
}
|
|
|
|
- private void loadChest() {
|
|
+ public void loadChest() { // CraftBukkit - public
|
|
InventoryHorseChest inventoryhorsechest = this.inventoryChest;
|
|
|
|
- this.inventoryChest = new InventoryHorseChest("HorseChest", this.cZ());
|
|
+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.cZ(), this); // CraftBukkit - add this horse
|
|
this.inventoryChest.a(this.getName());
|
|
if (inventoryhorsechest != null) {
|
|
inventoryhorsechest.b(this);
|
|
@@ -491,7 +494,7 @@
|
|
}
|
|
|
|
public int getMaxDomestication() {
|
|
- return 100;
|
|
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
|
|
}
|
|
|
|
protected float bB() {
|
|
@@ -591,7 +594,7 @@
|
|
}
|
|
|
|
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
|
|
- this.heal(f);
|
|
+ this.heal(f, RegainReason.EATING); // CraftBukkit
|
|
flag = true;
|
|
}
|
|
|
|
@@ -698,11 +701,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 m() {
|
|
if (this.random.nextInt(200) == 0) {
|
|
@@ -712,7 +728,7 @@
|
|
super.m();
|
|
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.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 @@
|
|
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();
|
|
|
|
@@ -1007,6 +1024,12 @@
|
|
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) {
|
|
@@ -1172,18 +1195,25 @@
|
|
|
|
public void v(int i) {
|
|
if (this.cG()) {
|
|
+ // CraftBukkit start - fire HorseJumpEvent, use event power
|
|
if (i < 0) {
|
|
i = 0;
|
|
- } else {
|
|
- this.bG = true;
|
|
- this.dh();
|
|
}
|
|
|
|
+ float power;
|
|
if (i >= 90) {
|
|
- this.br = 1.0F;
|
|
+ power = 1.0F;
|
|
} else {
|
|
- this.br = 0.4F + 0.4F * (float) i / 90.0F;
|
|
+ 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()) {
|
|
+ this.bG = true;
|
|
+ this.dh();
|
|
+ this.br = power;
|
|
}
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
}
|