Jump to content

Recommended Posts

Posted

Hello and sry for my silly questions.  :-[

I want to add a effect on my Item if I hold it.

But I everytime i get the effect if it just in the inventory...

How can I fix it?

(This is a Code I've used in 1.6 but I deleted some code in it to fix errors... this is maybe the problem..)

	   public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
    {
    EntityPlayer Player = (EntityPlayer) entity;
    if(Player.getCurrentEquippedItem() !=null)
    {
    Player.addPotionEffect((new PotionEffect(Potion.fireResistance.getId(), 25, 0)));
    }
    else
    {
    Player.curePotionEffects(itemstack);
    }
    }

 

I've changed this:

if(Player.getCurrentEquippedItem() !=null && Player.getCurrentEquippedItem().itemID == this.itemID

To this:

if(Player.getCurrentEquippedItem() !=null)

 

How can I replace .itemID?

Posted

Hm I think I don't understand...

you mean I've change

if(Player.getCurrentEquippedItem() !=null)

to

if(Player.getCurrentEquippedItem() == ModDatabase.myItem)

 

???

Posted

if(Player.getCurrentEquippedItem().equals(ModDatabase.myItem))

 

That is assuming 'ModDatabase' is your main class or whatever class you have your items registered/defined in.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

To make it simple.

 

 if(Player.getCurrentEquippedItem() !=null && Player.getCurrentEquippedItem().itemID == this.itemID 

NO

 

 if(Player.getCurrentEquippedItem()==MyItem) 

YES

 

if you dont understand this go back, learn some java and come backj then

 

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.