Search in sources :

Example 11 with CapManager

use of com.teamwizardry.wizardry.api.capability.CapManager in project Wizardry by TeamWizardry.

the class SpellRing method getPlayerBurnoutMultiplier.

/**
 * All non mana, burnout, and multiplier attributes are reduced based on the caster's burnout level. This returns how much to reduce them by.
 *
 * @return The INVERTED burnout multiplier.
 */
public double getPlayerBurnoutMultiplier(SpellData data) {
    Entity caster = data.getCaster();
    if (caster == null || caster instanceof EntityLivingBase && BaublesSupport.getItem((EntityLivingBase) caster, ModItems.CREATIVE_HALO, ModItems.FAKE_HALO, ModItems.REAL_HALO).isEmpty())
        return 1;
    CapManager manager = new CapManager(caster);
    double multiplier = manager.getBurnout() / manager.getMaxBurnout();
    // TODO: Probably put this into config, limit to [0, 1)
    double burnoutLimit = 0.5;
    return Math.min(1, 1 - (multiplier - burnoutLimit) / (1 - burnoutLimit));
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager) Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 12 with CapManager

use of com.teamwizardry.wizardry.api.capability.CapManager in project Wizardry by TeamWizardry.

the class SpellRing method taxCaster.

public boolean taxCaster(SpellData data) {
    Entity caster = data.getCaster();
    if (caster == null)
        return false;
    double manaDrain = getManaDrain();
    double burnoutFill = getBurnoutFill();
    if (caster instanceof EntityLivingBase) {
        float reduction = getReductionMultiplier((EntityLivingBase) caster);
        manaDrain *= reduction;
        burnoutFill *= reduction;
    }
    CapManager manager = new CapManager(data.getCapability());
    manager.setEntity(caster);
    manager.setManualSync(true);
    boolean fail = false;
    if (manager.getMana() < manaDrain)
        fail = true;
    manager.removeMana(manaDrain);
    manager.addBurnout(burnoutFill);
    manager.sync();
    return !fail;
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager) Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 13 with CapManager

use of com.teamwizardry.wizardry.api.capability.CapManager in project Wizardry by TeamWizardry.

the class BlockPearlHolder method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack heldItem = playerIn.getHeldItem(hand);
    if (!worldIn.isRemote) {
        TilePearlHolder te = getTE(worldIn, pos);
        if (!te.containsSomething()) {
            if (heldItem.getItem() == ModItems.ORB || heldItem.getItem() == ModItems.PEARL_NACRE) {
                te.setItemStack(heldItem.copy());
                te.getItemStack().setCount(1);
                heldItem.shrink(1);
            } else
                return false;
        } else {
            ItemStack stack = te.getItemStack().copy();
            CapManager manager1 = new CapManager(stack).setEntity(playerIn);
            manager1.sync();
            te.setItemStack(ItemStack.EMPTY);
            if (playerIn.inventory.addItemStackToInventory(stack))
                playerIn.openContainer.detectAndSendChanges();
            else {
                EntityItem entityItem = new EntityItem(worldIn, pos.getX(), pos.getY() + 1, pos.getZ(), stack);
                worldIn.spawnEntity(entityItem);
            }
        }
        te.markDirty();
    }
    return true;
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager) TilePearlHolder(com.teamwizardry.wizardry.common.tile.TilePearlHolder) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 14 with CapManager

use of com.teamwizardry.wizardry.api.capability.CapManager in project Wizardry by TeamWizardry.

the class ItemMagicWand method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (worldIn.isRemote)
        return EnumActionResult.SUCCESS;
    TileEntity tile = worldIn.getTileEntity(pos);
    if (tile instanceof TileManaInteracter) {
        CapManager manager = new CapManager(((TileManaInteracter) tile).getWizardryCap());
        Minecraft.getMinecraft().player.sendChatMessage(manager.getMana() + " / " + manager.getMaxMana());
    }
    return EnumActionResult.SUCCESS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CapManager(com.teamwizardry.wizardry.api.capability.CapManager) TileManaInteracter(com.teamwizardry.wizardry.api.block.TileManaInteracter)

Example 15 with CapManager

use of com.teamwizardry.wizardry.api.capability.CapManager in project Wizardry by TeamWizardry.

the class ItemOrb method getSubItems.

@Override
public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
    if (isInCreativeTab(tab)) {
        subItems.add(new ItemStack(this));
        for (float i = 0; i < 1; i += 0.1) {
            ItemStack stack = new ItemStack(this);
            CapManager manager = new CapManager(stack);
            manager.setMana(manager.getMaxMana() * i);
            subItems.add(stack);
        }
    }
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager) ItemStack(net.minecraft.item.ItemStack)

Aggregations

CapManager (com.teamwizardry.wizardry.api.capability.CapManager)26 Vec3d (net.minecraft.util.math.Vec3d)8 BlockPos (net.minecraft.util.math.BlockPos)6 ItemStack (net.minecraft.item.ItemStack)5 Entity (net.minecraft.entity.Entity)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 TileEntity (net.minecraft.tileentity.TileEntity)3 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)2 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)2 ClientRunnable (com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable)2 IWizardryCapability (com.teamwizardry.wizardry.api.capability.IWizardryCapability)2 PacketExplode (com.teamwizardry.wizardry.common.network.PacketExplode)2 TilePearlHolder (com.teamwizardry.wizardry.common.tile.TilePearlHolder)2 EntityItem (net.minecraft.entity.item.EntityItem)2 PotionEffect (net.minecraft.potion.PotionEffect)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 NetworkRegistry (net.minecraftforge.fml.common.network.NetworkRegistry)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 BasicAnimation (com.teamwizardry.librarianlib.features.animator.animations.BasicAnimation)1