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.

Featured Replies

Posted

How would I make it so that the item only glows when it's held and doesn't glow when it's not held?

 

@SideOnly(Side.CLIENT)
    @Override
    public boolean hasEffect(ItemStack stack) {
        return true;
    }

This is the method :P

    public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)

Probe around the isSelected flag. You'll probably need to be hacky to make sure you can revert the effect flag though.

I think its my java of the variables.

I'm pretty sure it's just reading from NBT, so nothing really hacky here.

I'm more getting at how to turn the flag off when the item ceases to be held such as when thrown, moved in inventory, on player death, etc. I'm not aware of whether or not a final tick is sent to the item somewhere before it's unequipped though :P

I think its my java of the variables.

It would also show up in item frames in the "enchanted" state because putting an item into an item frame calls nothing.  The stack is cloned (storing the clone in the item frame) and deleted from your inventory.  That's it.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Hence me saying to use the system time. You can check if more than X milliseconds have passed in the hasEffect method.

 

Oh ho, that's clever.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Oh ho, that's clever.

You know what they say about clever programming. I am not proud of this one :D

 

Nah, it's more along the lines of having gotten so used to using system time being the absolutely wrong tool for the job (for various reasons, depending on platform) so remembering that it's there in certain edge cases can actually be useful.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Since it's a client-only method, it may be possible to directly check the player's held item to see if it's the same stack as the argument.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

Okay then instead of making it glow how would I do it so on held it changes to another item and when that other item is stopped being held it changes to the original item?

Wrong question.

 

The answer is "it doesn't matter because only the currently held item is relevant."

 

If the item is currently held: glow

If the item is not currently held: don't glow

 

Two different items apply this same rule independently.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.