예제 #1
0
 @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);
       }
     }
   }
 }
 public static Result canEntityDespawn(EntityLiving entity) {
   AllowDespawn event = new AllowDespawn(entity);
   MinecraftForge.EVENT_BUS.post(event);
   return event.getResult();
 }