Paper/nms-patches/EntityHorseAbstract.patch

94 Zeilen
3.4 KiB
Diff

2016-11-17 02:41:03 +01:00
--- a/net/minecraft/server/EntityHorseAbstract.java
+++ b/net/minecraft/server/EntityHorseAbstract.java
2020-06-25 02:00:00 +02:00
@@ -6,6 +6,7 @@
2016-02-29 22:32:46 +01:00
import java.util.UUID;
2018-07-15 02:00:00 +02:00
import java.util.function.Predicate;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
2016-11-17 02:41:03 +01:00
2020-06-25 02:00:00 +02:00
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable, ISaddleable {
2016-11-17 02:41:03 +01:00
2020-06-25 02:00:00 +02:00
@@ -34,6 +35,7 @@
private float bR;
protected boolean bB = true;
protected int bC;
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
2019-04-23 04:00:00 +02:00
protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) {
2018-07-15 02:00:00 +02:00
super(entitytypes, world);
2020-06-25 02:00:00 +02:00
@@ -218,7 +220,7 @@
2017-05-14 04:00:00 +02:00
public void loadChest() {
2019-04-23 04:00:00 +02:00
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) {
2019-06-21 12:00:00 +02:00
inventorysubcontainer.b((IInventoryListener) this);
2019-04-23 04:00:00 +02:00
int i = Math.min(inventorysubcontainer.getSize(), this.inventoryChest.getSize());
2020-06-25 02:00:00 +02:00
@@ -334,7 +336,7 @@
}
public int getMaxDomestication() {
- return 100;
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
}
2019-04-23 04:00:00 +02:00
@Override
2020-06-25 02:00:00 +02:00
@@ -405,7 +407,7 @@
2016-11-17 02:41:03 +01:00
}
2016-11-17 02:41:03 +01:00
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
- this.heal(f);
+ this.heal(f, RegainReason.EATING); // CraftBukkit
flag = true;
}
2020-06-25 02:00:00 +02:00
@@ -481,7 +483,7 @@
2018-12-13 01:00:00 +01:00
super.movementTick();
2019-04-23 04:00:00 +02:00
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
}
2020-06-25 02:00:00 +02:00
if (this.fm()) {
@@ -718,6 +720,7 @@
2016-02-29 22:32:46 +01:00
if (this.getOwnerUUID() != null) {
2020-06-25 02:00:00 +02:00
nbttagcompound.a("Owner", this.getOwnerUUID());
2016-02-29 22:32:46 +01:00
}
+ nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
2016-02-29 22:32:46 +01:00
2016-11-17 02:41:03 +01:00
if (!this.inventoryChest.getItem(0).isEmpty()) {
nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound()));
2020-06-25 02:00:00 +02:00
@@ -745,6 +748,11 @@
if (uuid != null) {
this.setOwnerUUID(uuid);
}
+ // CraftBukkit start
+ if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) {
+ this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication");
+ }
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
2020-06-25 02:00:00 +02:00
if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) {
ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("SaddleItem"));
@@ -796,6 +804,18 @@
2019-04-23 04:00:00 +02:00
@Override
2018-07-15 02:00:00 +02:00
public void b(int i) {
2016-02-29 22:32:46 +01:00
+ // 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);
2016-02-29 22:32:46 +01:00
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.canSlide = true;
2020-06-25 02:00:00 +02:00
this.eV();
this.fo();