use of am2.api.spell.component.interfaces.ISpellPart in project ArsMagica2 by Mithion.
the class SpellValidator method validateStage.
private StageValidations validateStage(ArrayList<ISpellPart> stageDefinition, boolean isFinalStage) {
boolean terminus = false;
boolean principum = false;
boolean one_component = !isFinalStage;
boolean one_shape = false;
for (ISpellPart part : stageDefinition) {
if (part instanceof Summon)
return StageValidations.TERMINUS;
if (part instanceof ISpellShape) {
one_shape = true;
if (((ISpellShape) part).isTerminusShape())
terminus = true;
if (((ISpellShape) part).isPrincipumShape())
principum = true;
continue;
}
if (part instanceof ISpellComponent) {
one_component = true;
continue;
}
}
if (principum)
return StageValidations.PRINCIPUM;
if (!one_component || !one_shape)
return StageValidations.NOT_VALID;
if (terminus)
return StageValidations.TERMINUS;
return StageValidations.VALID;
}
use of am2.api.spell.component.interfaces.ISpellPart in project ArsMagica2 by Mithion.
the class SpellRecipeManager method RegisterRecipe.
public void RegisterRecipe(ISpellPart part) {
ArrayList<Object> recipeItems = new ArrayList<Object>();
Object[] recipe = part.getRecipeItems();
SpellRecipeItemsEvent event = new SpellRecipeItemsEvent(SkillManager.instance.getSkillName(part), SkillManager.instance.getShiftedPartID(part), recipe);
MinecraftForge.EVENT_BUS.post(event);
recipe = event.recipeItems;
if (recipe == null) {
LogHelper.info("Component %s has been registered with no craftable recipe - is this intentional? If so, return a 0-length array for recipe.", SkillManager.instance.getDisplayName(part));
return;
}
if (recipe.length == 0) {
return;
}
for (int i = 0; i < recipe.length; ++i) {
Object o = recipe[i];
if (o instanceof Item) {
recipeItems.add(new ItemStack((Item) o));
} else if (o instanceof Block) {
recipeItems.add(new ItemStack((Block) o));
} else if (o instanceof String) {
if (((String) o).toLowerCase().startsWith("e:")) {
if (i == recipe.length - 1 || !(recipe[i + 1] instanceof Integer)) {
LogHelper.warn("Error registering recipe. Power must be declared in Integer pairs (type flags, quantity)).");
return;
}
int[] ids = ParseEssenceIDs((String) o);
int flag = 0;
for (int f : ids) {
flag |= f;
}
int quantity = (Integer) recipe[++i];
ItemStack stack = new ItemStack(ItemsCommonProxy.essence, quantity, ItemEssence.META_MAX + flag);
recipeItems.add(stack);
} else {
recipeItems.add(o);
}
} else {
recipeItems.add(o);
}
}
recipes.put(recipeItems, part);
}
use of am2.api.spell.component.interfaces.ISpellPart in project ArsMagica2 by Mithion.
the class TileEntityInscriptionTable method createSpellForPlayer.
public void createSpellForPlayer(EntityPlayer player) {
if (worldObj.isRemote) {
AMDataWriter writer = new AMDataWriter();
writer.add(xCoord);
writer.add(yCoord);
writer.add(zCoord);
writer.add(MAKE_SPELL);
writer.add(player.getEntityId());
AMNetHandler.INSTANCE.sendPacketToServer(AMPacketIDs.INSCRIPTION_TABLE_UPDATE, writer.generate());
} else {
ArrayList<ArrayList<KeyValuePair<ISpellPart, byte[]>>> shapeGroupSetup = new ArrayList<ArrayList<KeyValuePair<ISpellPart, byte[]>>>();
ArrayList<KeyValuePair<ISpellPart, byte[]>> curRecipeSetup = new ArrayList<KeyValuePair<ISpellPart, byte[]>>();
for (ArrayList<ISpellPart> arr : shapeGroups) {
shapeGroupSetup.add(new ArrayList<KeyValuePair<ISpellPart, byte[]>>());
for (ISpellPart part : arr) {
shapeGroupSetup.get(shapeGroupSetup.size() - 1).add(new KeyValuePair<ISpellPart, byte[]>(part, new byte[0]));
}
}
for (ISpellPart part : currentRecipe) {
curRecipeSetup.add(new KeyValuePair<ISpellPart, byte[]>(part, new byte[0]));
}
ItemStack stack = SpellUtils.instance.createSpellStack(shapeGroupSetup, curRecipeSetup);
stack.stackTagCompound.setString("suggestedName", currentSpellName);
player.inventory.addItemStackToInventory(stack);
}
}
use of am2.api.spell.component.interfaces.ISpellPart in project ArsMagica2 by Mithion.
the class TileEntityCraftingAltar method matchCurrentRecipe.
private boolean matchCurrentRecipe() {
ISpellPart part = SpellRecipeManager.instance.getPartByRecipe(currentAddedItems);
if (part == null)
return false;
ArrayList<KeyValuePair<ISpellPart, byte[]>> currentShapeGroupList = getShapeGroupToAddTo();
if (part instanceof Summon)
handleSummonShape();
if (part instanceof Binding)
handleBindingShape();
byte[] metaData = new byte[0];
if (part instanceof ISpellModifier) {
metaData = ((ISpellModifier) part).getModifierMetadata(currentAddedItems.toArray(new ItemStack[currentAddedItems.size()]));
if (metaData == null) {
metaData = new byte[0];
}
}
// we're now creating the body of the spell
if (currentShapeGroupList == null) {
spellDef.add(new KeyValuePair<ISpellPart, byte[]>(part, metaData));
} else {
currentShapeGroupList.add(new KeyValuePair<ISpellPart, byte[]>(part, metaData));
}
return true;
}
use of am2.api.spell.component.interfaces.ISpellPart in project ArsMagica2 by Mithion.
the class TileEntityInscriptionTable method countModifiersInList.
private void countModifiersInList(ArrayList<ISpellPart> currentStage) {
for (ISpellPart part : currentStage) {
if (part instanceof ISpellModifier) {
EnumSet<SpellModifiers> modifiers = ((ISpellModifier) part).getAspectsModified();
for (SpellModifiers modifier : modifiers) {
int count = modifierCount.get(modifier) + 1;
modifierCount.put(modifier, count);
}
}
}
}
Aggregations