Jump to content

[1.7.10] Shift + Mine Function ? <SOLVED>


BaXMultigaming

Recommended Posts

Hey,

 

	public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
  {
    if (par3EntityLivingBase.isSneaking())
    {
      par3EntityLivingBase.dropItem(Waluta.instance, 1);
      par1ItemStack.damageItem(100, par3EntityLivingBase);
      return true;
    }
    par1ItemStack.damageItem(1, par3EntityLivingBase);
    return true;
}

 

How to make something similar like this but on pickaxe ? I was thinking about that if player is mining without holding shift diamond,iron,emerald,gold ore it drop normal items and subtract -1 durability, but when player will hold shift and than mine it will drop that (Waluta.instance, 1) item but it will also subtract -100 durability.

 

Sorry for my english.

Link to comment
Share on other sites

	public boolean onBlockLeftClicked(ItemStack damage, EntityLivingBase player, PlayerInteractEvent event)
	{
	if (event.action != PlayerInteractEvent.Action.LEFT_CLICK_BLOCK){
	   if (player.isSneaking())
	   {
		   player.dropItem(Waluta.instance, 1);
		   damage.damageItem(100, player);
	      return true;
	   }
	}
	damage.damageItem(1, player);
	return true;
	}

 

Is that right or not?

Link to comment
Share on other sites

You would know if you just looked at ANY tutorial on google... Search Forge Events.

 

You are missing @SubscribeEvent.

Event method takes only one argument - Event itself.

You pull data only from event. Exacly like you did with event.action...

If event is client side you can also use client classes, e.g Minecraft.class#thePlayer.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

I had other idea and i made something like this :

 

	public boolean onBlockDestroyed(ItemStack damage, World world, Block block, int arg1, int arg2, int arg3, EntityLivingBase player)
	{
    if ((double)block.getBlockHardness(world, arg1, arg2, arg3) != 0.0D)
    {
    	if (player.isSneaking())
	    {
    	player.dropItem(Waluta.instance, 1);
    	damage.damageItem(100, player);
	    return true;
    	}
    }
    damage.damageItem(1, player);
    return true;
}

 

It works fine.

Link to comment
Share on other sites

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.