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

hello

 

i need to keep this itemStack active in use for 20 ticks if certain conditions meet

 

but as you know playerIn.setActiveHand(hand);  stop in the moment you release rightclick

so also stops onUsingTick()method

 

i wanna touch right click like for 4 ticks  and release, but i want this item to act as i where keeping the rightClick hold per a full second

 

this is all for an experiment I'm trying to make works the offhand item event when you have another in the main hand without having to create a new entity to keep values on

 

// ############################################################################################3
@Override
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) {
	count = 10000 - count;

	System.out.println("## count=" + count);

	// World worldIn = player.worldObj;

	// 10000 9999 9998 9997 9996

	if (count < 9997) {

		if (count == 9996) {

		}

		if ((count % 2) == 0) {

		}

		if ((count % 2) == 0) {

		}

	}

}

// ############################################################################################3

 

###

some idea

 

thanks for reading

So you are saying that when you right click at all with an item, it will act as if you held it down for one second? You could try setting a a counter that starts at 0 and increments by one every time Item#onUpdate is called. If the counter is less than 20, then call whatever method you are using to handle the right click action.

  • Author

momentum

sounds posible

until what i try was to

 

@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {

	if (isSelected && !worldIn.isRemote) {

		if (entityIn instanceof EntityLivingBase) {

			EntityLivingBase playerIn = (EntityLivingBase) entityIn;

			playerIn.setActiveHand(EnumHand.MAIN_HAND);
		}
	}
}

 

 

but this could be

 

// ############################################################################################3

/**
 * Called each tick as long the item is on a player inventory. Uses by maps
 * to check if is on a player hand and update it's contents.
 */
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {

	if (isSelected && !worldIn.isRemote) {

		if (entityIn instanceof EntityLivingBase) {

			EntityLivingBase playerIn = (EntityLivingBase) entityIn;

			ItemStack offHand = playerIn.getHeldItem(EnumHand.OFF_HAND);
			ItemStack mainHand = playerIn.getHeldItem(EnumHand.MAIN_HAND);


			if ( mainHand != null && mainHand.getItem() instanceof cargadorMercenario00 )
			{
				int conteo = playerIn.getEntityData().getInteger("conteoMain");

				mainHand.getItem().onUsingTick(mainHand, playerIn, mainHand.getMaxItemUseDuration() - conteo );

				conteo ++;

				playerIn.getEntityData().setInteger("conteoMain", conteo);

			}


		}
	}
}

// ############################################################################################3

 

i have to store the values as nbttags on the player but works it seems to work the only down side could be sync it whith on render tick to make animation razonable

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.