Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

how would you use a tool in a crafting recipe no matter what the damage value is for it.

  • Author

how would you use a tool in a crafting recipe no matter what the damage value is for it.

(I'm not sure if I understood your question.) If you want the recipe to accept any damage value then use OreDictionary.WILDCARD_VALUE in dmg of ItemStack in the recipe.

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

(I'm not sure if I understood your question.) If you want the recipe to accept any damage value then use OreDictionary.WILDCARD_VALUE in dmg of ItemStack in the recipe.

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

  • Author

now i have a crafting handler that damages my item every time i use it in a crafting recipe but it doesn't break. How would you fix that?

  • Author

now i have a crafting handler that damages my item every time i use it in a crafting recipe but it doesn't break. How would you fix that?

EE3 (Equilant Exchange 3)

Does have the easiest way i know:

 

Look at this mod.

 

These Classes Are important:

ModItems

ItemMiniumstone

 

Look what he is doing with ContainerItem.

 

I mean these functions are needed:

ModItems: SetContainerItem,

ItemMiniumStone: GetContainerItemStack

 

with that you should get what you need^^

EE3 (Equilant Exchange 3)

Does have the easiest way i know:

 

Look at this mod.

 

These Classes Are important:

ModItems

ItemMiniumstone

 

Look what he is doing with ContainerItem.

 

I mean these functions are needed:

ModItems: SetContainerItem,

ItemMiniumStone: GetContainerItemStack

 

with that you should get what you need^^

  • Author

What I mean is I have an Item that is used only in crafting recipes but when I craft with that Item I have a handler that checks if my Item is in the crafting table then it adds damage to my Item and it shows the damage in Minecraft but when I use It up it doesn't break any suggestions?

Mine.java:

package sefodopo.mine;


import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
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;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="sefodopoMine", name="Mine", version="1.0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Mine {
final static Item mineGrind = new mainItem(5000, 64, "mineGrind").setMaxDamage(64).setNoRepair();
public static int mineGrindID = mineGrind.itemID;
public static CreativeTabs mineMain = new CreativeTabs("mineMain") {
        public ItemStack getIconItemStack() {
                return new ItemStack(mineGrind, 1, 0);
        }
};
        // The instance of your mod that Forge uses.
        @Instance("Generic")
        public static Mine instance;
       
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="sefodopo.mine.client.ClientProxy", serverSide="sefodopo.mine.CommonProxy")
        public static CommonProxy proxy;
       
        @PreInit
        public void preInit(FMLPreInitializationEvent event) {
                // Stub Method
        }
       
        @Init
        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
                LanguageRegistry.instance().addStringLocalization("itemGroup.mineMain", "en_US", "Mine");
                LanguageRegistry.addName(mineGrind, "Grind");
                mineGrind.setCreativeTab(mineMain);
                recipes();
                GameRegistry.registerCraftingHandler(new craftingHandler());
        }
       
        private void recipes() {
		GameRegistry.addRecipe(new ItemStack(mineGrind), "xxx", "xxx", "xxx", 'x', new ItemStack(Block.gravel));
		GameRegistry.addShapelessRecipe(new ItemStack(Block.sand, 3), new ItemStack(Block.dirt), new ItemStack(mineGrind, 1, OreDictionary.WILDCARD_VALUE));
		GameRegistry.addShapelessRecipe(new ItemStack(Block.sand, 5), new ItemStack(Block.cobblestone), new ItemStack(mineGrind), new ItemStack(mineGrind, 1, OreDictionary.WILDCARD_VALUE));
		GameRegistry.addShapelessRecipe(new ItemStack(Block.sand, 3), new ItemStack(Block.gravel), new ItemStack(mineGrind, 1, OreDictionary.WILDCARD_VALUE));
		GameRegistry.addShapelessRecipe(new ItemStack(Item.silk), new ItemStack(Block.cloth, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(mineGrind, 1, OreDictionary.WILDCARD_VALUE));
	}

	@PostInit
        public void postInit(FMLPostInitializationEvent event) {
                // Stub Method
        }
}

mainItem.java:

package sefodopo.mine;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class mainItem extends Item {
public mainItem(int par1, int maxStackSize, String Name, Item item) {
	super(par1);
	setMaxStackSize(maxStackSize);
	setUnlocalizedName(Name);
	setContainerItem(item);

}
public mainItem(int par1, int maxStackSize, String Name) {
	super(par1);
	setMaxStackSize(maxStackSize);
	setUnlocalizedName(Name);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) {
	this.itemIcon=iconRegister.registerIcon("sefodopo:mineGrind");
}

}

craftingHandler.java:

package sefodopo.mine;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.ICraftingHandler;

public class craftingHandler implements ICraftingHandler {

@Override
public void onCrafting(EntityPlayer player, ItemStack item, IInventory inv) {
	// TODO Auto-generated method stub
	 for(int i=0; i < inv.getSizeInventory(); i++)
	  {
	   if(inv.getStackInSlot(i) != null)
	   {
	    ItemStack j = inv.getStackInSlot(i);
	    if(j.getItem() != null && j.getItem() == Mine.mineGrind)
	    {
	     ItemStack k = new ItemStack(Mine.mineGrind, 2, (j.getItemDamage() + 1));//makes 2 items, 1 that is used and 1 that is damaged
	      inv.setInventorySlotContents(i, k);//i is slot, k is Item
	     }
	    }
	   }
	  }


@Override
public void onSmelting(EntityPlayer player, ItemStack item) {
	// TODO Auto-generated method stub

}

}

  • Author

What I mean is I have an Item that is used only in crafting recipes but when I craft with that Item I have a handler that checks if my Item is in the crafting table then it adds damage to my Item and it shows the damage in Minecraft but when I use It up it doesn't break any suggestions?

Mine.java:

package sefodopo.mine;


import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
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;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="sefodopoMine", name="Mine", version="1.0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Mine {
final static Item mineGrind = new mainItem(5000, 64, "mineGrind").setMaxDamage(64).setNoRepair();
public static int mineGrindID = mineGrind.itemID;
public static CreativeTabs mineMain = new CreativeTabs("mineMain") {
        public ItemStack getIconItemStack() {
                return new ItemStack(mineGrind, 1, 0);
        }
};
        // The instance of your mod that Forge uses.
        @Instance("Generic")
        public static Mine instance;
       
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="sefodopo.mine.client.ClientProxy", serverSide="sefodopo.mine.CommonProxy")
        public static CommonProxy proxy;
       
        @PreInit
        public void preInit(FMLPreInitializationEvent event) {
                // Stub Method
        }
       
        @Init
        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
                LanguageRegistry.instance().addStringLocalization("itemGroup.mineMain", "en_US", "Mine");
                LanguageRegistry.addName(mineGrind, "Grind");
                mineGrind.setCreativeTab(mineMain);
                recipes();
                GameRegistry.registerCraftingHandler(new craftingHandler());
        }
       
        private void recipes() {
		GameRegistry.addRecipe(new ItemStack(mineGrind), "xxx", "xxx", "xxx", 'x', new ItemStack(Block.gravel));
		GameRegistry.addShapelessRecipe(new ItemStack(Block.sand, 3), new ItemStack(Block.dirt), new ItemStack(mineGrind, 1, OreDictionary.WILDCARD_VALUE));
		GameRegistry.addShapelessRecipe(new ItemStack(Block.sand, 5), new ItemStack(Block.cobblestone), new ItemStack(mineGrind), new ItemStack(mineGrind, 1, OreDictionary.WILDCARD_VALUE));
		GameRegistry.addShapelessRecipe(new ItemStack(Block.sand, 3), new ItemStack(Block.gravel), new ItemStack(mineGrind, 1, OreDictionary.WILDCARD_VALUE));
		GameRegistry.addShapelessRecipe(new ItemStack(Item.silk), new ItemStack(Block.cloth, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(mineGrind, 1, OreDictionary.WILDCARD_VALUE));
	}

	@PostInit
        public void postInit(FMLPostInitializationEvent event) {
                // Stub Method
        }
}

mainItem.java:

package sefodopo.mine;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class mainItem extends Item {
public mainItem(int par1, int maxStackSize, String Name, Item item) {
	super(par1);
	setMaxStackSize(maxStackSize);
	setUnlocalizedName(Name);
	setContainerItem(item);

}
public mainItem(int par1, int maxStackSize, String Name) {
	super(par1);
	setMaxStackSize(maxStackSize);
	setUnlocalizedName(Name);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) {
	this.itemIcon=iconRegister.registerIcon("sefodopo:mineGrind");
}

}

craftingHandler.java:

package sefodopo.mine;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.ICraftingHandler;

public class craftingHandler implements ICraftingHandler {

@Override
public void onCrafting(EntityPlayer player, ItemStack item, IInventory inv) {
	// TODO Auto-generated method stub
	 for(int i=0; i < inv.getSizeInventory(); i++)
	  {
	   if(inv.getStackInSlot(i) != null)
	   {
	    ItemStack j = inv.getStackInSlot(i);
	    if(j.getItem() != null && j.getItem() == Mine.mineGrind)
	    {
	     ItemStack k = new ItemStack(Mine.mineGrind, 2, (j.getItemDamage() + 1));//makes 2 items, 1 that is used and 1 that is damaged
	      inv.setInventorySlotContents(i, k);//i is slot, k is Item
	     }
	    }
	   }
	  }


@Override
public void onSmelting(EntityPlayer player, ItemStack item) {
	// TODO Auto-generated method stub

}

}

  • Author

never mind I was able to add an if statement to check if it would be the last use and then only create one.

  • Author

never mind I was able to add an if statement to check if it would be the last use and then only create one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.