Search in sources :

Example 1 with CapManager

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

the class ModuleEffectLeech method run.

@Override
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Entity targetEntity = spell.getVictim();
    BlockPos targetPos = spell.getTargetPos();
    Entity caster = spell.getCaster();
    EnumFacing facing = spell.getData(FACE_HIT);
    double strength = spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell) / 2;
    if (!spellRing.taxCaster(spell))
        return false;
    if (targetEntity instanceof EntityLivingBase) {
        if (targetEntity instanceof EntityPlayer) {
            double targetMana = new CapManager(targetEntity).getMana();
            targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
            if (targetEntity.isDead) {
                targetMana /= 2;
                targetMana = MathHelper.clamp(targetMana, targetMana, spellRing.getManaDrain() * 2);
                new CapManager(caster).addMana(targetMana);
            }
        } else if (targetEntity instanceof EntityWitch) {
            double targetMana = spellRing.getManaDrain() * 2;
            targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
            if (targetEntity.isDead) {
                new CapManager(caster).addMana(targetMana);
            }
        } else {
            if (caster instanceof EntityLivingBase)
                ((EntityLivingBase) caster).setLastAttackedEntity(targetEntity);
            if (caster != null)
                targetEntity.attackEntityFrom(new EntityDamageSource("magic", caster).setDamageBypassesArmor().setMagicDamage(), (float) strength);
            else
                targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
        }
    }
    Vec3d target = spell.getTargetWithFallback();
    if (target != null)
        world.playSound(null, new BlockPos(target), ModSounds.CHAINY_ZAP, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.35f, 0.75f), RandUtil.nextFloat(0.35f, 1.5f));
    return true;
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager) Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) EntityWitch(net.minecraft.entity.monster.EntityWitch) Vec3d(net.minecraft.util.math.Vec3d)

Example 2 with CapManager

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

the class ItemCreativeHaloHead method onUpdate.

@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
    CapManager manager = new CapManager(entityIn).setManualSync(true);
    manager.setMaxMana(ConfigValues.creativeHaloBufferSize);
    manager.setMaxBurnout(ConfigValues.creativeHaloBufferSize);
    manager.setMana(ConfigValues.creativeHaloBufferSize);
    manager.setBurnout(0);
    if (manager.isSomethingChanged())
        manager.sync();
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager)

Example 3 with CapManager

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

the class ItemFakeHaloBauble method onWornTick.

@Override
public void onWornTick(@Nonnull ItemStack stack, @Nonnull EntityLivingBase player) {
    CapManager manager = new CapManager(player).setManualSync(true);
    manager.setMaxMana(ConfigValues.crudeHaloBufferSize);
    manager.setMaxBurnout(ConfigValues.crudeHaloBufferSize);
    if (manager.getMana() > ConfigValues.crudeHaloBufferSize)
        manager.setMana(ConfigValues.crudeHaloBufferSize);
    if (manager.getBurnout() > ConfigValues.crudeHaloBufferSize)
        manager.setBurnout(ConfigValues.crudeHaloBufferSize);
    if (!manager.isBurnoutEmpty())
        manager.removeBurnout(manager.getMaxBurnout() * ConfigValues.haloGenSpeed);
    if (manager.isSomethingChanged())
        manager.sync();
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager)

Example 4 with CapManager

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

the class ItemFakeHaloHead method onUpdate.

@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
    CapManager manager = new CapManager(entityIn).setManualSync(true);
    manager.setMaxMana(ConfigValues.crudeHaloBufferSize);
    manager.setMaxBurnout(ConfigValues.crudeHaloBufferSize);
    if (manager.getMana() > ConfigValues.crudeHaloBufferSize)
        manager.setMana(ConfigValues.crudeHaloBufferSize);
    if (manager.getBurnout() > ConfigValues.crudeHaloBufferSize)
        manager.setBurnout(ConfigValues.crudeHaloBufferSize);
    if (!manager.isBurnoutEmpty())
        manager.removeBurnout(manager.getMaxBurnout() * ConfigValues.haloGenSpeed);
    if (manager.isSomethingChanged())
        manager.sync();
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager)

Example 5 with CapManager

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

the class ItemRealHaloHead method onUpdate.

@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
    CapManager manager = new CapManager(entityIn).setManualSync(true);
    manager.setMaxMana(ConfigValues.realHaloBufferSize);
    manager.setMaxBurnout(ConfigValues.realHaloBufferSize);
    if (manager.getMana() > ConfigValues.realHaloBufferSize)
        manager.setMana(ConfigValues.realHaloBufferSize);
    if (manager.getBurnout() > ConfigValues.realHaloBufferSize)
        manager.setBurnout(ConfigValues.realHaloBufferSize);
    if (!manager.isManaFull())
        manager.addMana(manager.getMaxMana() * ConfigValues.haloGenSpeed);
    if (!manager.isBurnoutEmpty())
        manager.removeBurnout(manager.getMaxBurnout() * ConfigValues.haloGenSpeed);
    if (manager.isSomethingChanged())
        manager.sync();
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager)

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