Exemplo n.º 1
0
  @SubscribeEvent
  public void entityHurtEvent(LivingHurtEvent event) {
    if (!EtFuturum.enableDmgIndicator) return;
    int amount =
        MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
    if (amount <= 0) return;

    // If the attacker is a player spawn the hearts aligned and facing it
    if (event.source instanceof EntityDamageSource) {
      EntityDamageSource src = (EntityDamageSource) event.source;
      Entity attacker = src.getSourceOfDamage();
      if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
        EntityPlayer player = (EntityPlayer) attacker;
        Vec3 look = player.getLookVec();
        look.rotateAroundY((float) Math.PI / 2);
        for (int i = 0; i < amount; i++) {
          double x =
              event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
          double y =
              event.entityLiving.posY
                  + 1.5
                  + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
          double z =
              event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
          EtFuturum.networkWrapper.sendToAllAround(
              new BlackHeartParticlesMessage(x, y, z),
              new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
        }
      }
    }
  }
 /* ダメージソースのタイプ */
 public DamageSource thisDamageSource(Entity entity) {
   // 発射元のEntityがnullだった場合の対策を含む。
   if (entity instanceof EntityPlayer) {
     return EntityDamageSource.causePlayerDamage((EntityPlayer) entity);
   }
   return entity != null
       ? EntityDamageSource.causeIndirectMagicDamage(this, entity)
       : DamageSource.magic;
 }
  @SubscribeEvent
  public void onDeath(LivingDeathEvent ev) {
    if (!(ev.source instanceof EntityDamageSource)) {
      return;
    }
    EntityDamageSource eds = (EntityDamageSource) ev.source;

    Entity ent = eds.getEntity();
    if (!(ent instanceof EntityPlayer)) {
      return;
    }

    EntityPlayer epl = (EntityPlayer) ent;

    ItemStack wpn = epl.getHeldItem();
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 0) {
      return;
    }
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 1) {
      if (ev.entityLiving instanceof EntityDragon) {
        ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts, 1, 0), 0.5F);
      }
    }
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 2) {
      if (ev.entityLiving instanceof EntityDragon) {
        ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts, 1, 0), 0.8F);
      }
    }
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 3) {
      if (ev.entityLiving instanceof EntityDragon) {
        ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts, 1, 0), 1.0F);
      }
    }
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 4) {
      if (ev.entityLiving instanceof EntityDragon) {
        ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts, 2, 0), 0.5F);
      }
    }
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 5) {
      if (ev.entityLiving instanceof EntityDragon) {
        ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts, 2, 0), 0.8F);
      }
    }
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 6) {
      if (ev.entityLiving instanceof EntityDragon) {
        ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts, 2, 0), 1.0F);
      }
    }
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 7) {
      if (ev.entityLiving instanceof EntityDragon) {
        ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts, 3, 0), 0.5F);
      }
    }
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 8) {
      if (ev.entityLiving instanceof EntityDragon) {
        ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts, 3, 0), 0.8F);
      }
    }
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 9) {
      if (ev.entityLiving instanceof EntityDragon) {
        ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts, 3, 0), 1.0F);
      }
    }
    if (EnchantmentHelper.getEnchantmentLevel(KingdomKeys.HarvestHearts.effectId, wpn) == 10) {
      if (ev.entityLiving instanceof EntityDragon) {
        ev.entityLiving.entityDropItem(new ItemStack(AddedItems.KingdomHearts, 4, 0), 0.8F);
      }
    }
  }