Jump to content

Make item damaged in crafting get repaired.


dude22072

Recommended Posts

Is their a way i can make an item that gets damaged in crafting get repaired via crafting?

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Link to comment
Share on other sites

As in, set the damage (metadata) to 0.

1.this would still clone it

2.i don't want it to be 100%, if i did i would use the anvil

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Link to comment
Share on other sites

As in, set the damage (metadata) to 0.

1.this would still clone it

2.i don't want it to be 100%, if i did i would use the anvil

Aw, for the love of Pete. Just show me your code.

Maybe I didn't explain well enough:

I have an item. When you use it in a crafting recipe it remains and simply takes damage(Like the minium stone from EE3).

I want the item to have a recipe that repairs the item instead of damaging it.

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Link to comment
Share on other sites

What do i do within the class?

ย 

(also here is my crafting manager if i can just use this file)

package dudesmods.lozmod;

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

public class LOZCraftingHandler implements ICraftingHandler {

 public void onCrafting(EntityPlayer player, ItemStack item, IInventory inv) 
 {
ย  ย  for(int i=0; i < inv.getSizeInventory(); i++)
ย  {ย  ย  ย  ย   
ย  ย  ย  if(inv.getStackInSlot(i) != null)
ย  ย  ย  {
ย  ย  ย   ItemStack j = inv.getStackInSlot(i);
ย  ย  ย   if(j.getItem() != null && j.getItem() == LOZmod.magicPowder)
ย  ย  ย   {
ย  ย  ย  ย  ItemStack k = new ItemStack(LOZmod.magicPowder, 2, (j.getItemDamage() + 1));
ย  ย  ย  ย  inv.setInventorySlotContents(i, k);
ย  ย  ย   }
ย  ย  ย  }ย  
ย  }
 }

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

}
}

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Link to comment
Share on other sites

What do i do within the class?

ย 

(also here is my crafting manager if i can just use this file)

package dudesmods.lozmod;

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

public class LOZCraftingHandler implements ICraftingHandler {

 public void onCrafting(EntityPlayer player, ItemStack item, IInventory inv) 
 {
ย  ย  for(int i=0; i < inv.getSizeInventory(); i++)
ย  {ย  ย  ย  ย   
ย  ย  ย  if(inv.getStackInSlot(i) != null)
ย  ย  ย  {
ย  ย  ย   ItemStack j = inv.getStackInSlot(i);
ย  ย  ย   if(j.getItem() != null && j.getItem() == LOZmod.magicPowder)
ย  ย  ย   {
ย  ย  ย  ย  ItemStack k = new ItemStack(LOZmod.magicPowder, 2, (j.getItemDamage() + 1));
ย  ย  ย  ย  inv.setInventorySlotContents(i, k);
ย  ย  ย   }
ย  ย  ย  }ย  
ย  }
 }

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

}
}

Oh, that looks like it should work. Although I would just use j.setItemDamage(j.getItemDamage()+1) instead of creating a new ItemStack.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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