Search in sources :

Example 6 with LivingArmour

use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.

the class ItemLivingArmour method damageArmor.

@Override
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
    if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
        int preDamage = stack.getItemDamage();
        if (source.isUnblockable()) {
            return;
        }
        if (damage > this.getMaxDamage(stack) - this.getDamage(stack)) {
            // TODO: Syphon a load of LP.
            if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) {
                EntityPlayer player = (EntityPlayer) entity;
                SoulNetwork network = NetworkHelper.getSoulNetwork(player);
                network.syphonAndDamage(player, damage * 100);
            }
            return;
        }
        stack.damageItem(damage, entity);
        int receivedDamage = stack.getItemDamage() - preDamage;
        if (entity instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) entity;
            if (LivingArmour.hasFullSet(player)) {
                LivingArmour armour = ItemLivingArmour.getLivingArmour(stack);
                if (armour != null) {
                    StatTrackerRepairing.incrementCounter(armour, receivedDamage);
                }
            }
        }
    } else {
        stack.damageItem(damage, entity);
    }
    // TODO Armour shouldn't get damaged... for now
    return;
}
Also used : LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 7 with LivingArmour

use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.

the class LivingArmourHandler method onPlayerClick.

@SubscribeEvent
public static void onPlayerClick(PlayerInteractEvent event) {
    if (event.isCancelable()) {
        EntityPlayer player = event.getEntityPlayer();
        if (LivingArmour.hasFullSet(player)) {
            ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
            LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
            if (armour != null) {
                if (event.getHand() == EnumHand.OFF_HAND) {
                    LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.crippledArm", chestStack);
                    if (upgrade instanceof LivingArmourUpgradeCrippledArm) {
                        event.setCanceled(true);
                    }
                }
                if (event.getItemStack().getItemUseAction() == EnumAction.DRINK) {
                    ItemStack drinkStack = event.getItemStack();
                    // TODO: See if the item is a splash potion? Those should be usable.
                    LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.quenched", chestStack);
                    if (upgrade instanceof LivingArmourUpgradeQuenched) {
                        event.setCanceled(true);
                    }
                }
            }
        }
    }
}
Also used : ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgradeQuenched(WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeQuenched) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) EntityPlayer(net.minecraft.entity.player.EntityPlayer) LivingArmourUpgradeCrippledArm(WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeCrippledArm) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 8 with LivingArmour

use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.

the class LivingArmourHandler method onEntityHealed.

@SubscribeEvent
public static void onEntityHealed(LivingHealEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getEntity();
        if (LivingArmour.hasFullSet(player)) {
            ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
            LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
            if (armour != null) {
                double modifier = 1;
                LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.slowHeal", chestStack);
                if (upgrade instanceof LivingArmourUpgradeSlowHeal) {
                    modifier *= ((LivingArmourUpgradeSlowHeal) upgrade).getHealingModifier();
                }
                if (modifier != 1) {
                    event.setAmount((float) (event.getAmount() * modifier));
                }
            }
        }
    }
}
Also used : LivingArmourUpgradeSlowHeal(WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlowHeal) 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)

Example 9 with LivingArmour

use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.

the class LivingArmourHandler method onEntityDeath.

// Applies: Grim Reaper
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onEntityDeath(LivingDeathEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        if (LivingArmour.hasFullSet(player)) {
            ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
            LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
            if (armour != null) {
                StatTrackerGrimReaperSprint.incrementCounter(armour);
                LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.grimReaper", chestStack);
                if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint && ((LivingArmourUpgradeGrimReaperSprint) upgrade).canSavePlayer(player)) {
                    ((LivingArmourUpgradeGrimReaperSprint) upgrade).applyEffectOnRebirth(player);
                    event.setCanceled(true);
                    event.setResult(Event.Result.DENY);
                }
                armour.writeDirtyToNBT(ItemLivingArmour.getArmourTag(chestStack));
            }
        }
    }
}
Also used : 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)

Example 10 with LivingArmour

use of WayofTime.bloodmagic.livingArmour.LivingArmour in project BloodMagic by WayofTime.

the class StatTrackerHandler method blockBreakEvent.

// Tracks: Digging, DigSlowdown
@SubscribeEvent
public static void blockBreakEvent(BlockEvent.BreakEvent event) {
    EntityPlayer player = event.getPlayer();
    if (player != null) {
        if (LivingArmour.hasFullSet(player)) {
            ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
            if (chestStack.getItem() instanceof ItemLivingArmour) {
                LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
                if (armour != null) {
                    StatTrackerDigging.incrementCounter(armour);
                    LivingArmourUpgradeDigging.hasDug(armour);
                }
            }
        }
    }
}
Also used : ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

LivingArmour (WayofTime.bloodmagic.livingArmour.LivingArmour)25 ItemStack (net.minecraft.item.ItemStack)22 ItemLivingArmour (WayofTime.bloodmagic.item.armour.ItemLivingArmour)20 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 LivingArmourUpgrade (WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade)18 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)14 World (net.minecraft.world.World)5 BlockPos (net.minecraft.util.math.BlockPos)4 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)3 StatTracker (WayofTime.bloodmagic.livingArmour.StatTracker)2 StatTrackerGrimReaperSprint (WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint)2 LivingArmourUpgradeSelfSacrifice (WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice)2 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityArrow (net.minecraft.entity.projectile.EntityArrow)2 PotionEffect (net.minecraft.potion.PotionEffect)2 TileEntity (net.minecraft.tileentity.TileEntity)2 IBloodAltar (WayofTime.bloodmagic.altar.IBloodAltar)1 SoulNetwork (WayofTime.bloodmagic.core.data.SoulNetwork)1 ItemSentientArmour (WayofTime.bloodmagic.item.armour.ItemSentientArmour)1