use of net.minecraft.item.crafting.ShapelessRecipes in project SecurityCraft by Geforce132.
the class GuiSCManual method updateRecipeAndIcons.
private void updateRecipeAndIcons() {
if (currentPage < 0) {
recipe = null;
hoverCheckers.clear();
return;
}
hoverCheckers.clear();
if (SecurityCraft.instance.manualPages.get(currentPage).hasCustomRecipe())
recipe = SecurityCraft.instance.manualPages.get(currentPage).getRecipe();
else
for (Object object : CraftingManager.getInstance().getRecipeList()) {
if (object instanceof ShapedRecipes) {
ShapedRecipes recipe = (ShapedRecipes) object;
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
this.recipe = recipe.recipeItems;
break;
}
} else if (object instanceof ShapelessRecipes) {
ShapelessRecipes recipe = (ShapelessRecipes) object;
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
this.recipe = toItemStackArray(recipe.recipeItems);
break;
}
}
recipe = null;
}
if (recipe != null) {
outer: for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if ((i * 3) + j == recipe.length)
break outer;
if (recipe[(i * 3) + j] != null)
hoverCheckers.add(new CustomHoverChecker(144 + (i * 20), 144 + (i * 20) + 16, (k + 100) + (j * 20), (k + 100) + (j * 20) + 16, 20, recipe[(i * 3) + j].getDisplayName()));
}
}
} else if (SecurityCraft.instance.manualPages.get(currentPage).isRecipeDisabled())
hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.disabled")));
else if (SecurityCraft.instance.manualPages.get(currentPage).getHelpInfo().equals("help.reinforced.info"))
hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.recipe.reinforced")));
else {
String name = SecurityCraft.instance.manualPages.get(currentPage).getItem().getUnlocalizedName().substring(5);
hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.recipe." + name)));
}
Item item = SecurityCraft.instance.manualPages.get(currentPage).getItem();
TileEntity te = ((item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof ITileEntityProvider) ? ((ITileEntityProvider) ((ItemBlock) item).getBlock()).createNewTileEntity(Minecraft.getMinecraft().theWorld, 0) : null);
Block itemBlock = ((item instanceof ItemBlock) ? ((ItemBlock) item).getBlock() : null);
if (te != null) {
if (te instanceof IOwnable)
hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 29, (k + 29) + 16, 20, StatCollector.translateToLocal("gui.scManual.ownableBlock")));
if (te instanceof IPasswordProtected)
hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 55, (k + 55) + 16, 20, StatCollector.translateToLocal("gui.scManual.passwordProtectedBlock")));
if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView())
hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 81, (k + 81) + 16, 20, StatCollector.translateToLocal("gui.scManual.viewActivatedBlock")));
if (itemBlock instanceof IExplosive)
hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 107, (k + 107) + 16, 20, StatCollector.translateToLocal("gui.scManual.explosiveBlock")));
if (te instanceof CustomizableSCTE)
hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 213, (k + 213) + 16, 20, StatCollector.translateToLocal("gui.scManual.customizableBlock")));
}
}
use of net.minecraft.item.crafting.ShapelessRecipes 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