use of com.lying.variousoddities.api.event.LivingWakeUpEvent in project VariousOddities by Lyinginbedmon.
the class VOBusServer method onSleepingHurtEvent.
/**
* If a sleeping mob is harmed, wake them up.
* @param event
*/
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void onSleepingHurtEvent(LivingHurtEvent event) {
if (event.getAmount() > 0F && !event.isCanceled()) {
LivingEntity hurtEntity = event.getEntityLiving();
if (VOPotions.isSilenced(hurtEntity))
return;
wakeupEntitiesAround(hurtEntity);
EffectInstance sleepEffect = hurtEntity.getActivePotionEffect(VOPotions.SLEEP);
int tier = (sleepEffect == null || sleepEffect.getDuration() <= 0) ? -1 : sleepEffect.getAmplifier();
if (PotionSleep.isSleeping(hurtEntity) && tier < 1)
if (!MinecraftForge.EVENT_BUS.post(new LivingWakeUpEvent(hurtEntity, true)))
hurtEntity.removePotionEffect(VOPotions.SLEEP);
}
}
Aggregations