use of am2.api.spell.component.interfaces.ISkillTreeEntry in project ArsMagica2 by Mithion.
the class TileEntityInscriptionTable method HandleUpdatePacket.
public void HandleUpdatePacket(byte[] data) {
if (this.worldObj == null)
return;
AMDataReader rdr = new AMDataReader(data);
switch(rdr.ID) {
case FULL_UPDATE:
if (!rdr.getBoolean()) {
Entity e = this.worldObj.getEntityByID(rdr.getInt());
if (e instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) e;
this.setInUse(player);
} else {
this.setInUse(null);
}
} else {
this.setInUse(null);
}
currentRecipe.clear();
int partLength = rdr.getInt();
for (int i = 0; i < partLength; ++i) {
ISkillTreeEntry part = SkillManager.instance.getSkill(rdr.getInt());
if (part instanceof ISpellPart)
this.currentRecipe.add((ISpellPart) part);
}
this.shapeGroups.clear();
int numGroups = rdr.getInt();
for (int i = 0; i < numGroups; ++i) {
ArrayList<ISpellPart> group = new ArrayList<ISpellPart>();
int[] partData = rdr.getIntArray();
for (int n : partData) {
ISkillTreeEntry part = SkillManager.instance.getSkill(n);
if (part instanceof ISpellPart)
group.add((ISpellPart) part);
}
this.shapeGroups.add(group);
}
countModifiers();
this.currentSpellName = rdr.getString();
this.currentSpellIsReadOnly = rdr.getBoolean();
break;
case MAKE_SPELL:
int entityID = rdr.getInt();
EntityPlayer player = (EntityPlayer) worldObj.getEntityByID(entityID);
if (player != null) {
createSpellForPlayer(player);
}
break;
case RESET_NAME:
entityID = rdr.getInt();
player = (EntityPlayer) worldObj.getEntityByID(entityID);
if (player != null) {
((ContainerInscriptionTable) player.openContainer).resetSpellNameAndIcon();
}
break;
}
}
use of am2.api.spell.component.interfaces.ISkillTreeEntry in project ArsMagica2 by Mithion.
the class ItemSpellPart method registerIcons.
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
ArrayList<Integer> parts = SkillManager.instance.getAllShapes();
parts.addAll(SkillManager.instance.getAllComponents());
parts.addAll(SkillManager.instance.getAllModifiers());
parts.addAll(SkillManager.instance.getAllTalents());
int count = 0;
for (Integer i : parts) {
if (i == null)
continue;
ISkillTreeEntry entry = SkillManager.instance.getSkill(i);
String subfolder = "";
if (entry instanceof ISpellShape)
subfolder = "shapes";
else if (entry instanceof ISpellComponent)
subfolder = "components";
else if (entry instanceof ISpellModifier)
subfolder = "modifiers";
else
subfolder = "skills";
String skillName = SkillManager.instance.getSkillName(entry);
IIcon IIcon = ResourceManager.RegisterTexture(String.format("spells/%s/%s.png", subfolder, skillName), IIconRegister);
SpellIconManager.instance.registerIcon(skillName, IIcon);
}
}
use of am2.api.spell.component.interfaces.ISkillTreeEntry in project ArsMagica2 by Mithion.
the class GuiArcaneCompendium method renderItemToolTip.
private void renderItemToolTip(ItemStack stack, int x, int y) {
try {
List list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
CompendiumEntry entry;
if (stack.getItem() instanceof ItemBlock) {
ItemBlock item = (ItemBlock) stack.getItem();
Block block = item.field_150939_a;
String name = block.getUnlocalizedName().replace("arsmagica2:", "").replace("tile.", "");
String metaname = name + "@" + stack.getItemDamage();
entry = ArcaneCompendium.instance.getEntry(metaname);
if (entry == null)
entry = ArcaneCompendium.instance.getEntry(name);
} else {
if (stack.getItem() == ItemsCommonProxy.spell_component) {
list.clear();
ISkillTreeEntry skill = SkillManager.instance.getSkill(stack.getItemDamage());
if (skill == null)
return;
list.add(SkillManager.instance.getDisplayName(skill));
entry = ArcaneCompendium.instance.getEntry(SkillManager.instance.getSkillName(skill));
} else {
String name = stack.getItem().getUnlocalizedName().replace("item.", "").replace("arsmagica2:", "");
String metaname = name + "@" + stack.getItemDamage();
entry = ArcaneCompendium.instance.getEntry(metaname);
if (entry == null)
entry = ArcaneCompendium.instance.getEntry(name);
}
}
for (int k = 0; k < list.size(); ++k) {
if (k == 0) {
if (entry != null) {
list.set(k, "§2" + (String) list.get(k));
} else {
list.set(k, "§" + stack.getRarity().rarityColor.getFormattingCode() + (String) list.get(k));
}
} else {
list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
}
}
//split out multiline entries (only entry 0 in this case)
if (((String) list.get(0)).indexOf('\n') != -1) {
String s = ((String) list.get(0));
String colorPrefix = "";
list.remove(0);
if (entry != null) {
colorPrefix = "§2";
} else {
colorPrefix = "§" + stack.getRarity().rarityColor.getFormattingCode();
}
String[] split = s.split("\n");
for (int i = split.length - 1; i >= 0; --i) {
list.add(0, colorPrefix + split[i]);
}
}
FontRenderer font = stack.getItem().getFontRenderer(stack);
drawHoveringText(list, x, y, (font == null ? this.fontRendererObj : font));
} catch (Throwable t) {
}
}
use of am2.api.spell.component.interfaces.ISkillTreeEntry in project ArsMagica2 by Mithion.
the class GuiArcaneCompendium method getAndAnalyzeRecipe.
private void getAndAnalyzeRecipe() {
if (renderStack == null)
return;
if (renderStack.getItem() == ItemsCommonProxy.essence || renderStack.getItem() == ItemsCommonProxy.deficitCrystal) {
RecipeArsMagica essenceRecipe = RecipesEssenceRefiner.essenceRefinement().recipeFor(renderStack);
if (essenceRecipe != null) {
craftingComponents = essenceRecipe.getRecipeItems();
recipeHeight = 2;
} else {
craftingComponents = null;
}
} else if (renderStack.getItem() instanceof ItemSpellPart) {
ISkillTreeEntry part = SkillManager.instance.getSkill(this.entryName);
if (part == null)
return;
ArrayList<Object> recipe = new ArrayList<Object>();
if (part instanceof ISpellPart) {
Object[] recipeItems = ((ISpellPart) part).getRecipeItems();
SpellRecipeItemsEvent event = new SpellRecipeItemsEvent(SkillManager.instance.getSkillName(part), SkillManager.instance.getShiftedPartID(part), recipeItems);
MinecraftForge.EVENT_BUS.post(event);
recipeItems = event.recipeItems;
if (recipeItems != null) {
for (int i = 0; i < recipeItems.length; ++i) {
Object o = recipeItems[i];
boolean matches = false;
if (o instanceof ItemStack) {
recipe.add(o);
} else if (o instanceof Item) {
recipe.add(new ItemStack((Item) o));
} else if (o instanceof Block) {
recipe.add(new ItemStack((Block) o));
} else if (o instanceof String) {
if (((String) o).startsWith("P:")) {
//potion
String s = ((String) o).substring(2);
int pfx = SpellRecipeManager.parsePotionMeta(s);
recipe.add(new ItemStack(Items.potionitem, 1, pfx));
} else if (((String) o).startsWith("E:")) {
//essence
String s = ((String) o);
try {
int[] types = SpellRecipeManager.ParseEssenceIDs(s);
int type = 0;
for (int t : types) type |= t;
int amount = (Integer) recipeItems[++i];
recipe.add(new ItemStack(ItemsCommonProxy.essence, amount, ItemsCommonProxy.essence.META_MAX + type));
} catch (Throwable t) {
continue;
}
} else {
recipe.add(OreDictionary.getOres((String) o));
}
}
}
}
}
craftingComponents = recipe.toArray();
} else {
IRecipe recipe = RecipeUtilities.getRecipeFor(renderStack);
if (recipe != null) {
renderStack = recipe.getRecipeOutput();
if (recipe instanceof ShapedRecipes) {
recipeWidth = ((ShapedRecipes) recipe).recipeWidth;
recipeHeight = ((ShapedRecipes) recipe).recipeHeight;
craftingComponents = ((ShapedRecipes) recipe).recipeItems;
} else if (recipe instanceof ShapedOreRecipe) {
recipeWidth = ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, ((ShapedOreRecipe) recipe), "width");
recipeHeight = ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, ((ShapedOreRecipe) recipe), "height");
craftingComponents = ((ShapedOreRecipe) recipe).getInput();
} else if (recipe instanceof ShapelessRecipes) {
recipeWidth = ((ShapelessRecipes) recipe).getRecipeSize();
recipeHeight = -1;
craftingComponents = ((ShapelessRecipes) recipe).recipeItems.toArray();
} else if (recipe instanceof ShapelessOreRecipe) {
recipeWidth = ((ShapelessOreRecipe) recipe).getRecipeSize();
recipeHeight = -1;
craftingComponents = ((ShapelessOreRecipe) recipe).getInput().toArray();
} else {
craftingComponents = null;
}
} else {
craftingComponents = null;
}
}
}
Aggregations