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
    @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?

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

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.

  • 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

  • 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 by poopoodice

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

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.