Search in sources :

Example 1 with LivingArmourUpgradeExperience

use of WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience in project BloodMagic by WayofTime.

the class StatTrackerHandler method onExperiencePickup.

// Tracks: Experienced
@SubscribeEvent(priority = EventPriority.LOW)
public static void onExperiencePickup(PlayerPickupXpEvent event) {
    EntityPlayer player = event.getEntityPlayer();
    if (LivingArmour.hasFullSet(player)) {
        ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
        LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
        if (armour != null) {
            LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.experienced", chestStack);
            if (upgrade instanceof LivingArmourUpgradeExperience) {
                double modifier = ((LivingArmourUpgradeExperience) upgrade).getExperienceModifier();
                double exp = event.getOrb().xpValue * (1 + modifier);
                event.getOrb().xpValue = (int) Math.floor(exp) + (Math.random() < exp % 1 ? 1 : 0);
            }
            StatTrackerExperience.incrementCounter(armour, event.getOrb().xpValue);
        }
    }
}
Also used : LivingArmourUpgradeExperience(WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ItemLivingArmour (WayofTime.bloodmagic.item.armour.ItemLivingArmour)1 LivingArmour (WayofTime.bloodmagic.livingArmour.LivingArmour)1 LivingArmourUpgrade (WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade)1 LivingArmourUpgradeExperience (WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1