Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-23 23:00:08 +01:00
156 Zeilen
5.4 KiB
Diff
156 Zeilen
5.4 KiB
Diff
--- ../work/decompile-8eb82bde//net/minecraft/server/EntityHorse.java Sun Nov 30 18:01:41 2014
|
|
+++ src/main/java/net/minecraft/server/EntityHorse.java Sun Nov 30 18:00:23 2014
|
|
@@ -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 bq = new EntitySelectorHorse();
|
|
@@ -36,6 +38,7 @@
|
|
private String bM;
|
|
private String[] bN = new String[3];
|
|
private boolean bO = false;
|
|
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
|
|
|
|
public EntityHorse(World world) {
|
|
super(world);
|
|
@@ -314,13 +317,13 @@
|
|
private int cX() {
|
|
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
|
|
}
|
|
|
|
public void loadChest() {
|
|
InventoryHorseChest inventoryhorsechest = this.inventoryChest;
|
|
|
|
- this.inventoryChest = new InventoryHorseChest("HorseChest", this.cX());
|
|
+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.cX(), this); // CraftBukkit - add this horse
|
|
this.inventoryChest.a(this.getName());
|
|
if (inventoryhorsechest != null) {
|
|
inventoryhorsechest.b(this);
|
|
@@ -485,7 +488,7 @@
|
|
}
|
|
|
|
public int getMaxDomestication() {
|
|
- return 100;
|
|
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
|
|
}
|
|
|
|
protected float bA() {
|
|
@@ -585,7 +588,7 @@
|
|
}
|
|
|
|
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
|
|
- this.heal(f);
|
|
+ this.heal(f, RegainReason.EATING); // CraftBukkit
|
|
flag = true;
|
|
}
|
|
|
|
@@ -692,11 +695,24 @@
|
|
|
|
public void die(DamageSource damagesource) {
|
|
super.die(damagesource);
|
|
+ /* CraftBukkit start - Handle chest dropping in dropDeathLoot below
|
|
if (!this.world.isStatic) {
|
|
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.isStatic) {
|
|
+ this.dropChest();
|
|
+ }
|
|
}
|
|
+ // CraftBukkit end
|
|
|
|
public void m() {
|
|
if (this.random.nextInt(200) == 0) {
|
|
@@ -706,7 +722,7 @@
|
|
super.m();
|
|
if (!this.world.isStatic) {
|
|
if (this.random.nextInt(900) == 0 && this.deathTicks == 0) {
|
|
- this.heal(1.0F);
|
|
+ this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
|
|
}
|
|
|
|
if (!this.cw() && 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) {
|
|
@@ -730,6 +746,14 @@
|
|
}
|
|
|
|
public void s_() {
|
|
+ // CraftBukkit start - Remove out of bounds horses, fixes an vanilla bug
|
|
+ if ( this.locY < -600 ) {
|
|
+ world.removeEntity(this);
|
|
+ MinecraftServer.getLogger().warn("Removed oob horse. Prevented a crash for Horse @ " + this.locX + ", " + this.locY + ", " + this.locZ);
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
super.s_();
|
|
if (this.world.isStatic && this.datawatcher.a()) {
|
|
this.datawatcher.e();
|
|
@@ -949,6 +973,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();
|
|
|
|
@@ -1001,6 +1026,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) {
|
|
@@ -1166,18 +1197,25 @@
|
|
|
|
public void v(int i) {
|
|
if (this.cE()) {
|
|
+ // CraftBukkit start - fire HorseJumpEvent, use event power
|
|
if (i < 0) {
|
|
i = 0;
|
|
- } else {
|
|
- this.bE = true;
|
|
- this.df();
|
|
}
|
|
-
|
|
+
|
|
+ float power;
|
|
if (i >= 90) {
|
|
- this.bp = 1.0F;
|
|
+ power = 1.0F;
|
|
} else {
|
|
- this.bp = 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.bE = true;
|
|
+ this.df();
|
|
+ this.bp = power;
|
|
}
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
}
|