Exemplo n.º 1
0
 @SubscribeEvent(priority = EventPriority.LOWEST)
 public void bedrockSave(LivingHurtEvent evt) {
   EntityLivingBase e = evt.entityLiving;
   if (evt.ammount < 1000) {
     if (e instanceof EntityPlayer) {
       if (ItemBedrockArmor.isWearingFullSuitOf(e)) {
         evt.ammount = Math.min(evt.ammount, 5);
         if (evt.ammount <= 1) {
           evt.ammount = 0;
           return;
         } else {
           Entity attacker = evt.source.getSourceOfDamage();
           if (attacker instanceof EntityPlayer) {
             ItemStack held = ((EntityPlayer) attacker).getCurrentEquippedItem();
             if (held != null
                 && held.getItem().getClass().getSimpleName().toLowerCase().contains("rapier")) {
               evt.ammount = 0;
               int dmg = held.getItem().getDamage(held);
               held.getItem().setDamage(held, dmg + 120);
             }
           }
         }
       }
     }
   }
 }
Exemplo n.º 2
0
 @SubscribeEvent
 public void onEntityDamage(LivingHurtEvent event) {
   /* Less fire damage */
   if (event.entity instanceof EntityPlayer) {
     EntityPlayer player = (EntityPlayer) event.entity;
     if (ElementManager.hasElement(player, ElementManager.FIRE)) {
       if (event.source == DamageSource.inFire || event.source == DamageSource.onFire) {
         if (player.getRNG().nextInt(3) == 0) {
           event.ammount = 1;
         } else {
           event.ammount = 0;
         }
       }
     }
   }
 }
 @Override
 public boolean applyEffect(
     EntityPlayer player,
     World world,
     ItemStack stack,
     ImbuementApplicationTypes matchedType,
     Object... params) {
   LivingHurtEvent event = (LivingHurtEvent) params[0];
   if (event.source.damageType.equals(dmgType)
       || (dmgType.equals("fire") && event.source.isFireDamage())
       || (dmgType.equals("magic") && event.source.isMagicDamage())
       || (dmgType.equals("explosion") && event.source.isExplosion())) {
     event.ammount *= 0.85f;
     return true;
   }
   return false;
 }
Exemplo n.º 4
0
  @SubscribeEvent
  public void onEntityHurt(LivingHurtEvent event) {
    EntityLivingBase entity = event.entityLiving;
    if (entity instanceof EntityPlayer) {
      float curMaxHealth =
          (float)
              ((EntityPlayer) entity)
                  .getEntityAttribute(SharedMonsterAttributes.maxHealth)
                  .getAttributeValue();
      float newMaxHealth = FoodStatsTFC.getMaxHealth((EntityPlayer) entity);
      float h = ((EntityPlayer) entity).getHealth();
      if (newMaxHealth != curMaxHealth)
        ((EntityPlayer) entity)
            .getEntityAttribute(SharedMonsterAttributes.maxHealth)
            .setBaseValue(newMaxHealth);
      if (newMaxHealth < h) ((EntityPlayer) entity).setHealth(newMaxHealth);
    }

    if (event.source == DamageSource.onFire) {
      event.ammount = 50;
    } else if (event.source == DamageSource.fall) {
      float healthMod = TFC_Core.getEntityMaxHealth(entity) / 1000f;
      event.ammount *= 80 * healthMod;
    } else if (event.source == DamageSource.drown) {
      event.ammount = 50;
    } else if (event.source == DamageSource.lava) {
      event.ammount = 100;
    } else if (event.source == DamageSource.inWall) {
      event.ammount = 100;
    } else if (event.source == DamageSource.fallingBlock) {
      event.ammount = 100;
    } else if (event.source.isExplosion()) {
      event.ammount *= 30;
    } else if (event.source == DamageSource.magic && entity.getHealth() > 25) {
      event.ammount = 25;
    } else if ("player".equals(event.source.damageType)
        || "mob".equals(event.source.damageType)
        || "arrow".equals(event.source.damageType)) {
      event.ammount = applyArmorCalculations(entity, event.source, event.ammount);
      if ("arrow".equals(event.source.damageType)) {
        Entity e = ((EntityDamageSourceIndirect) event.source).getSourceOfDamage();
        if (e instanceof EntityJavelin) {
          ((EntityJavelin) e).setDamageTaken((short) (((EntityJavelin) e).damageTaken + 10));
          if (((EntityJavelin) e).damageTaken >= ((EntityJavelin) e).pickupItem.getMaxDamage()) {
            e.setDead();
          }
        }
      }
    }
  }
  @ForgeSubscribe
  public void onEntityLivingAttack(LivingHurtEvent event) // TODO: Balancing!
      {
    if (event.source.getDamageType().equals("player")) {
      EntityPlayer player = (EntityPlayer) event.source.getSourceOfDamage();
      if (player.inventory.getCurrentItem() != null) {
        if (race.getClass(player).equals("Warrior")) {
          if ((player.inventory.getCurrentItem().getItem() instanceof ItemSword)) {
            event.ammount += Math.round(stats.getStrengthPoints(player) / 4);
          }
        }
        if (race.getClass(player).equals("Hunter")) {
          if ((player.inventory.getCurrentItem().getItem() instanceof ItemBow)) {
            event.ammount += Math.round(stats.getDexerityPoints(player) / 4);
          }
        }
        if (race.getClass(player).equals("Mage")) {
          if ((player.inventory.getCurrentItem().getItem() instanceof ItemWand)) {
            event.ammount += Math.round(stats.getIntelligencePoints(player) / 4);
          } else if ((player.inventory.getCurrentItem().getItem() instanceof ItemExcaliburMace)) {
            event.ammount += Math.round(stats.getIntelligencePoints(player) / 4);
          }
        }
        if (race.getClass(player).equals("Thief")) {
          if ((player.inventory.getCurrentItem().getItem() instanceof ItemClaw)) {
            event.ammount += Math.round(stats.getLuckPoints(player) / 4);
          }
        }
      }
    }

    if (event.source.getSourceOfDamage() instanceof EntityArrow) {
      if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity != null) {
        if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity
            instanceof EntityPlayer) {
          EntityPlayer player =
              (EntityPlayer) ((EntityArrow) event.source.getSourceOfDamage()).shootingEntity;
          if (race.getClass(player).equals("Hunter")) {
            event.ammount += Math.round(stats.getDexerityPoints(player) / 4);
          }
        }
      }
    }

    if (event.source.getSourceOfDamage() instanceof EntityShuricken) {
      if (((EntityShuricken) event.source.getSourceOfDamage()).getThrower() != null) {
        if (((EntityShuricken) event.source.getSourceOfDamage()).getThrower()
            instanceof EntityPlayer) {
          EntityPlayer player =
              (EntityPlayer) ((EntityShuricken) event.source.getSourceOfDamage()).getThrower();
          if (race.getClass(player).equals("Thief"))
            event.ammount += Math.round(StatKeeper.getLuckPoints(player) / 8);
        }
      }
    }
  }