Jump to content

Recommended Posts

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

Posted

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.

Posted

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

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