Jump to content

Recommended Posts

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;
    }

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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?

Posted

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

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