Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-16 21:10:17 +01:00
Added reasons for entities regaining health.
Dieser Commit ist enthalten in:
Ursprung
f518ced9ad
Commit
8a521ec629
@ -13,6 +13,7 @@ import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
// CraftBukkit end
|
||||
|
||||
public abstract class EntityHuman extends EntityLiving {
|
||||
@ -175,7 +176,7 @@ public abstract class EntityHuman extends EntityLiving {
|
||||
public void v() {
|
||||
// CraftBukkit - spawnMonsters -> allowMonsters
|
||||
if (!this.world.allowMonsters && this.health < 20 && this.ticksLived % 20 * 12 == 0) {
|
||||
this.b(1);
|
||||
this.b(1, RegainReason.REGEN);
|
||||
}
|
||||
|
||||
this.inventory.f();
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
// CraftBukkit end
|
||||
|
||||
public abstract class EntityLiving extends Entity {
|
||||
@ -313,10 +314,14 @@ public abstract class EntityLiving extends Entity {
|
||||
super.b(f, f1);
|
||||
}
|
||||
|
||||
// CraftBukkit start - delegate so we can handle providing a reason for health being regained
|
||||
public void b(int i) {
|
||||
// CraftBukkit start - Added event
|
||||
b(i, RegainReason.CUSTOM);
|
||||
}
|
||||
|
||||
public void b(int i, RegainReason regainReason) {
|
||||
if (this.health > 0) {
|
||||
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), i);
|
||||
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), i, regainReason);
|
||||
this.world.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
// CraftBukkit end
|
||||
|
||||
public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
@ -184,7 +185,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
}
|
||||
|
||||
public void b(int i) {
|
||||
super.b(i);
|
||||
super.b(i, RegainReason.EATING);
|
||||
}
|
||||
|
||||
public void a(boolean flag) {
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
@ -385,7 +386,7 @@ public class EntityWolf extends EntityAnimal {
|
||||
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
|
||||
}
|
||||
|
||||
this.b(((ItemFood) Item.PORK).k());
|
||||
this.b(((ItemFood) Item.PORK).k(), RegainReason.EATING);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren