Search in sources :

Example 1 with LivingArmour

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

the class ItemLivingArmour method getLivingArmourFromStack.

@Nullable
public static LivingArmour getLivingArmourFromStack(ItemStack stack) {
    NBTTagCompound livingTag = getArmourTag(stack);
    LivingArmour livingArmour = new LivingArmour();
    livingArmour.readFromNBT(livingTag);
    return livingArmour;
}
Also used : LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Nullable(javax.annotation.Nullable)

Example 2 with LivingArmour

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

the class RitualUpgradeRemove method performRitual.

@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
    World world = masterRitualStone.getWorldObj();
    if (world.isRemote) {
        return;
    }
    BlockPos pos = masterRitualStone.getBlockPos();
    AreaDescriptor checkRange = getBlockRange(CHECK_RANGE);
    List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, checkRange.getAABB(pos));
    for (EntityPlayer player : playerList) {
        if (LivingArmour.hasFullSet(player)) {
            boolean removedUpgrade = false;
            ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
            LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
            if (armour != null) {
                @SuppressWarnings("unchecked") HashMap<String, LivingArmourUpgrade> upgradeMap = (HashMap<String, LivingArmourUpgrade>) armour.upgradeMap.clone();
                for (Entry<String, LivingArmourUpgrade> entry : upgradeMap.entrySet()) {
                    LivingArmourUpgrade upgrade = entry.getValue();
                    String upgradeKey = entry.getKey();
                    ItemStack upgradeStack = new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME);
                    LivingUpgrades.setKey(upgradeStack, upgradeKey);
                    LivingUpgrades.setLevel(upgradeStack, upgrade.getUpgradeLevel());
                    boolean successful = armour.removeUpgrade(player, upgrade);
                    if (successful) {
                        removedUpgrade = true;
                        world.spawnEntity(new EntityItem(world, player.posX, player.posY, player.posZ, upgradeStack));
                        for (Entry<String, StatTracker> trackerEntry : armour.trackerMap.entrySet()) {
                            StatTracker tracker = trackerEntry.getValue();
                            if (tracker != null) {
                                if (tracker.providesUpgrade(upgradeKey)) {
                                    // Resets the tracker if the upgrade corresponding to it was removed.
                                    tracker.resetTracker();
                                }
                            }
                        }
                    }
                }
                if (removedUpgrade) {
                    ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true);
                    ItemLivingArmour.setLivingArmour(chestStack, armour);
                    armour.recalculateUpgradePoints();
                    masterRitualStone.setActive(false);
                    world.spawnEntity(new EntityLightningBolt(world, pos.getX(), pos.getY() - 1, pos.getZ(), true));
                }
            }
        }
    }
}
Also used : ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) HashMap(java.util.HashMap) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) World(net.minecraft.world.World) EntityPlayer(net.minecraft.entity.player.EntityPlayer) StatTracker(WayofTime.bloodmagic.livingArmour.StatTracker) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 3 with LivingArmour

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

the class LivingArmourHandler method onJumpEvent.

// Applies: Jump
@SubscribeEvent
public static void onJumpEvent(LivingEvent.LivingJumpEvent 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) {
                StatTrackerJump.incrementCounter(armour);
                if (!player.isSneaking()) {
                    LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.jump", chestStack);
                    if (upgrade instanceof LivingArmourUpgradeJump) {
                        player.motionY += ((LivingArmourUpgradeJump) upgrade).getJumpModifier();
                    }
                }
            }
        }
    }
}
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 4 with LivingArmour

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

the class LivingArmourHandler method onEntityJoinedWorld.

// Applies: Storm Trooper
@SubscribeEvent
public static void onEntityJoinedWorld(EntityJoinWorldEvent event) {
    Entity owner = null;
    if (event.getEntity() instanceof EntityArrow) {
        owner = ((EntityArrow) event.getEntity()).shootingEntity;
    } else if (event.getEntity() instanceof EntityThrowable) {
        owner = ((EntityThrowable) event.getEntity()).getThrower();
    }
    if (owner instanceof EntityPlayer) {
        Entity projectile = event.getEntity();
        EntityPlayer player = (EntityPlayer) owner;
        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.stormTrooper", chestStack);
                if (upgrade instanceof LivingArmourUpgradeStormTrooper) {
                    float velocityModifier = (float) (((LivingArmourUpgradeStormTrooper) upgrade).getArrowJiggle(player) * Math.sqrt(projectile.motionX * projectile.motionX + projectile.motionY * projectile.motionY + projectile.motionZ * projectile.motionZ));
                    projectile.motionX += 2 * (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
                    projectile.motionY += 2 * (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
                    projectile.motionZ += 2 * (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityArrow(net.minecraft.entity.projectile.EntityArrow) EntityThrowable(net.minecraft.entity.projectile.EntityThrowable) 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) LivingArmourUpgradeStormTrooper(WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeStormTrooper) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with LivingArmour

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

the class ItemUpgradeTome method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (world.isRemote) {
        return super.onItemRightClick(world, player, hand);
    }
    LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack);
    if (upgrade == null) {
        return super.onItemRightClick(world, player, hand);
    }
    ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
    if (chestStack.getItem() instanceof ItemLivingArmour) {
        LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
        if (armour == null) {
            return super.onItemRightClick(world, player, hand);
        }
        if (armour.upgradeArmour(player, upgrade)) {
            ItemLivingArmour.setLivingArmour(chestStack, armour);
            // ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(stack, armour, false);
            stack.shrink(1);
        }
    }
    return super.onItemRightClick(world, player, hand);
}
Also used : ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) ItemStack(net.minecraft.item.ItemStack)

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