コード例 #1
0
 private boolean canEntityDespawnHere(EntityLiving entity) {
   LivingHandlerRegistry livingHandlerRegistry =
       MVELProfile.worldSettings().livingHandlerRegistry();
   List<LivingHandler> livingHandlers = livingHandlerRegistry.getLivingHandlers(entity.getClass());
   CountInfo info = CustomSpawner.spawnCounter.countEntities(entity.worldObj);
   if (!livingHandlers.isEmpty()) {
     for (LivingHandler livingHandler : livingHandlers) {
       if (livingHandler.canDespawn(entity, info)) {
         return true;
       }
     }
     return false;
   }
   return LivingHelper.canDespawn(entity);
 }
コード例 #2
0
 @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);
       }
     }
   }
 }
コード例 #3
0
 @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);
       }
     }
   }
 }