@SubscribeEvent(priority = EventPriority.LOWEST) public void disallowDespawn(AllowDespawn ad) { EntityLivingBase e = ad.entityLiving; PotionEffect pe = e.getActivePotionEffect(RotaryCraft.freeze); if (pe == null) return; ad.setResult(Result.DENY); }
@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); } } } }