Search in sources :

Example 16 with LivingArmour

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

the class GenericHandler method onEntityHurt.

@SubscribeEvent
public static void onEntityHurt(LivingHurtEvent event) {
    if (event.getEntity().getEntityWorld().isRemote)
        return;
    if (event.getSource().getTrueSource() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.getSource().getTrueSource())) {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        if (!player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty() && player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() instanceof ItemPackSacrifice) {
            ItemPackSacrifice pack = (ItemPackSacrifice) player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem();
            boolean shouldSyphon = pack.getStoredLP(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST)) < pack.CAPACITY;
            float damageDone = event.getEntityLiving().getHealth() < event.getAmount() ? event.getAmount() - event.getEntityLiving().getHealth() : event.getAmount();
            int totalLP = Math.round(damageDone * ConfigHandler.values.coatOfArmsConversion);
            if (shouldSyphon)
                ItemHelper.LPContainer.addLPToItem(player.getItemStackFromSlot(EntityEquipmentSlot.CHEST), totalLP, pack.CAPACITY);
        }
        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.battleHunger", chestStack);
                if (upgrade instanceof LivingArmourUpgradeBattleHungry) {
                    ((LivingArmourUpgradeBattleHungry) upgrade).resetTimer();
                }
            }
        }
    }
}
Also used : LivingArmourUpgradeBattleHungry(WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeBattleHungry) 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) ItemPackSacrifice(WayofTime.bloodmagic.item.gear.ItemPackSacrifice) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 17 with LivingArmour

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

the class LivingArmourHandler method onArrowFire.

// Applies: Arrow Shot
// Tracks: Arrow Shot
@SubscribeEvent
public static void onArrowFire(ArrowLooseEvent event) {
    World world = event.getEntityPlayer().getEntityWorld();
    ItemStack stack = event.getBow();
    EntityPlayer player = event.getEntityPlayer();
    if (world.isRemote)
        return;
    if (LivingArmour.hasFullSet(player)) {
        ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
        LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
        if (armour != null) {
            StatTrackerArrowShot.incrementCounter(armour);
            LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.arrowShot", chestStack);
            if (upgrade instanceof LivingArmourUpgradeArrowShot) {
                int charge = event.getCharge();
                float velocity = (float) charge / 20.0F;
                velocity = (velocity * velocity + velocity * 2.0F) / 3.0F;
                if ((double) velocity < 0.1D)
                    return;
                if (velocity > 1.0F)
                    velocity = 1.0F;
                int extraArrows = ((LivingArmourUpgradeArrowShot) upgrade).getExtraArrows();
                for (int n = 0; n < extraArrows; n++) {
                    ItemStack arrowStack = new ItemStack(Items.ARROW);
                    ItemArrow itemarrow = (ItemArrow) ((stack.getItem() instanceof ItemArrow ? arrowStack.getItem() : Items.ARROW));
                    EntityArrow entityarrow = itemarrow.createArrow(world, arrowStack, player);
                    entityarrow.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity * 3.0F, 1.0F);
                    float velocityModifier = 0.6f * velocity;
                    entityarrow.motionX += (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
                    entityarrow.motionY += (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
                    entityarrow.motionZ += (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
                    if (velocity == 1.0F)
                        entityarrow.setIsCritical(true);
                    int powerLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack);
                    if (powerLevel > 0)
                        entityarrow.setDamage(entityarrow.getDamage() + (double) powerLevel * 0.5D + 0.5D);
                    int punchLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
                    if (punchLevel > 0)
                        entityarrow.setKnockbackStrength(punchLevel);
                    if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0)
                        entityarrow.setFire(100);
                    entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
                    world.spawnEntity(entityarrow);
                }
            }
        }
    }
}
Also used : EntityArrow(net.minecraft.entity.projectile.EntityArrow) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) ItemArrow(net.minecraft.item.ItemArrow) StatTrackerGrimReaperSprint(WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 18 with LivingArmour

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

the class LivingArmourHandler method onMiningSpeedCheck.

@SubscribeEvent
public static void onMiningSpeedCheck(PlayerEvent.BreakSpeed event) {
    EntityPlayer player = event.getEntityPlayer();
    if (LivingArmour.hasFullSet(player)) {
        ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
        LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
        if (armour != null) {
            double modifier = 1;
            for (LivingArmourUpgrade upgrade : armour.upgradeMap.values()) {
                modifier *= upgrade.getMiningSpeedModifier(player);
            }
            if (modifier != 1) {
                event.setNewSpeed((float) (event.getOriginalSpeed() * modifier));
            }
        }
    }
}
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 19 with LivingArmour

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

the class LivingArmourHandler method onEntityUpdate.

// Applies: Step Assist, Speed Boost
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onEntityUpdate(LivingEvent.LivingUpdateEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        boolean hasAssist = false;
        if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) {
            hasAssist = true;
            player.stepHeight = Constants.Misc.ALTERED_STEP_HEIGHT;
        } else {
            if (LivingArmour.hasFullSet(player)) {
                ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
                LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
                if (armour != null) {
                    LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.stepAssist", chestStack);
                    if (upgrade instanceof LivingArmourUpgradeStepAssist) {
                        player.stepHeight = ((LivingArmourUpgradeStepAssist) upgrade).getStepAssist();
                        hasAssist = true;
                    }
                }
            }
        }
        if (!hasAssist && player.stepHeight == Constants.Misc.ALTERED_STEP_HEIGHT)
            player.stepHeight = 0.6f;
        float percentIncrease = 0;
        if (LivingArmour.hasFullSet(player)) {
            ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
            LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
            if (armour != null) {
                LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.movement", chestStack);
                if (upgrade instanceof LivingArmourUpgradeSpeed) {
                    percentIncrease += ((LivingArmourUpgradeSpeed) upgrade).getSpeedModifier();
                }
            }
        }
        if (event.getEntityLiving().isPotionActive(RegistrarBloodMagic.BOOST)) {
            int i = event.getEntityLiving().getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier();
            {
                percentIncrease += (i + 1) * 0.5f;
            }
        }
        if (percentIncrease > 0 && (player.onGround || player.capabilities.isFlying) && (Math.abs(player.moveForward) > 0 || Math.abs(player.moveStrafing) > 0)) {
            player.travel(player.moveStrafing * percentIncrease, 0, player.moveForward * percentIncrease);
        }
    }
}
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) StatTrackerGrimReaperSprint(WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 20 with LivingArmour

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

the class StatTrackerHandler method onEntityHealed.

// Tracks: Health Boost
@SubscribeEvent
public static void onEntityHealed(LivingHealEvent event) {
    EntityLivingBase healedEntity = event.getEntityLiving();
    if (!(healedEntity instanceof EntityPlayer)) {
        return;
    }
    EntityPlayer player = (EntityPlayer) healedEntity;
    if (LivingArmour.hasFullSet(player)) {
        ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
        LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
        if (armour != null) {
            StatTrackerHealthboost.incrementCounter(armour, event.getAmount());
            if (player.getEntityWorld().canSeeSky(player.getPosition()) && player.getEntityWorld().provider.isDaytime()) {
                StatTrackerSolarPowered.incrementCounter(armour, event.getAmount());
            }
        }
    }
}
Also used : ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) EntityLivingBase(net.minecraft.entity.EntityLivingBase) 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