mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
75 lines
3.5 KiB
Diff
75 lines
3.5 KiB
Diff
--- ../work/decompile-8eb82bde//net/minecraft/server/MobEffectList.java 2014-11-28 17:43:43.257707431 +0000
|
|
+++ src/main/java/net/minecraft/server/MobEffectList.java 2014-11-28 17:38:23.000000000 +0000
|
|
@@ -6,6 +6,11 @@
|
|
import java.util.UUID;
|
|
import java.util.Map.Entry;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
|
+// CraftBukkit end
|
|
+
|
|
public class MobEffectList {
|
|
|
|
public static final MobEffectList[] byId = new MobEffectList[32];
|
|
@@ -63,6 +68,8 @@
|
|
}
|
|
|
|
this.L = j;
|
|
+ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType(this)); // CraftBukkit
|
|
+
|
|
}
|
|
|
|
public static MobEffectList b(String s) {
|
|
@@ -94,11 +101,11 @@
|
|
public void tick(EntityLiving entityliving, int i) {
|
|
if (this.id == MobEffectList.REGENERATION.id) {
|
|
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
|
|
- entityliving.heal(1.0F);
|
|
+ entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
|
|
}
|
|
} else if (this.id == MobEffectList.POISON.id) {
|
|
if (entityliving.getHealth() > 1.0F) {
|
|
- entityliving.damageEntity(DamageSource.MAGIC, 1.0F);
|
|
+ entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
|
|
}
|
|
} else if (this.id == MobEffectList.WITHER.id) {
|
|
entityliving.damageEntity(DamageSource.WITHER, 1.0F);
|
|
@@ -106,14 +113,25 @@
|
|
((EntityHuman) entityliving).applyExhaustion(0.025F * (float) (i + 1));
|
|
} else if (this.id == MobEffectList.SATURATION.id && entityliving instanceof EntityHuman) {
|
|
if (!entityliving.world.isStatic) {
|
|
- ((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
|
|
}
|
|
} else if ((this.id != MobEffectList.HEAL.id || entityliving.bl()) && (this.id != MobEffectList.HARM.id || !entityliving.bl())) {
|
|
if (this.id == MobEffectList.HARM.id && !entityliving.bl() || this.id == MobEffectList.HEAL.id && entityliving.bl()) {
|
|
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
|
|
}
|
|
|
|
}
|
|
@@ -132,7 +150,7 @@
|
|
}
|
|
} else {
|
|
j = (int) (d0 * (double) (4 << i) + 0.5D);
|
|
- entityliving.heal((float) j);
|
|
+ entityliving.heal((float) j, RegainReason.MAGIC); // CraftBukkit
|
|
}
|
|
|
|
}
|