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