mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Add LivingHealEvent called from EntityLivingBase.heal()
This commit is contained in:
1 parent
f2b1622355
commit
44b21681e2
3 files changed
+58
-12
No files matched your search
@@ -40,6 +40,7 @@ import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
|
||||
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
|
||||
import net.minecraftforge.event.entity.item.ItemExpireEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingPackSizeEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent.AllowDespawn;
|
||||
@@ -378,4 +379,10 @@ public class ForgeEventFactory
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new WorldEvent.CreateSpawnPosition(world, settings));
|
||||
}
|
||||
|
||||
public static float onLivingHeal(EntityLivingBase entity, float amount)
|
||||
{
|
||||
LivingHealEvent event = new LivingHealEvent(entity, amount);
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.amount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.minecraftforge.event.entity.living;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
/**
|
||||
* LivingHealEvent is fired when an Entity is set to be healed. <br>
|
||||
* This event is fired whenever an Entity is healed in EntityLivingBase#heal(float)<br>
|
||||
* <br>
|
||||
* This event is fired via the {@link ForgeHooks#onLivingHeal(EntityLivingBase, float)}.<br>
|
||||
* <br>
|
||||
* {@link #amount} contains the amount of healing done to the Entity that was healed. <br>
|
||||
* <br>
|
||||
* This event is {@link Cancelable}.<br>
|
||||
* If this event is canceled, the Entity is not healed.<br>
|
||||
* <br>
|
||||
* This event does not have a result. {@link HasResult}<br>
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
||||
**/
|
||||
@Cancelable
|
||||
public class LivingHealEvent extends LivingEvent
|
||||
{
|
||||
public float amount;
|
||||
public LivingHealEvent(EntityLivingBase entity, float amount)
|
||||
{
|
||||
super(entity);
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user