First pass trying to optimise LivingUpdateEvent handlers, see issue #484
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -46,9 +46,10 @@ public class PotionDecay extends PotionMagicEffect {
|
||||
// amplifier of the potion effect, and is too slow for this purpose.
|
||||
|
||||
EntityLivingBase target = event.getEntityLiving();
|
||||
|
||||
if(!target.world.isRemote && target.isPotionActive(WizardryPotions.decay) && target.onGround
|
||||
&& target.ticksExisted % Constants.DECAY_SPREAD_INTERVAL == 0){
|
||||
|
||||
// Do the timing check first, it'll cut out 95% of calls to all subsequent conditions
|
||||
if(target.ticksExisted % Constants.DECAY_SPREAD_INTERVAL == 0 && !target.world.isRemote
|
||||
&& target.isPotionActive(WizardryPotions.decay) && target.onGround){
|
||||
|
||||
List<Entity> entities = target.world.getEntitiesWithinAABBExcludingEntity(target,
|
||||
target.getEntityBoundingBox());
|
||||
|
||||
Reference in New Issue
Block a user