Items added and crafting handler

This commit is contained in:
Fluid1C3
2015-08-14 19:08:58 -05:00
parent 5e0c435917
commit 21cc50c34e
17 changed files with 211 additions and 34 deletions

View File

@@ -2,6 +2,8 @@ package nmd.primal.energy;
import nmd.primal.energy.common.CommonProxy;
import nmd.primal.energy.common.ModInfo;
import nmd.primal.energy.crafting.CraftingHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
@@ -11,34 +13,35 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION)
public class Energy
{
@SidedProxy(clientSide = ModInfo.CLIENT_PROXY, serverSide = ModInfo.COMMON_PROXY)
public static CommonProxy proxy;
@Instance
public static Energy instance = new Energy();
@EventHandler
public void preinit(FMLPreInitializationEvent event)
{
Energy.proxy.preInit(event);
public class Energy {
@SidedProxy(clientSide = ModInfo.CLIENT_PROXY, serverSide = ModInfo.COMMON_PROXY)
public static CommonProxy proxy;
@Instance
public static Energy instance = new Energy();
@EventHandler
public void preinit(FMLPreInitializationEvent event) {
Energy.proxy.preInit(event);
// some example code
//System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());
}
@EventHandler
public void init(FMLInitializationEvent event)
{
// System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());
}
@EventHandler
public void init(FMLInitializationEvent event) {
FMLCommonHandler.instance().bus().register(new CraftingHandler());
// some example code
//System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());
}
// System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());
}
@EventHandler
public void postInit(FMLPostInitializationEvent e) {
System.out.println("U want some Body Massage?");
//RenderingRegistry.registerEntityRenderingHandler(EntityShit.class, new RenderSnowball(ModItems.itemShit));
// RenderingRegistry.registerEntityRenderingHandler(EntityShit.class,
// new RenderSnowball(ModItems.itemShit));
}
}

View File

@@ -1,5 +1,19 @@
package nmd.primal.energy.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModBlocks {
public static Block SMBBlock;
public static final void init() {
GameRegistry.registerBlock(SMBBlock = new SMBBlock("SMBBlock", Material.iron), "SMBBlock");
//GameRegistry.registerBlock(mineralBlock = new MineralBlock("mineralBlock", Material.rock), "mineralBlock");
}
}

View File

@@ -0,0 +1,19 @@
package nmd.primal.energy.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import nmd.primal.energy.common.ModInfo;
import nmd.primal.energy.util.CustomTab;
public class SMBBlock extends Block{
protected SMBBlock(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(ModInfo.MOD_ID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.NMDEnergyTab);
this.setHardness(1.0F);
this.setResistance(6.0F);
this.setStepSound(soundTypeStone);
}
}

View File

@@ -7,6 +7,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
public class ClientProxy extends CommonProxy{
@Override
public void preInit(FMLPreInitializationEvent event)
{
super.preInit(event);

View File

@@ -1,7 +1,10 @@
package nmd.primal.energy.common;
import nmd.primal.energy.util.CustomTab;
import nmd.primal.energy.block.ModBlocks;
import nmd.primal.energy.crafting.ModCrafting;
import nmd.primal.energy.item.ModItems;
import nmd.primal.energy.tileents.TileRegistry;
import nmd.primal.energy.util.CustomTab;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@@ -11,7 +14,9 @@ public class CommonProxy {
public void preInit(FMLPreInitializationEvent event)
{
CustomTab.NMDEnergyTab();
ModItems.registerItems();
ModBlocks.init();
ModCrafting.init();
}
public void init(FMLInitializationEvent event)

View File

@@ -2,7 +2,7 @@ package nmd.primal.energy.common;
public class ModInfo {
public static final String MOD_ID = "NMDEnergy";
public static final String MOD_ID = "energy";
public static final String MOD_NAME = "NMD Energy";
public static final String MOD_PREFIX = "nmd";
public static final String MOD_CHANNEL = "nmd-energy";
@@ -10,4 +10,6 @@ public class ModInfo {
public static final String COMMON_PROXY = "nmd.primal.energy.common.CommonProxy";
public static final String CLIENT_PROXY = "nmd.primal.energy.client.ClientProxy";
public static final int SMBBlock_ID = 201;
}

View File

@@ -0,0 +1,28 @@
package nmd.primal.energy.crafting;
import net.minecraft.item.ItemStack;
import nmd.primal.energy.item.ModItems;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
public class CraftingHandler {
@SubscribeEvent
public void onItemCrafting(PlayerEvent.ItemCraftedEvent event){
for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) { // Checks all the slots
if (event.craftMatrix.getStackInSlot(i) != null) {
ItemStack j = event.craftMatrix.getStackInSlot(i);
if (j.getItem() != null && j.getItem() == ModItems.schiselItem) {
ItemStack k = new ItemStack(ModItems.schiselItem, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
}
}
}
}
}

View File

@@ -1,5 +1,39 @@
package nmd.primal.energy.crafting;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import nmd.primal.energy.block.ModBlocks;
import nmd.primal.energy.item.ModItems;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModCrafting {
public static final void init()
{
//GameRegistry.addRecipe(new ItemStack(ModBlocks.mineralBlock), new Object[] {"aa", "aa" , 'a', ModItems.mineraldustItem});
GameRegistry.addRecipe(
new ItemStack(ModItems.schiselItem), new Object[]{
" f",
" t ",
"s ",
'f', Items.flint, 't', Items.string, 's', Items.stick});
GameRegistry.addRecipe(
new ItemStack(ModItems.sgearItem), new Object[]{
"x",
"y",
'x', new ItemStack(ModItems.schiselItem, 1, OreDictionary.WILDCARD_VALUE), 'y', ModItems.swheelItem});
GameRegistry.addRecipe(
new ItemStack(ModBlocks.SMBBlock), new Object[]{
"sss",
"s s",
"sss",
's', Blocks.wooden_slab});
}
}

View File

@@ -1,5 +1,31 @@
package nmd.primal.energy.item;
import net.minecraft.item.Item;
import nmd.primal.energy.common.ModInfo;
import nmd.primal.energy.util.CustomTab;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModItems {
public static Item schiselItem;
public static Item swheelItem;
public static Item sgearItem;
public static Item saxleItem;
public static void registerItems(){
schiselItem = new SChiselItem();
swheelItem = new Item().setUnlocalizedName("swheelItem").setCreativeTab(CustomTab.NMDEnergyTab).setTextureName(ModInfo.MOD_ID + ":swheelItem");
GameRegistry.registerItem(swheelItem, "swheelItem");
sgearItem = new Item().setUnlocalizedName("sgearItem").setCreativeTab(CustomTab.NMDEnergyTab).setTextureName(ModInfo.MOD_ID + ":sgearItem");
GameRegistry.registerItem(sgearItem, "sgearItem");
saxleItem = new Item().setUnlocalizedName("saxleItem").setCreativeTab(CustomTab.NMDEnergyTab).setTextureName(ModInfo.MOD_ID + ":saxleItem");
GameRegistry.registerItem(saxleItem, "saxleItem");
}
}

View File

@@ -0,0 +1,37 @@
package nmd.primal.energy.item;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import nmd.primal.energy.common.ModInfo;
import cpw.mods.fml.common.registry.GameRegistry;
public class SChiselItem extends Item{
private String name = "schiselItem";
private Item item;
public SChiselItem(){
setMaxStackSize(1);
setUnlocalizedName(name);
setTextureName(ModInfo.MOD_ID + ":" + name);
setMaxDamage(100);
setNoRepair();
item = this;
GameRegistry.registerItem(this, name);
}
@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemstack) {
return false;
}
@Override
public Item getContainerItem()
{
item.setDamage(new ItemStack(item), +1);
return item;
}
}

View File

@@ -6,13 +6,14 @@ import net.minecraft.item.Item;
public class CustomTab {
public static CreativeTabs NMDEnergyTab = new CreativeTabs("NMDEnergyTab")
{
public static CreativeTabs NMDEnergyTab = new CreativeTabs("NMDEnergyTab") {
@Override
public Item getTabIconItem() {return Items.blaze_powder;}};
public static void NMDEnergyTab()
{
public Item getTabIconItem() {
return Items.blaze_powder;
}
};
public static void NMDEnergyTab() {
}
}

View File

@@ -1 +1,8 @@
itemGroup.NMDEnergyTab=NMD Energy
itemGroup.NMDEnergyTab=NMD Energy
item.schiselItem.name=Standard Chisel
item.swheelItem.name=Standard Wheel
item.sgearItem.name=Standard Gear
item.saxleItem.name=Standard Axle
tile.SMBBlock.name=Standard Machine Box

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B