3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 15:20:11 +01:00
Paper/nms-patches/MobEffectList.patch

75 Zeilen
3.4 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/MobEffectList.java
+++ b/net/minecraft/server/MobEffectList.java
2018-12-25 22:00:00 +01:00
@@ -7,6 +7,11 @@
2020-06-25 02:00:00 +02:00
import java.util.UUID;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
+// CraftBukkit end
+
public class MobEffectList {
2020-06-25 02:00:00 +02:00
private final Map<AttributeBase, AttributeModifier> a = Maps.newHashMap();
2019-04-23 04:00:00 +02:00
@@ -21,7 +26,7 @@
2016-02-29 22:32:46 +01:00
}
2016-02-29 22:32:46 +01:00
public static int getId(MobEffectList mobeffectlist) {
2018-08-26 04:00:00 +02:00
- return IRegistry.MOB_EFFECT.a((Object) mobeffectlist);
+ return IRegistry.MOB_EFFECT.a(mobeffectlist); // CraftBukkit - decompile error
}
2019-04-23 04:00:00 +02:00
protected MobEffectList(MobEffectInfo mobeffectinfo, int i) {
@@ -32,11 +37,11 @@
public void tick(EntityLiving entityliving, int i) {
2016-02-29 22:32:46 +01:00
if (this == MobEffects.REGENERATION) {
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
- entityliving.heal(1.0F);
+ entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
}
2016-02-29 22:32:46 +01:00
} else if (this == MobEffects.POISON) {
if (entityliving.getHealth() > 1.0F) {
- entityliving.damageEntity(DamageSource.MAGIC, 1.0F);
+ entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
}
2016-02-29 22:32:46 +01:00
} else if (this == MobEffects.WITHER) {
entityliving.damageEntity(DamageSource.WITHER, 1.0F);
2019-04-23 04:00:00 +02:00
@@ -44,14 +49,25 @@
2016-11-17 02:41:03 +01:00
((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1));
2016-02-29 22:32:46 +01:00
} else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) {
2015-02-26 23:41:06 +01:00
if (!entityliving.world.isClientSide) {
- ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F);
+ // CraftBukkit start
+ EntityHuman entityhuman = (EntityHuman) entityliving;
+ int oldFoodLevel = entityhuman.getFoodData().foodLevel;
+
+ org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, i + 1 + oldFoodLevel);
+
+ if (!event.isCancelled()) {
+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
+ }
+
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
+ // CraftBukkit end
}
2020-06-25 02:00:00 +02:00
} else if ((this != MobEffects.HEAL || entityliving.di()) && (this != MobEffects.HARM || !entityliving.di())) {
if (this == MobEffects.HARM && !entityliving.di() || this == MobEffects.HEAL && entityliving.di()) {
entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i));
}
} else {
- entityliving.heal((float) Math.max(4 << i, 0));
+ entityliving.heal((float) Math.max(4 << i, 0), RegainReason.MAGIC); // CraftBukkit
}
}
2019-04-23 04:00:00 +02:00
@@ -72,7 +88,7 @@
}
} else {
j = (int) (d0 * (double) (4 << i) + 0.5D);
- entityliving.heal((float) j);
+ entityliving.heal((float) j, RegainReason.MAGIC); // CraftBukkit
}
}