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

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.

  • Author

	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?

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.

  • Author

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.

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.