Skip to content

Instantly share code, notes, and snippets.

@ipetepete
Created November 28, 2014 03:36
Show Gist options
  • Save ipetepete/1c7a0724c46b3af946bf to your computer and use it in GitHub Desktop.
Save ipetepete/1c7a0724c46b3af946bf to your computer and use it in GitHub Desktop.
package com.bigbaddevil7.example;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = Example.MODID, version = Example.VERSION)
public class Example {
public static final String MODID = "Example";
public static final String VERSION = "1.0.0";
//I Highly suggest turning on line numbers Window, preferences, general, editors, click on Text Editors not the drop down, check the show line numbers, click apply.
@EventHandler
public void preInit(FMLPreInitializationEvent event){//This method does everything that needs to be done when Minecraft is starting. In this case registering recipes.
//GameRegistry.addRecipe(output, params);
/*GameRegistry just tells minecraft that you are registering something minecraft. What you are registering can be a simple recipe as shown below or an new world event handler like ore spawns.
*
*
*GameRegistry.addRecipe(output, params);
*
*addRecipe allows you to add a shaped minecraft recipe. It takes to parameters the first being the output or what item you get out of the recipe. The second parameter is what the shape of
*the recipe is. Eg. "D D", "DDD", "DDD" is the shape of a chestplate.
*
*As you can see below there is a section of code that goes like this. 'y', Blocks.sponge. That tells minecraft what item is suppose to be in the corresponding spot. Say if I were to use the
*example above with the chest plate after I made the layout of the recipe I would add a , and do 'D', Items.diamond. Anything that has a D in the layout of the recipe would represent a diamond.
*NOTE when adding that it must be '' not "".
*You should pick up on what I mean in the examples below. Line 57
*
*
*GameRegistry.addShapelessRecipe(output, params);
*
*addShaplessRecipe is just what it sounds like. It adds a shapeless recipe to minecraft. The first param is the same as a shaped recipe but the second param just needs the items that are going
*to be in the recipe. Examples towards the bottom. Lines 68 - 72
*
*
* Recipes can also use numbers of items and metadata information(damage values) Lines 64-66.
*
* Vanilla Diamond Chestplate
* GameRegistry.addRecipe(newItemStack(Items.diamond_chestplate), "D D", "DDD", "DDD", 'D', Items.diamond);
*
*
* */
GameRegistry.addRecipe(new ItemStack(Items.diamond),
"y y", "yxy", "yyy", 'y', Blocks.sponge, 'x', Blocks.bedrock // uses 1 bedrock and 7 sponge in the pattern to make 1 diamond.
);
GameRegistry.addRecipe(new ItemStack(Items.gold_ingot, 2),
"xx ", "xx ", " ", 'x', Items.iron_ingot //uses 4 iron in a the pattern to make 2 gold.(The same shape of a crafting bench put it must be in the top left corner of the grid)
);
GameRegistry.addRecipe(new ItemStack(Blocks.diamond_block),
"yyy", "yxy", "yyy", 'y', new ItemStack(Blocks.wool, 1, 15), 'x', Blocks.gold_block//uses 8 black wool(1 being the count, 15 being the damage which makes it black) 1 gold block to make 1 diamond block
);
GameRegistry.addShapelessRecipe(new ItemStack(Items.diamond), Items.gold_ingot, Items.gold_ingot, Items.gold_ingot, Items.gold_ingot);//uses 4 gold bars placed anywhere in the crafting table to get 1 diamond(have to be placed separately not stacked on top of each other)
GameRegistry.addShapelessRecipe(new ItemStack(Items.diamond, 2), Items.gold_ingot, Items.gold_ingot, Items.gold_ingot, Items.gold_ingot, Items.diamond);// uses 4 gold and 1 diamond to give you 2 diamonds.
GameRegistry.addShapelessRecipe(new ItemStack(Blocks.wool, 1 ,5), Blocks.wool, Items.stick);// uses 1 wool of any color and 1 stick to give you 1 lime wool. (1 being the count, 5 being the metadata making the wool lime colored).
}
@EventHandler
public void init(FMLInitializationEvent event){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment