Jump to content

Recommended Posts

Posted

I'm making an item that has to be reloaded after every shot. To reload the item the player needs to hold down the item for a certain period of time. After the item has been reloaded I want to cancel the the progress / animation of the reload. Pretty sure back in 1.7/1.8 there was a EntityPlayer#clearItemInUse method for this. I'd like to know if there is an equivalent to the method in 1.12 and if this can be done at all.

Posted

Try with something like
 

    @Override 
    public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
    {
    	if(slotChanged){
    		return true;
    	}
    	return false;
    }

 

Or adjust it to return true whenever you consider it necessary.

 

I have it like
 

    @Override 
    public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
    {
    	if(slotChanged || (oldStack.getItem() != newStack.getItem())){
    		return true;
    	}
    	return false;
    }


On my last example the mistake it that it wont case the animation if I change between 2 slots with the same item checked. (But that's fixable) :P

Posted (edited)

Thanks for your reply. The thing is that I need access to the amount of seconds the item was held for and I don't really want to use NBT. Isn't there just a method that cancels the use of the item?

Edited by Melonslise

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.