Melonslise Posted December 21, 2017 Posted December 21, 2017 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. Quote
American2050 Posted December 21, 2017 Posted December 21, 2017 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) Quote
Melonslise Posted December 21, 2017 Author Posted December 21, 2017 (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 December 21, 2017 by Melonslise Quote
Melonslise Posted December 22, 2017 Author Posted December 22, 2017 (edited) I managed to do this by calling EntityLivingBase#stopActiveHand. Edited December 22, 2017 by Melonslise 1 Quote
Recommended Posts
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.