Posted October 2, 20196 yr @Override public void onUsingTick(ItemStack itemstack, EntityLivingBase entity, int count) { EntityPlayer player = (EntityPlayer) entity; if(fireAble(itemstack)) { fire(player.world, player, itemstack); } if (reloadAble((EntityPlayer) player, itemstack) && !(this.loading)) { reload(this.ammoType, (EntityPlayer) player, itemstack); } } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if(!worldIn.isRemote) { if(!playerIn.isHandActive()) { if (fireAble(itemstack)) { fire(worldIn, playerIn, itemstack); } if (reloadAble(playerIn, itemstack) && !(this.loading)) { reload(this.ammoType, playerIn, itemstack); } playerIn.setActiveHand(handIn); return new ActionResult<>(EnumActionResult.SUCCESS, itemstack); } } return new ActionResult<>(EnumActionResult.FAIL, itemstack); } I've written these codes. They work fine in the creative mode, the gun stopped fire when the right mouse button was released, but in survival mode, sometimes it just doesn't stop, the gun keeps fire although the player has released the mouse. What might cause this problem and how do I solve it?
October 2, 20195 yr Author After running a couple of times, I notice the problem is itemstack.damageItem(1, player); If I remove this line of code everything works again, but as soon as I add it in either onitemrightclick() or onusingitem() it acts weird, I think when Minecraft sets the item's damage it interrupts with the using method. Any way to solve this? I have tried to use setdamage instead of damageitem doesn't work either.
October 3, 20195 yr 2 hours ago, poopoodice said: Any way to solve this? I believe this has been a problem for a long time. It happens whenever the ItemStack changes. I'm thinking you might be able to use Item#shouldCauseRequipAnimation? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 3, 20195 yr Author 1 minute ago, Animefan8888 said: I believe this has been a problem for a long time. It happens whenever the ItemStack changes. I'm thinking you might be able to use Item#shouldCauseRequipAnimation? What I mean by doesnt stop isnt just about the animation, it also execute the code in the method. And I did use shouldCauseReequipAnimation and returned false but still not working
October 3, 20195 yr Author 3 hours ago, Animefan8888 said: I believe this has been a problem for a long time. It happens whenever the ItemStack changes. I'm thinking you might be able to use Item#shouldCauseRequipAnimation? Is it better to use events instead of onitemrightclick and onusingtick Edited October 3, 20195 yr by poopoodice
October 3, 20195 yr Author 4 hours ago, diesieben07 said: In 1.14.4 you can override canContinueUsing in your Item class to change this behavior. I don't think there is a way to do it in 1.12.2. Alright, thank you.
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.