Search in sources :

Example 1 with ItemLivingArmour

use of WayofTime.bloodmagic.item.armour.ItemLivingArmour 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 2 with ItemLivingArmour

use of WayofTime.bloodmagic.item.armour.ItemLivingArmour 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)

Example 3 with ItemLivingArmour

use of WayofTime.bloodmagic.item.armour.ItemLivingArmour 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)

Example 4 with ItemLivingArmour

use of WayofTime.bloodmagic.item.armour.ItemLivingArmour in project BloodMagic by WayofTime.

the class RitualArmourEvolve 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)) {
            ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
            LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
            if (armour != null) {
                if (armour.maxUpgradePoints < 300) {
                    armour.maxUpgradePoints = 300;
                    ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true);
                    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) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ItemLivingArmour

use of WayofTime.bloodmagic.item.armour.ItemLivingArmour in project BloodMagic by WayofTime.

the class RegistrarBloodMagicItems method registerItems.

@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
    items = Lists.newArrayList();
    RegistrarBloodMagicBlocks.blocks.stream().filter(block -> block instanceof IBMBlock && ((IBMBlock) block).getItem() != null).forEach(block -> {
        IBMBlock bmBlock = (IBMBlock) block;
        items.add(bmBlock.getItem().setRegistryName(block.getRegistryName()));
    });
    items.addAll(Lists.newArrayList(new ItemBloodOrb().setRegistryName("blood_orb"), new ItemActivationCrystal().setRegistryName("activation_crystal"), new ItemSlate().setRegistryName("slate"), new ItemInscriptionTool().setRegistryName("inscription_tool"), new ItemSacrificialDagger().setRegistryName("sacrificial_dagger"), new ItemPackSacrifice().setRegistryName("pack_sacrifice"), new ItemPackSelfSacrifice().setRegistryName("pack_self_sacrifice"), new ItemDaggerOfSacrifice().setRegistryName("dagger_of_sacrifice"), new ItemRitualDiviner().setRegistryName("ritual_diviner"), new ItemRitualReader().setRegistryName("ritual_reader"), new ItemLavaCrystal().setRegistryName("lava_crystal"), new ItemBoundSword().setRegistryName("bound_sword"), new ItemBoundPickaxe().setRegistryName("bound_pickaxe"), new ItemBoundAxe().setRegistryName("bound_axe"), new ItemBoundShovel().setRegistryName("bound_shovel"), new ItemSigilDivination(true).setRegistryName("sigil_divination"), new ItemSigilAir().setRegistryName("sigil_air"), new ItemSigilWater().setRegistryName("sigil_water"), new ItemSigilLava().setRegistryName("sigil_lava"), new ItemSigilVoid().setRegistryName("sigil_void"), new ItemSigilGreenGrove().setRegistryName("sigil_green_grove"), new ItemSigilBloodLight().setRegistryName("sigil_blood_light"), new ItemSigilElementalAffinity().setRegistryName("sigil_elemental_affinity"), new ItemSigilMagnetism().setRegistryName("sigil_magnetism"), new ItemSigilSuppression().setRegistryName("sigil_suppression"), new ItemSigilHaste().setRegistryName("sigil_haste"), new ItemSigilFastMiner().setRegistryName("sigil_fast_miner"), new ItemSigilDivination(false).setRegistryName("sigil_seer"), new ItemSigilPhantomBridge().setRegistryName("sigil_phantom_bridge"), new ItemSigilWhirlwind().setRegistryName("sigil_whirlwind"), new ItemSigilCompression().setRegistryName("sigil_compression"), new ItemSigilEnderSeverance().setRegistryName("sigil_ender_severance"), new ItemSigilHolding().setRegistryName("sigil_holding"), new ItemSigilTeleposition().setRegistryName("sigil_teleposition"), new ItemSigilTransposition().setRegistryName("sigil_transposition"), new ItemSigilClaw().setRegistryName("sigil_claw"), new ItemSigilBounce().setRegistryName("sigil_bounce"), new ItemSigilFrost().setRegistryName("sigil_frost"), new ItemEnum.Variant<>(ComponentTypes.class, "baseComponent").setRegistryName("component"), new ItemDemonCrystal().setRegistryName("item_demon_crystal"), new ItemTelepositionFocus().setRegistryName("teleposition_focus"), new ItemExperienceBook().setRegistryName("experience_tome"), new ItemEnum.Variant<>(ShardType.class, "blood_shard").setRegistryName("blood_shard"), new ItemLivingArmour(EntityEquipmentSlot.HEAD).setRegistryName("living_armour_helmet"), new ItemLivingArmour(EntityEquipmentSlot.CHEST).setRegistryName("living_armour_chest"), new ItemLivingArmour(EntityEquipmentSlot.LEGS).setRegistryName("living_armour_leggings"), new ItemLivingArmour(EntityEquipmentSlot.FEET).setRegistryName("living_armour_boots"), new ItemSentientArmour(EntityEquipmentSlot.HEAD).setRegistryName("sentient_armour_helmet"), new ItemSentientArmour(EntityEquipmentSlot.CHEST).setRegistryName("sentient_armour_chest"), new ItemSentientArmour(EntityEquipmentSlot.LEGS).setRegistryName("sentient_armour_leggings"), new ItemSentientArmour(EntityEquipmentSlot.FEET).setRegistryName("sentient_armour_boots"), new ItemAltarMaker().setRegistryName("altar_maker"), new ItemUpgradeTome().setRegistryName("upgrade_tome"), new ItemUpgradeTrainer().setRegistryName("upgrade_trainer"), new ItemArcaneAshes().setRegistryName("arcane_ashes"), new ItemMonsterSoul().setRegistryName("monster_soul"), new ItemSoulGem().setRegistryName("soul_gem"), new ItemSoulSnare().setRegistryName("soul_snare"), new ItemSentientSword().setRegistryName("sentient_sword"), new ItemSentientBow().setRegistryName("sentient_bow"), new ItemSentientArmourGem().setRegistryName("sentient_armour_gem"), new ItemSentientAxe().setRegistryName("sentient_axe"), new ItemSentientPickaxe().setRegistryName("sentient_pickaxe"), new ItemSentientShovel().setRegistryName("sentient_shovel"), new ItemNodeRouter().setRegistryName("node_router"), new ItemRouterFilter().setRegistryName("base_item_filter"), new ItemFluidRouterFilter().setRegistryName("base_fluid_filter"), new ItemCuttingFluid().setRegistryName("cutting_fluid"), new ItemSanguineBook().setRegistryName("sanguine_book"), new ItemLivingArmourPointsUpgrade().setRegistryName("points_upgrade"), new ItemDemonWillGauge().setRegistryName("demon_will_gauge"), new ItemPotionFlask().setRegistryName("potion_flask"), new ItemAlchemicVial().setRegistryName("alchemic_vial")));
    event.getRegistry().registerAll(items.toArray(new Item[0]));
}
Also used : WayofTime.bloodmagic.item.soul(WayofTime.bloodmagic.item.soul) Item(net.minecraft.item.Item) IVariantProvider(WayofTime.bloodmagic.client.IVariantProvider) WayofTime.bloodmagic.item(WayofTime.bloodmagic.item) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) GameRegistry(net.minecraftforge.fml.common.registry.GameRegistry) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) ComponentTypes(WayofTime.bloodmagic.item.types.ComponentTypes) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IBMBlock(WayofTime.bloodmagic.block.IBMBlock) Lists(com.google.common.collect.Lists) Side(net.minecraftforge.fml.relauncher.Side) RegistryEvent(net.minecraftforge.event.RegistryEvent) Mod(net.minecraftforge.fml.common.Mod) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) ItemPackSelfSacrifice(WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice) ModelLoader(net.minecraftforge.client.model.ModelLoader) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) EnumHelper(net.minecraftforge.common.util.EnumHelper) IMeshProvider(WayofTime.bloodmagic.client.IMeshProvider) ItemLivingArmourPointsUpgrade(WayofTime.bloodmagic.item.alchemy.ItemLivingArmourPointsUpgrade) Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) ItemCuttingFluid(WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid) ItemFluidRouterFilter(WayofTime.bloodmagic.item.routing.ItemFluidRouterFilter) ItemNodeRouter(WayofTime.bloodmagic.item.routing.ItemNodeRouter) Items(net.minecraft.init.Items) ItemPackSacrifice(WayofTime.bloodmagic.item.gear.ItemPackSacrifice) Set(java.util.Set) WayofTime.bloodmagic.item.sigil(WayofTime.bloodmagic.item.sigil) ShardType(WayofTime.bloodmagic.item.types.ShardType) Sets(com.google.common.collect.Sets) ItemSentientArmour(WayofTime.bloodmagic.item.armour.ItemSentientArmour) List(java.util.List) BloodMagic(WayofTime.bloodmagic.BloodMagic) Int2ObjectMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ItemRouterFilter(WayofTime.bloodmagic.item.routing.ItemRouterFilter) ShardType(WayofTime.bloodmagic.item.types.ShardType) Item(net.minecraft.item.Item) ItemLivingArmourPointsUpgrade(WayofTime.bloodmagic.item.alchemy.ItemLivingArmourPointsUpgrade) ItemSentientArmour(WayofTime.bloodmagic.item.armour.ItemSentientArmour) ItemPackSelfSacrifice(WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice) ItemFluidRouterFilter(WayofTime.bloodmagic.item.routing.ItemFluidRouterFilter) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) ComponentTypes(WayofTime.bloodmagic.item.types.ComponentTypes) ItemRouterFilter(WayofTime.bloodmagic.item.routing.ItemRouterFilter) IBMBlock(WayofTime.bloodmagic.block.IBMBlock) ItemNodeRouter(WayofTime.bloodmagic.item.routing.ItemNodeRouter) ItemPackSacrifice(WayofTime.bloodmagic.item.gear.ItemPackSacrifice) ItemCuttingFluid(WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ItemLivingArmour (WayofTime.bloodmagic.item.armour.ItemLivingArmour)6 LivingArmour (WayofTime.bloodmagic.livingArmour.LivingArmour)5 ItemStack (net.minecraft.item.ItemStack)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 LivingArmourUpgrade (WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade)2 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)2 BlockPos (net.minecraft.util.math.BlockPos)2 World (net.minecraft.world.World)2 BloodMagic (WayofTime.bloodmagic.BloodMagic)1 IBMBlock (WayofTime.bloodmagic.block.IBMBlock)1 IMeshProvider (WayofTime.bloodmagic.client.IMeshProvider)1 IVariantProvider (WayofTime.bloodmagic.client.IVariantProvider)1 WayofTime.bloodmagic.item (WayofTime.bloodmagic.item)1 ItemCuttingFluid (WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid)1 ItemLivingArmourPointsUpgrade (WayofTime.bloodmagic.item.alchemy.ItemLivingArmourPointsUpgrade)1 ItemSentientArmour (WayofTime.bloodmagic.item.armour.ItemSentientArmour)1 ItemPackSacrifice (WayofTime.bloodmagic.item.gear.ItemPackSacrifice)1 ItemPackSelfSacrifice (WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice)1 ItemFluidRouterFilter (WayofTime.bloodmagic.item.routing.ItemFluidRouterFilter)1 ItemNodeRouter (WayofTime.bloodmagic.item.routing.ItemNodeRouter)1