Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[SOLVED]Item Effect don't work as I want.

Featured Replies

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?

dont use ids to compare, use the instance of the item u create to register the item.

so use equippedItem==myItem

  • Author

Hm I think I don't understand...

you mean I've change

if(Player.getCurrentEquippedItem() !=null)

to

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

 

???

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.