use of am2.api.spell.ItemSpellBase in project ArsMagica2 by Mithion.
the class ContainerSpellBook method transferStackInSlot.
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) {
ItemStack itemstack = null;
Slot slot = (Slot) inventorySlots.get(i);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (i < 40) {
if (!mergeItemStack(itemstack1, 40, 75, true)) {
return null;
}
} else if (// range 27 - player inventory
i >= 40 && i < 67) {
if (itemstack.getItem() instanceof ItemSpellBase) {
for (int n = 0; n < 40; n++) {
Slot scrollSlot = (Slot) inventorySlots.get(n);
if (scrollSlot.getHasStack())
continue;
ItemStack newStack = new ItemStack(itemstack1.getItem(), 1, itemstack1.getItemDamage());
newStack.setTagCompound(itemstack1.getTagCompound());
scrollSlot.putStack(newStack);
scrollSlot.onSlotChanged();
itemstack1.stackSize--;
if (itemstack1.stackSize == 0) {
slot.putStack(null);
slot.onSlotChanged();
}
return null;
}
}
if (!mergeItemStack(itemstack1, 67, 75, false)) {
return null;
}
} else if (// range 9 - player action bar
i >= 67 && i < 76) {
if (itemstack.getItem() instanceof ItemSpellBase) {
for (int n = 0; n < 40; n++) {
Slot scrollSlot = (Slot) inventorySlots.get(n);
if (scrollSlot.getHasStack())
continue;
ItemStack newStack = new ItemStack(itemstack1.getItem(), 1, itemstack1.getItemDamage());
newStack.setTagCompound(itemstack1.getTagCompound());
scrollSlot.putStack(newStack);
scrollSlot.onSlotChanged();
itemstack1.stackSize--;
if (itemstack1.stackSize == 0) {
slot.putStack(null);
slot.onSlotChanged();
}
return null;
}
}
if (!mergeItemStack(itemstack1, 40, 67, false)) {
return null;
}
} else if (!mergeItemStack(itemstack1, 40, 75, false)) {
return null;
}
if (itemstack1.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize != itemstack.stackSize) {
slot.onSlotChange(itemstack1, itemstack);
} else {
return null;
}
}
return itemstack;
}
use of am2.api.spell.ItemSpellBase in project ArsMagica2 by Mithion.
the class AMIngameGUI method RenderSpellBookUI.
private void RenderSpellBookUI(int i, int j, FontRenderer fontrenderer, ItemStack bookStack) {
mc.renderEngine.bindTexture(spellbook_ui);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
AMVector2 spellbookVec = getShiftedVector(AMCore.config.getSpellBookPosition(), i, j);
int spellUI_x = spellbookVec.iX;
int spellUI_y = spellbookVec.iY;
int spellUI_width = 148;
int spellUI_height = 22;
float activeSpellSize = 15f;
int bookActiveSlot = ((ItemSpellBook) bookStack.getItem()).GetActiveSlot(bookStack);
float x = spellUI_x + bookActiveSlot * 12.9f;
float y = spellUI_y;
this.zLevel = -5;
drawTexturedModalRect_Classic(spellUI_x, spellUI_y, 0, 0, 106, 15, spellUI_width, spellUI_height);
ItemStack[] activeScrolls = ((ItemSpellBook) bookStack.getItem()).getActiveScrollInventory(bookStack);
mc.renderEngine.bindTexture(items);
this.zLevel = 0;
for (int n = 0; n < 8; ++n) {
float IIconX = spellUI_x + 1.5f + n * 12.9f;
ItemStack stackItem = activeScrolls[n];
if (stackItem == null) {
continue;
}
int d = 12;
DrawIconAtXY(((ItemSpellBase) stackItem.getItem()).getIconFromDamageForRenderPass(stackItem.getItemDamage(), 0), "items", IIconX, spellUI_y + 1.5f, d, d, false);
DrawIconAtXY(((ItemSpellBase) stackItem.getItem()).getIconFromDamageForRenderPass(stackItem.getItemDamage(), 1), "items", IIconX, spellUI_y + 1.5f, d, d, false);
}
mc.renderEngine.bindTexture(spellbook_ui);
this.zLevel = 1000;
drawTexturedModalRect_Classic(x, y, 148, 0, activeSpellSize, activeSpellSize, 20, 20);
this.zLevel = 0;
mc.renderEngine.bindTexture(mc_gui);
}
use of am2.api.spell.ItemSpellBase in project ArsMagica2 by Mithion.
the class Projectile method beginStackStage.
@Override
public SpellCastResult beginStackStage(ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean giveXP, int useCount) {
if (!world.isRemote) {
double projectileSpeed = SpellUtils.instance.getModifiedDouble_Mul(SpellModifiers.SPEED, stack, caster, target, world, 0);
double projectileGravity = SpellUtils.instance.getModifiedDouble_Add(SpellModifiers.GRAVITY, stack, caster, target, world, 0);
int projectileBounce = SpellUtils.instance.getModifiedInt_Add(SpellModifiers.BOUNCE, stack, caster, target, world, 0);
int projectileLife = SpellUtils.instance.getModifiedInt_Mul(SpellModifiers.DURATION, stack, caster, target, world, 0);
int pierces = SpellUtils.instance.getModifiedInt_Add(0, stack, caster, target, world, 0, SpellModifiers.PIERCING);
int homing = SpellUtils.instance.getModifiedInt_Add(SpellModifiers.HOMING, stack, caster, target, world, 0);
boolean tWater = SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, stack, 0);
EntitySpellProjectile projectile = new EntitySpellProjectile(world, caster, projectileSpeed);
projectile.setShootingEntity(caster);
projectile.setBounces(projectileBounce);
projectile.setEffectStack(stack);
if (tWater)
projectile.setTargetWater();
projectile.setGravity(projectileGravity);
projectile.setNumPierces(pierces);
projectile.setHoming(homing);
world.spawnEntityInWorld(projectile);
}
return SpellCastResult.SUCCESS;
}
use of am2.api.spell.ItemSpellBase in project ArsMagica2 by Mithion.
the class Self method beginStackStage.
@Override
public SpellCastResult beginStackStage(ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean giveXP, int useCount) {
SpellCastResult result = SpellHelper.instance.applyStageToEntity(stack, caster, world, caster, 0, giveXP);
if (result != SpellCastResult.SUCCESS) {
return result;
}
ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
return SpellHelper.instance.applyStackStage(newItemStack, caster, target, x, y, z, 0, world, true, giveXP, 0);
}
use of am2.api.spell.ItemSpellBase in project ArsMagica2 by Mithion.
the class Touch method beginStackStage.
@Override
public SpellCastResult beginStackStage(ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean giveXP, int useCount) {
if (target != null) {
Entity e = target;
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
SpellCastResult result = SpellHelper.instance.applyStageToEntity(stack, caster, world, e, 0, giveXP);
return result;
}
boolean targetWater = SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, stack, 0);
MovingObjectPosition mop = item.getMovingObjectPosition(caster, world, 2.5f, true, targetWater);
if (mop == null) {
return SpellCastResult.EFFECT_FAILED;
} else {
if (mop.typeOfHit == MovingObjectType.ENTITY) {
Entity e = mop.entityHit;
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
SpellCastResult result = SpellHelper.instance.applyStageToEntity(stack, caster, world, (target == null) ? e : target, 0, giveXP);
if (result != SpellCastResult.SUCCESS) {
return result;
}
ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
return SpellHelper.instance.applyStackStage(newItemStack, caster, target, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 0, world, true, giveXP, 0);
} else {
SpellCastResult result = SpellHelper.instance.applyStageToGround(stack, caster, world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 0, giveXP);
if (result != SpellCastResult.SUCCESS) {
return result;
}
ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
return SpellHelper.instance.applyStackStage(newItemStack, caster, target, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, world, true, giveXP, 0);
}
}
}
Aggregations