@SubscribeEvent public void entityPersistance(AllowDespawn event) { if (!event.entity.worldObj.isRemote) { LivingHandlerRegistry livingHandlerRegistry = MVELProfile.worldSettings().livingHandlerRegistry(); @SuppressWarnings("unchecked") List<LivingHandler> livingHandlers = livingHandlerRegistry.getLivingHandlers( (Class<? extends EntityLiving>) event.entityLiving.getClass()); for (LivingHandler livingHandler : livingHandlers) { if (livingHandler != null && livingHandler.getDespawning() != null && livingHandler.getDespawning().isPresent()) { event.setResult(Result.DENY); } } } }
@SubscribeEvent public void despawner(LivingUpdateEvent event) { if (event.entityLiving instanceof EntityLiving && event.entityLiving.ticksExisted % 60 == 0 && !event.entityLiving.worldObj.isRemote) { LivingHandlerRegistry livingHandlerRegistry = MVELProfile.worldSettings().livingHandlerRegistry(); if (countInfo == null) { updateCountInfo(event.entityLiving.worldObj); } @SuppressWarnings("unchecked") List<LivingHandler> livingHandlers = livingHandlerRegistry.getLivingHandlers( (Class<? extends EntityLiving>) event.entityLiving.getClass()); for (LivingHandler livingHandler : livingHandlers) { if (livingHandler != null && livingHandler.getDespawning() != null && livingHandler.getDespawning().isPresent()) { livingHandler.despawnEntity((EntityLiving) event.entityLiving, countInfo); } } } }