MC Modding
Please register and join the community!


[1.8.1] Recharging Item

View previous topic View next topic Go down

[1.8.1] Recharging Item

Post by Strengthowns on Wed Oct 05, 2011 6:55 pm

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!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Recharging Item

Post by pv9avenger on Wed Feb 01, 2012 2:33 am

what do you mean by recharging item

pv9avenger
Member

Posts: 8
Join date: 2012-02-01
Age: 12
Location: Iceland

View user profile

Back to top Go down

View previous topic View next topic Back to top


Permissions in this forum:
You cannot reply to topics in this forum