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;
}
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();
}
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();
}
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();
}
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();
}
Aggregations