Hi everyone! This is my first post, so go easy on me, also i'd like to apologise in advance about my english, that not that good but i'm sure you all will understand.
I'm a beginner em "progamming" ( the quotes are cuz i'm not that good ), so, of course before i decide to make this post, i searched into the deeps of the internet for the answer but i don't even get close what i did wrong.
I was doing a easy task, this worked, but with a bug, the item last forever!
The item takes damage, but when it goes to 0(zero) this wont break, it still taking damage over damage but still there.
This is the event code:
package com.electroink.main;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
public class MyMod {
@SubscribeEvent
public void onCrafting(PlayerEvent.ItemCraftedEvent e) {
for(int i=0; i < e.craftMatrix.getSizeInventory(); i++)
{
if(e.craftMatrix.getStackInSlot(i) != null)
{
ItemStack j = e.craftMatrix.getStackInSlot(i);
if(j.getItem() != null && j.getItem() == DamagedItem)
{
ItemStack k = new ItemStack(DamagedItem, 2, (j.getItemDamage() + 1 ));
e.craftMatrix.setInventorySlotContents(i, k);
}
}
}
}
}
The FML stuff:
@EventHandler
public static void PreLoad(FMLPreInitializationEvent PreEvent){
FMLCommonHandler.instance().bus().register(new MyMod());
}
And the recipe:
GameRegistry.addShapelessRecipe(new ItemStack(crafteditem, 1, 0), new ItemStack(useditem1), new ItemStack(willgetdamageitem, 1, OreDictionary.WILDCARD_VALUE));
I'd like to thanks the attention.
Best regrats, Necrolytie.