3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 14:50:08 +01:00
Paper/nms-patches/EntityHorseAbstract.patch
2019-12-11 09:00:00 +11:00

94 Zeilen
3.4 KiB
Diff

--- a/net/minecraft/server/EntityHorseAbstract.java
+++ b/net/minecraft/server/EntityHorseAbstract.java
@@ -5,6 +5,7 @@
import java.util.UUID;
import java.util.function.Predicate;
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable {
@@ -33,6 +34,7 @@
private float bS;
protected boolean bD = true;
protected int bE;
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -210,7 +212,7 @@
public void loadChest() {
InventorySubcontainer inventorysubcontainer = this.inventoryChest;
- this.inventoryChest = new InventorySubcontainer(this.getChestSlots());
+ this.inventoryChest = new InventorySubcontainer(this.getChestSlots(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit
if (inventorysubcontainer != null) {
inventorysubcontainer.b((IInventoryListener) this);
int i = Math.min(inventorysubcontainer.getSize(), this.inventoryChest.getSize());
@@ -333,7 +335,7 @@
}
public int getMaxDomestication() {
- return 100;
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
}
@Override
@@ -394,7 +396,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
- this.heal(f);
+ this.heal(f, RegainReason.EATING); // CraftBukkit
flag = true;
}
@@ -470,7 +472,7 @@
super.movementTick();
if (!this.world.isClientSide && this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTicks == 0) {
- this.heal(1.0F);
+ this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
}
if (this.eO()) {
@@ -717,6 +719,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()));
@@ -744,6 +747,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");
@@ -801,6 +809,18 @@
@Override
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.eW();
}