mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 20:22:28 +00:00
Add LivingHealEvent called from EntityLivingBase.heal() Closes #1282
This commit is contained in:
1 parent
877ba864e7
commit
c9fe5ded9b
3 files changed
+60
-14
No files matched your search
@@ -29,6 +29,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
|
||||
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;
|
||||
@@ -246,4 +247,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 cpw.mods.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