[1.8.1] Recharging Item
MC Modding :: Modding :: Singleplayer Modding :: Tutorials
Page 1 of 1 • Share •
[1.8.1] Recharging Item
Recharging Item
- Spoiler:
- ItemNamehere
- Code:
package net.minecraft.src;
import java.util.*;
public class ItemNamehere extends Item
{
public ItemNamehere(int i)
{
super(i);
maxStackSize = 1;
setMaxDamage(40);
}
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
if(itemstack.getItemDamage() == 0)
{
itemstack.damageItem(40, entityplayer);
}
return itemstack;
}
public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
{
if(itemstack.getItemDamage() != 0)
{
itemstack.damageItem(-1, entity);
}
}
}
mod_Namehere- Code:
package net.minecraft.src;
public class mod_Namehere extends BaseMod
{
public static Item Namehere = (new ItemNamehere(30438)).setItemName("Namehere");
public mod_Namehere()
{
Namehere.iconIndex = ModLoader.addOverride("/gui/items.png", "/Namehere.png");
ModLoader.AddName(Namehere, "Namehere");
}
public String Version()
{
return "1.8.1";
}
}
Help: ItemNamehere
1. Change the 40 in "setMaxDamage(40);" to whatever number you want. This will be how much/long it has to recharge.
2. Again, change the 40 in "itemstack.damageItem(40, entityplayer);" to the number you put in step 1. This is how much the recharge bar goes down on use.
3. Leave everything else as is.Help: mod_Namehere
1. Same as normal.

Strengthowns- Admin
- Posts: 79
Join date: 2011-06-14
Location: Right here!

Re: [1.8.1] Recharging Item
what do you mean by recharging item
pv9avenger- Member
- Posts: 8
Join date: 2012-02-01
Age: 12
Location: Iceland
MC Modding :: Modding :: Singleplayer Modding :: Tutorials
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum





