Custom code for Items with potion effects.

Started by ProjectDefault on Sat, 11/28/2015 - 06:01
Last seen on 08:41, 28. Nov 2015
Joined Sep 2014
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Custom code for Items with potion effects.
Sat, 11/28/2015 - 06:01

XXXX = Item name

Find this:

static class ItemsXXXX extends Item{

public ItemsXXXX(int par1){
setMaxDamage(0);
maxStackSize = 64;
setUnlocalizedName("XXXX");
GameRegistry.registerItem(this, "XXXX");
setCreativeTab(CreativeTabs.tabCombat);
}

And simply add this above "setUnlocalizedName("XXXX");" : setPotionEffect(Potion.regeneration.id, 6, 1, 1.0F);

So it will look like this now: 

static class ItemsXXXX extends Item{

public ItemsXXXX(int par1){
setMaxDamage(0);
maxStackSize = 64;
setPotionEffect(Potion.regeneration.id, 6, 1, 1.0F);
setUnlocalizedName("XXXX");
GameRegistry.registerItem(this, "XXXX");
setCreativeTab(CreativeTabs.tabCombat);
}

Enjoy

 

P.S : Use the same method for food if you get a compile error when using the normal options to add potion effects.

Last seen on 16:28, 25. Feb 2018
Joined Jan 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
does it work will tools?
Sat, 03/19/2016 - 01:24

does it work will tools?

Last seen on 16:45, 28. Jan 2018
Joined Aug 2014
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Really nice! I'm gonna try it
Mon, 03/28/2016 - 15:11

Really nice! I'm gonna try it

What's if I want to create a poisoned sword? That gives poison effect to the entity I hit with?
I tried something like this: 
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving) { 

 par2EntityLiving.addPotionEffect(new PotionEffect(Potion.poison.id, 20 * 5, 100)); System.out.println("Poisoned something."); return true;

}
But nothing works

 

Can you help me?