Skip to content

Instantly share code, notes, and snippets.

Created November 7, 2013 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1e30ea376d8f3a93573e to your computer and use it in GitHub Desktop.
Save anonymous/1e30ea376d8f3a93573e to your computer and use it in GitHub Desktop.
main class code
package jonas.myMod;
import net.minecraft.block.Block;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
import net.minecraft.src.ModLoader;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; // used in 1.6.2
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
@Mod(modid="Jonas", name="MyMod", version="0.0.1")
@NetworkMod(clientSideRequired=true)
public class MyMod {
//Materials
EnumToolMaterial FRAG_SWORD = EnumHelper.addToolMaterial("FRAG_SWORD", 3, 59, 12.0F, 7.0F, 30);
EnumArmorMaterial SCALE_ARMOR = EnumHelper.addArmorMaterial("SCALE_ARMOR", 66, new int[]{6, 16, 12, 6}, 30);
//Tabs
public static CreativeTabs tabJonas = new CreativeTabs("tabJonas") {
public ItemStack getIconItemStack() {
return new ItemStack(MyMod.fragment, 1, 0);
}
};
//Armour Declarations
public static Item scaleHelmet;
public static Item scaleChestplate;
public static Item scaleLeggings;
public static Item scaleBoots;
public static Item plateHelmet;
public static Item plateChestplate;
public static Item plateLeggings;
public static Item plateBoots;
public static Item darkBone; //crafts with ebonsand to make sand
public static Item fragSword; //fragile, powerful sword
public static Item potatoBakedSkewer; //unfinished
public static Item potatoRawSkewer; //unfinished
public static Item fragment; //only used for scales and swords
public static Item plate; //implemented, unused
public static Item scale; //makes plate
public static Block ebonsand;
public static Block shadowFossil;
@Instance(value = "Jonas")
public static MyMod instance;
@SidedProxy(clientSide="jonas.myMod.client.ClientProxy", serverSide="jonas.myMod.CommonProxy")
public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
//Foods
potatoBakedSkewer = new ItemPotatoSkewer(8000, 7, .9F, false)
.setMaxStackSize(1).setCreativeTab(tabJonas).setTextureName("mymod:potatobakedskewer").setUnlocalizedName("potatoBakedSkewer");
potatoRawSkewer = new ItemPotatoSkewer(8001, 2, .2F, false)
.setMaxStackSize(1).setCreativeTab(tabJonas).setTextureName("mymod:potatorawskewer").setUnlocalizedName("potatoRawSkewer");
//Armor
scaleHelmet = new ItemScaleArmor(8050, SCALE_ARMOR, ModLoader.addArmor("SCALE_ARMOR"), 0)
.setCreativeTab(tabJonas).setUnlocalizedName("scaleHelmet");
scaleChestplate = new ItemScaleArmor(8051, SCALE_ARMOR, ModLoader.addArmor("SCALE_ARMOR"), 1)
.setCreativeTab(tabJonas).setUnlocalizedName("scaleChestplate");
scaleLeggings = new ItemScaleArmor(8052, SCALE_ARMOR, ModLoader.addArmor("SCALE_ARMOR"), 2)
.setCreativeTab(tabJonas).setUnlocalizedName("scaleLeggings");
scaleBoots = new ItemScaleArmor(8053, SCALE_ARMOR, ModLoader.addArmor("SCALE_ARMOR"), 3)
.setCreativeTab(tabJonas).setUnlocalizedName("scaleBoots");
//Weapons
fragSword = new ItemFragSword(8100, FRAG_SWORD)
.setCreativeTab(tabJonas).setTextureName("mymod:fragsword").setUnlocalizedName("fragSword");
//Other Items
fragment = new Item(8150)
.setMaxStackSize(16).setCreativeTab(tabJonas).setTextureName("mymod:fragment").setUnlocalizedName("fragment");
scale = new Item(8151)
.setMaxStackSize(24).setCreativeTab(tabJonas).setTextureName("mymod:scale").setUnlocalizedName("scale");
plate = new Item(8152)
.setMaxStackSize(24).setCreativeTab(tabJonas).setUnlocalizedName("plate");
darkBone = new Item(8153)
.setMaxStackSize(64).setCreativeTab(tabJonas).setTextureName("mymod:darkbone").setUnlocalizedName("darkBone");
//Blocks
ebonsand = new BlockEbonsand(800, Material.sand)
.setHardness(.5F).setStepSound(Block.soundSandFootstep).setCreativeTab(tabJonas).setTextureName("mymod:Ebonsand").setUnlocalizedName("ebonsand");
shadowFossil = new BlockShadowFossil(801, Material.rock);
}
@EventHandler // used in 1.6.2
public void load(FMLInitializationEvent event) {
//Item names
LanguageRegistry.addName(potatoBakedSkewer, "Potato Sheesh-ka-bob");
LanguageRegistry.addName(potatoRawSkewer, "Potato on a stick...");
LanguageRegistry.addName(fragment, "Shadow Fragment");
LanguageRegistry.addName(scale, "Shadow Scale");
LanguageRegistry.addName(darkBone, "Dark Bone");
LanguageRegistry.addName(fragSword, "Fragmented Sword");
LanguageRegistry.addName(plate, "Shadow Plate");
LanguageRegistry.addName(scaleChestplate, "Scale Chestplate");
LanguageRegistry.addName(scaleHelmet, "Scale Helmet");
LanguageRegistry.addName(scaleLeggings, "Scale Leggings");
LanguageRegistry.addName(scaleBoots, "Scale Boots");
LanguageRegistry.addName(ebonsand, "Ebonsand");
LanguageRegistry.addName(shadowFossil, "Shadow Fossil");
//Blocks, tool, plants, names, armor
GameRegistry.registerBlock(ebonsand, "ebonsand");
MinecraftForge.setBlockHarvestLevel(ebonsand, "shovel", 0);
GameRegistry.registerBlock(shadowFossil, "shadowFossil");
MinecraftForge.setBlockHarvestLevel(shadowFossil, "pickaxe", 3);
//Item Stacks
ItemStack darkBoneOne = new ItemStack(MyMod.darkBone);
ItemStack ebonsandOne = new ItemStack(MyMod.ebonsand);
ItemStack glassOne = new ItemStack(Block.glass);
ItemStack potatoBakedSkewerOne = new ItemStack(MyMod.potatoBakedSkewer);
ItemStack potatoRawOne = new ItemStack(Item.potato);
ItemStack potatoRawSkewerOne = new ItemStack(MyMod.potatoRawSkewer);
ItemStack sandTwo = new ItemStack(Block.sand, 2);
ItemStack fragmentOne = new ItemStack(MyMod.fragment);
ItemStack plateOne = new ItemStack(MyMod.plate);
ItemStack scaleOne = new ItemStack(MyMod.scale);
ItemStack stickOne = new ItemStack(Item.stick);
ItemStack woolPurpleOne = new ItemStack(Block.cloth, 1, 10);
ItemStack fragSwordOne = new ItemStack(MyMod.fragSword);
ItemStack bonemealThree = new ItemStack(Item.dyePowder, 3, 15);
//Recipes
GameRegistry.addRecipe(scaleOne, " x ", "xxx", "x x",
'x', fragmentOne);
GameRegistry.addRecipe(potatoRawSkewerOne, "x", "y",
'x', potatoRawOne, 'y', stickOne);
GameRegistry.addRecipe(plateOne, " x ", "xxx", " x ",
'x', scaleOne);
GameRegistry.addRecipe(fragSwordOne, " x ", " x ", " y ",
'x', fragmentOne, 'y', darkBoneOne);
GameRegistry.addSmelting(MyMod.ebonsand.blockID, glassOne, 0.1F);
GameRegistry.addSmelting(MyMod.potatoRawSkewer.itemID, potatoBakedSkewerOne, .35F);
GameRegistry.addShapelessRecipe(sandTwo, darkBoneOne, ebonsandOne);
GameRegistry.addShapelessRecipe(bonemealThree, darkBoneOne);
proxy.registerRenderers();
LanguageRegistry.instance().addStringLocalization("itemGroup.tabJonas", "en_US", "Jonas");
}
@EventHandler // used in 1.6.2
public void postInit(FMLPostInitializationEvent event) {
// Stub Method
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment