3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 13:00:06 +01:00
Paper/nms-patches/EntityHorseAbstract.patch

115 Zeilen
3.7 KiB
Diff

--- a/net/minecraft/server/EntityHorseAbstract.java
+++ b/net/minecraft/server/EntityHorseAbstract.java
@@ -6,6 +6,7 @@
import java.util.List;
import java.util.UUID;
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable {
@@ -39,6 +40,7 @@
private float bS;
protected boolean bE = true;
protected int bF;
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
public EntityHorseAbstract(World world) {
super(world);
@@ -211,10 +213,10 @@
return 2;
}
- protected void dx() {
+ public void dx() { // PAIL: protected-> public, rename
InventoryHorseChest inventoryhorsechest = this.inventoryChest;
- this.inventoryChest = new InventoryHorseChest("HorseChest", this.di());
+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.di(), this); // CraftBukkit
this.inventoryChest.a(this.getName());
if (inventoryhorsechest != null) {
inventoryhorsechest.b(this);
@@ -354,7 +356,7 @@
}
public int getMaxDomestication() {
- return 100;
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
}
protected float ci() {
@@ -414,7 +416,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
- this.heal(f);
+ this.heal(f, RegainReason.EATING); // CraftBukkit
flag = true;
}
@@ -465,7 +467,7 @@
}
public void die(DamageSource damagesource) {
- super.die(damagesource);
+ // super.die(damagesource); // Moved down
if (!this.world.isClientSide && this.inventoryChest != null) {
for (int i = 0; i < this.inventoryChest.getSize(); ++i) {
ItemStack itemstack = this.inventoryChest.getItem(i);
@@ -476,6 +478,7 @@
}
}
+ super.die(damagesource); // CraftBukkit
}
public void n() {
@@ -486,7 +489,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.dE()) {
@@ -719,6 +722,7 @@
if (this.getOwnerUUID() != null) {
nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString());
}
+ nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
if (!this.inventoryChest.getItem(0).isEmpty()) {
nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound()));
@@ -745,6 +749,11 @@
if (!s.isEmpty()) {
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");
@@ -797,6 +806,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.dL();
}