First pass trying to optimise LivingUpdateEvent handlers, see issue #484

This commit is contained in:
Electroblob77
2020-08-03 22:47:08 +01:00
parent 9d8b0b3a90
commit 7401a8e3b4
6 changed files with 17 additions and 16 deletions
@@ -114,7 +114,8 @@ public class PotionContainment extends PotionMagicEffect {
@SubscribeEvent
public static void onLivingUpdateEvent(LivingUpdateEvent event){
if(event.getEntityLiving().getEntityData().hasKey(ENTITY_TAG)
// This is LAST-RESORT CLEANUP. It does NOT need checking every tick! We always check for the actual potion anyway.
if(event.getEntity().ticksExisted % 20 == 0 && event.getEntityLiving().getEntityData().hasKey(ENTITY_TAG)
&& !event.getEntityLiving().isPotionActive(WizardryPotions.containment)){
event.getEntityLiving().getEntityData().removeTag(ENTITY_TAG);
}