This chapter is from the book
The Results in the Mod File
After you have done all this, the mod file should look something like the following:
package com.wuppy.samsmod;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.DungeonHooks;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
@Mod(modid = SamsMod.MODID, version = SamsMod.VERSION)
public class SamsMod
{
public static final String MODID = "wuppy29_samsmod";
public static final String VERSION = "1.0";
@EventHandler
public void init(FMLInitializationEvent event)
{
// crafting recipes
GameRegistry.addRecipe(new ItemStack(Items.apple),
"XXX",
"XXX",
"XXX",
'X', Blocks.leaves);
GameRegistry.addRecipe(new ItemStack(Items.arrow),
"YZ",
"X ",
'X', Items.flint, 'Y', Items.stick, 'Z', Blocks.leaves);
GameRegistry.addRecipe(new ItemStack(Items.dye, 2, 1),
"XY",
'X', Items.redstone, 'Y', new ItemStack(Items.dye, 1, 1));
// shapeless recipes
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 2, 1),
Items.redstone, new ItemStack(Items.dye, 1, 1));
// special recipes
ItemStack enchantedSwordItemStack = new ItemStack(Items.stone_sword);
enchantedSwordItemStack.addEnchantment(Enchantment.sharpness, 1);
GameRegistry.addShapelessRecipe(enchantedSwordItemStack, Items.flint,
Items.stone_sword);
ItemStack knockbackItemStack = new ItemStack(Items.stone_sword);
knockbackItemStack.addEnchantment(Enchantment.knockback, 1);
GameRegistry.addShapelessRecipe(knockbackItemStack, Items.gunpowder,
Items.stone_sword );
// smelting
GameRegistry.addSmelting(Blocks.stone, new ItemStack(Blocks.stonebrick),
0.1F);
// dungeon changes
DungeonHooks.removeDungeonMob("Spider");
DungeonHooks.addDungeonMob("Creeper", 100);
ChestGenHooks.removeItem(ChestGenHooks.DUNGEON_CHEST, new
ItemStack(Items.saddle));
ChestGenHooks.addItem(ChestGenHooks.DUNGEON_CHEST, new
WeightedRandomChestContent(new ItemStack(Blocks.cobblestone), 25,
50, 10));
}
}
This code adds several standard recipes, a smelting recipe, and some shapeless recipes. It also changes up the dungeons a little bit.
Except for this, the code is grouped up a little, and there are a few comments that quickly tell the reader what it does. It’s suggested to add this to your own file as well.