2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/MobEffectList.java
+++ b/net/minecraft/server/MobEffectList.java
2016-05-10 13:47:39 +02:00
@@ -7,6 +7,11 @@
2014-11-25 22:32:16 +01:00
import java.util.Map.Entry;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
2014-11-25 22:32:16 +01:00
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
+// CraftBukkit end
+
public class MobEffectList {
2016-02-29 22:32:46 +01:00
public static final RegistryMaterials<MinecraftKey, MobEffectList> REGISTRY = new RegistryMaterials();
2016-05-10 13:47:39 +02:00
@@ -24,7 +29,7 @@
2016-02-29 22:32:46 +01:00
}
2014-11-25 22:32:16 +01:00
2016-02-29 22:32:46 +01:00
public static int getId(MobEffectList mobeffectlist) {
- return MobEffectList.REGISTRY.a((Object) mobeffectlist);
+ return MobEffectList.REGISTRY.a(mobeffectlist); // CraftBukkit - decompile error
2014-11-25 22:32:16 +01:00
}
2016-05-10 13:47:39 +02:00
@Nullable
@@ -51,11 +56,11 @@
2014-11-25 22:32:16 +01:00
public void tick(EntityLiving entityliving, int i) {
2016-02-29 22:32:46 +01:00
if (this == MobEffects.REGENERATION) {
2014-11-25 22:32:16 +01:00
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) {
2014-11-25 22:32:16 +01:00
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) {
2014-11-25 22:32:16 +01:00
entityliving.damageEntity(DamageSource.WITHER, 1.0F);
2016-05-10 13:47:39 +02:00
@@ -63,14 +68,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) {
2014-11-25 22:32:16 +01:00
- ((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
}
2017-06-08 10:00:00 +02:00
} else if ((this != MobEffects.HEAL || entityliving.cc()) && (this != MobEffects.HARM || !entityliving.cc())) {
if (this == MobEffects.HARM && !entityliving.cc() || this == MobEffects.HEAL && entityliving.cc()) {
2014-11-25 22:32:16 +01:00
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
}
}
2016-05-10 13:47:39 +02:00
@@ -89,7 +105,7 @@
2014-11-25 22:32:16 +01:00
}
} else {
j = (int) (d0 * (double) (4 << i) + 0.5D);
- entityliving.heal((float) j);
+ entityliving.heal((float) j, RegainReason.MAGIC); // CraftBukkit
}
}
2016-05-10 13:47:39 +02:00
@@ -208,5 +224,10 @@
2016-02-29 22:32:46 +01:00
MobEffectList.REGISTRY.a(25, new MinecraftKey("levitation"), (new MobEffectList(true, 13565951)).c("effect.levitation").b(3, 2));
2017-05-14 04:00:00 +02:00
MobEffectList.REGISTRY.a(26, new MinecraftKey("luck"), (new MobEffectList(false, 3381504)).c("effect.luck").b(5, 2).j().a(GenericAttributes.j, "03C3C89D-7037-4B42-869F-B146BCB64D2E", 1.0D, 0));
MobEffectList.REGISTRY.a(27, new MinecraftKey("unluck"), (new MobEffectList(true, 12624973)).c("effect.unluck").b(6, 2).a(GenericAttributes.j, "CC5AF142-2BD2-4215-B636-2605AED11727", -1.0D, 0));
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start
2016-06-09 03:43:49 +02:00
+ for (Object effect : REGISTRY) {
+ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType((MobEffectList) effect));
2016-02-29 22:32:46 +01:00
+ }
+ // CraftBukkit end
}
}