use of net.minecraftforge.oredict.ShapedOreRecipe in project Railcraft by Railcraft.
the class RollingMachineCraftingManager method addRecipe.
@Override
public void addRecipe(@Nullable ItemStack result, Object... recipeArray) {
CraftingPlugin.ProcessedRecipe processedRecipe;
try {
processedRecipe = CraftingPlugin.processRecipe(CraftingPlugin.RecipeType.SHAPED, result, recipeArray);
} catch (InvalidRecipeException ex) {
Game.logTrace(Level.WARN, ex.getRawMessage());
return;
}
if (processedRecipe.isOreRecipe) {
IRecipe recipe = new ShapedOreRecipe(processedRecipe.result, processedRecipe.recipeArray);
addRecipe(recipe);
} else
addRecipe(CraftingPlugin.makeVanillaShapedRecipe(processedRecipe.result, processedRecipe.recipeArray));
}
use of net.minecraftforge.oredict.ShapedOreRecipe in project Guide-API by TeamAmeriFrance.
the class TestBook2 method buildBook.
@Nullable
@Override
public Book buildBook() {
book = new Book();
book.setAuthor("TehNut");
book.setColor(Color.GREEN);
book.setDisplayName("Display Name");
book.setTitle("Title message");
book.setWelcomeMessage("Is this still a thing?");
CategoryAbstract testCategory = new CategoryItemStack("test.category.name", new ItemStack(Items.BANNER)).withKeyBase("guideapi");
testCategory.addEntry("entry", new EntryItemStack("test.entry.name", new ItemStack(Items.POTATO)));
testCategory.getEntry("entry").addPage(new PageText("Hello, this is\nsome text"));
testCategory.getEntry("entry").addPage(new PageFurnaceRecipe(Blocks.COBBLESTONE));
testCategory.getEntry("entry").addPage(new PageIRecipe(new ShapedOreRecipe(Items.ACACIA_BOAT, "X X", "XXX", 'X', "plankWood")));
testCategory.getEntry("entry").addPage(new PageBrewingRecipe(new BrewingRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), new ItemStack(Items.SPECKLED_MELON), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.HEALING))));
book.addCategory(testCategory);
book.setRegistryName(new ResourceLocation("guideapi", "test_book2"));
return book;
}
use of net.minecraftforge.oredict.ShapedOreRecipe in project Engine by VoltzEngine-Project.
the class CommandJsonRecipe method handleConsoleCommand.
@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
if (args != null && args.length > 0 && !"help".equalsIgnoreCase(args[0])) {
if (args[0].equals("generate") || args[0].equals("gen")) {
if (args.length > 1) {
String entryID = args[1];
ItemStack stack = new JsonCraftingRecipeData(null, null, null, false, false).toStack(entryID);
if (stack != null) {
List<IRecipe> recipes = entryID.contains("#") ? InventoryUtility.getRecipesWithOutput(stack) : InventoryUtility.getRecipesWithOutput(stack.getItem());
if (recipes != null) {
sender.addChatMessage(new ChatComponentText("Found " + recipes.size() + " for '" + entryID + "' saving to external json file"));
File writeFile = new File(JsonContentLoader.INSTANCE.externalContentFolder.getParent(), "json-gen/" + (entryID + "-recipes.json").replace(":", "_"));
if (!writeFile.getParentFile().exists()) {
writeFile.getParentFile().mkdirs();
}
try {
JsonObject object = new JsonObject();
int index = 0;
for (IRecipe recipe : recipes) {
try {
if (recipe instanceof ShapedOreRecipe) {
int width = 0;
int height = 0;
Object[] recipeItems = null;
Field field = ShapedOreRecipe.class.getDeclaredField("input");
field.setAccessible(true);
recipeItems = (Object[]) field.get(recipe);
field = ShapedOreRecipe.class.getDeclaredField("width");
field.setAccessible(true);
width = field.getInt(recipe);
field = ShapedOreRecipe.class.getDeclaredField("height");
field.setAccessible(true);
height = field.getInt(recipe);
Pair<String, HashMap<String, JsonElement>> itemSet = generateItemData(recipeItems, width, height);
//Build data
if (itemSet != null) {
JsonObject recipeObject = new JsonObject();
recipeObject.add("type", new JsonPrimitive("shaped"));
recipeObject.add("output", toItemJson(recipe.getRecipeOutput()));
recipeObject.add("grid", new JsonPrimitive(itemSet.left()));
JsonObject itemEntry = new JsonObject();
for (Map.Entry<String, JsonElement> entry : itemSet.right().entrySet()) {
itemEntry.add(entry.getKey(), entry.getValue());
}
recipeObject.add("items", itemEntry);
object.add("craftingGridRecipe:" + (index++), recipeObject);
} else {
sender.addChatMessage(new ChatComponentText("Failed to map recipe items for '" + recipe + "'"));
}
} else if (recipe instanceof ShapedRecipes) {
Pair<String, HashMap<String, JsonElement>> itemSet = generateItemData(((ShapedRecipes) recipe).recipeItems, ((ShapedRecipes) recipe).recipeWidth, ((ShapedRecipes) recipe).recipeHeight);
//Build data
if (itemSet != null) {
JsonObject recipeObject = new JsonObject();
recipeObject.add("type", new JsonPrimitive("shaped"));
recipeObject.add("output", toItemJson(recipe.getRecipeOutput()));
recipeObject.add("grid", new JsonPrimitive(itemSet.left()));
JsonObject itemEntry = new JsonObject();
for (Map.Entry<String, JsonElement> entry : itemSet.right().entrySet()) {
itemEntry.add(entry.getKey(), entry.getValue());
}
recipeObject.add("items", itemEntry);
object.add("craftingGridRecipe:" + (index++), recipeObject);
} else {
sender.addChatMessage(new ChatComponentText("Failed to map recipe items for '" + recipe + "'"));
}
} else {
sender.addChatMessage(new ChatComponentText("Failed to ID recipe type of '" + recipe + "'"));
}
} catch (Exception e) {
sender.addChatMessage(new ChatComponentText("Error processing recipe '" + recipe + "', see logs for details."));
e.printStackTrace();
}
}
if (object.entrySet().size() > 0) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
try (FileWriter file = new FileWriter(writeFile)) {
file.write(gson.toJson(object));
}
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
sender.addChatMessage(new ChatComponentText("Failed to locate recipes for '" + entryID + "'"));
}
} else {
sender.addChatMessage(new ChatComponentText("Failed to locate entry for '" + entryID + "'"));
}
return true;
}
}
}
return handleHelp(sender, args);
}
use of net.minecraftforge.oredict.ShapedOreRecipe in project AgriCraft by AgriCraft.
the class ItemJournal method registerRecipes.
@Override
public void registerRecipes() {
// Normal Crafting
GameRegistry.addRecipe(new ShapedOreRecipe(this, "csc", "sbs", "csc", 'c', AgriItems.getInstance().CROPS, 's', Items.WHEAT_SEEDS, 'b', Items.BOOK));
// Copy Crafting
RecipeSorter.register("recipe.copy_journal", RecipeCopyJournal.class, RecipeSorter.Category.SHAPELESS, "");
GameRegistry.addRecipe(new RecipeCopyJournal());
}
use of net.minecraftforge.oredict.ShapedOreRecipe in project ICBM-Classic by BuiltBrokenModding.
the class ICBMClassic method loadRecipes.
@Override
public void loadRecipes(ModManager manager) {
/** LOAD. */
ArrayList dustCharcoal = OreDictionary.getOres("dustCharcoal");
ArrayList dustCoal = OreDictionary.getOres("dustCoal");
// Sulfur
//GameRegistry.addSmelting(blockSulfurOre, new ItemStack(itemSulfurDust, 4), 0.8f);
GameRegistry.addSmelting(Items.reeds, new ItemStack(itemSulfurDust, 4, 1), 0f);
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Items.gunpowder, 2), "dustSulfur", "dustSaltpeter", Items.coal));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Items.gunpowder, 2), "dustSulfur", "dustSaltpeter", new ItemStack(Items.coal, 1, 1)));
if (dustCharcoal != null && dustCharcoal.size() > 0) {
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Items.gunpowder, 2), "dustSulfur", "dustSaltpeter", "dustCharcoal"));
}
if (dustCoal != null && dustCoal.size() > 0) {
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Items.gunpowder, 2), "dustSulfur", "dustSaltpeter", "dustCoal"));
}
GameRegistry.addRecipe(new ShapedOreRecipe(Blocks.tnt, "@@@", "@R@", "@@@", '@', Items.gunpowder, 'R', Items.redstone));
// Poison Powder
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(itemPoisonPowder, 3), Items.spider_eye, Items.rotten_flesh));
// Glass Pressure Plate
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockGlassPlate, 1, 0), "##", '#', Blocks.glass));
// Glass Button
GameRegistry.addRecipe(new ItemStack(blockGlassButton, 2), "G", "G", 'G', Blocks.glass);
// Proximity Detector
GameRegistry.addRecipe(new ShapedOreRecipe(blockProximityDetector, "SSS", "S?S", "SSS", 'S', Items.iron_ingot, '?', itemTracker));
// Signal Disrupter
GameRegistry.addRecipe(new ShapedOreRecipe(itemSignalDisrupter, "WWW", "SCS", "SSS", 'S', Items.iron_ingot, 'C', UniversalRecipe.CIRCUIT_T1.get(), 'W', UniversalRecipe.WIRE.get()));
// Antidote
OreDictionary.registerOre("seeds", Items.wheat_seeds);
OreDictionary.registerOre("seeds", Items.pumpkin_seeds);
OreDictionary.registerOre("seeds", Items.melon_seeds);
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemAntidote, 6), "@@@", "@@@", "@@@", '@', "seeds"));
// Reinforced rails
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCombatRail, 16, 0), new Object[] { "C C", "CIC", "C C", 'I', new ItemStack(blockConcrete, 1, 0), 'C', Items.iron_ingot }));
// Reinforced Glass
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockReinforcedGlass, 8), new Object[] { "IGI", "GIG", "IGI", 'G', Blocks.glass, 'I', Items.iron_ingot }));
// Rocket Launcher
GameRegistry.addRecipe(new ShapedOreRecipe(itemRocketLauncher, "SCR", "SB ", 'R', itemRadarGun, 'C', new ItemStack(blockCruiseLauncher), 'B', Blocks.stone_button, 'S', UniversalRecipe.PRIMARY_METAL.get()));
// Radar Gun
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemRadarGun), "@#!", " $!", " !", '@', Blocks.glass, '!', UniversalRecipe.PRIMARY_METAL.get(), '#', UniversalRecipe.CIRCUIT_T1.get(), '$', Blocks.stone_button));
// Remote
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemRemoteDetonator), "?@@", "@#$", "@@@", '@', UniversalRecipe.PRIMARY_METAL.get(), '?', Items.redstone, '#', UniversalRecipe.CIRCUIT_T2.get(), '$', Blocks.stone_button));
// Laser Designator
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemLaserDesignator), "! ", " ? ", " @", '@', itemRemoteDetonator, '?', UniversalRecipe.CIRCUIT_T3.get(), '!', itemRadarGun));
// Defuser
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemDefuser), "I ", " W ", " C", 'C', UniversalRecipe.CIRCUIT_T2.get(), 'W', UniversalRecipe.WRENCH.get(), 'I', UniversalRecipe.WIRE.get()));
// Missile module
GameRegistry.addRecipe(new ShapedOreRecipe(Explosives.MISSILE.getItemStack(), " @ ", "@#@", "@?@", '@', UniversalRecipe.PRIMARY_METAL.get(), '?', Items.flint_and_steel, '#', UniversalRecipe.CIRCUIT_T1.get()));
// Homing
GameRegistry.addRecipe(new ShapedOreRecipe(Explosives.MISSILE_HOMING.getItemStack(), " B ", " C ", "BMB", 'M', Explosives.MISSILE.getItemStack(), 'C', UniversalRecipe.CIRCUIT_T1.get(), 'B', UniversalRecipe.SECONDARY_METAL.get()));
// Anti-ballistic
GameRegistry.addRecipe(new ShapedOreRecipe(Explosives.MISSILE_ANTI.getItemStack(), "!", "?", "@", '@', Explosives.MISSILE.getItemStack(), '?', new ItemStack(blockExplosive, 1, 0), '!', UniversalRecipe.CIRCUIT_T1.get()));
// Cluster
GameRegistry.addRecipe(new ShapedOreRecipe(Explosives.MISSILE_CLUSTER.getItemStack(), " ! ", " ? ", "!@!", '@', Explosives.MISSILE.getItemStack(), '?', Explosives.FRAGMENTATION.getItemStack(), '!', new ItemStack(itemMissile, 1, 0)));
// Nuclear Cluster
GameRegistry.addRecipe(new ShapedOreRecipe(Explosives.MISSILE_CLUSTER_NUKE.getItemStack(), " N ", "NCN", 'C', Explosives.MISSILE_CLUSTER.getItemStack(), 'N', Explosives.NUCLEAR.getItemStack()));
for (Explosives ex : Explosives.values()) {
Explosive explosive = ex.handler;
explosive.init();
if (!(explosive instanceof Missile)) {
// Missile
RecipeUtility.addRecipe(new ShapelessOreRecipe(new ItemStack(itemMissile, 1, ex.ordinal()), Explosives.MISSILE.getItemStack(), new ItemStack(blockExplosive, 1, ex.ordinal())), explosive.getUnlocalizedName() + " Missile", getConfig(), true);
if (explosive.getTier() < 2) {
// Grenade
RecipeUtility.addRecipe(new ShapedOreRecipe(new ItemStack(itemGrenade, 1, ex.ordinal()), "?", "@", '@', new ItemStack(blockExplosive, 1, ex.ordinal()), '?', Items.string), explosive.getUnlocalizedName() + " Grenade", getConfig(), true);
}
if (explosive.getTier() < 3) {
// Minecart
RecipeUtility.addRecipe(new ShapedOreRecipe(new ItemStack(itemBombCart, 1, ex.ordinal()), "?", "@", '?', new ItemStack(blockExplosive, 1, ex.ordinal()), '@', Items.minecart), explosive.getUnlocalizedName() + " Minecart", getConfig(), true);
}
}
}
}
Aggregations