Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.15.2] How to apply bonus damage to item [Solved]
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Thorius

[1.15.2] How to apply bonus damage to item [Solved]

By Thorius, January 14 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Thorius    0

Thorius

Thorius    0

  • Tree Puncher
  • Thorius
  • Members
  • 0
  • 24 posts
Posted January 14 (edited)

Hello,

I want to apply bonus damage to my weapon if the attacked entity meets the criteria. However, onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity entity) disables the normal attack damage because of the invulnerability after taking damage.

Maybe i could get this working but what would be the best and least ugly way to implement this feature?

 

I really appreciate any help you can provide.

Edited January 14 by Thorius
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7614

diesieben07

diesieben07    7614

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7614
  • 55199 posts
Posted January 14

You can use LivingHurtEvent to modify the amount of damage an entity takes. You can then check the source of the damage (DamageSource#getTrueSource gets you the entity that caused the damage) and check if they are holding your sword.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

Thorius    0

Thorius

Thorius    0

  • Tree Puncher
  • Thorius
  • Members
  • 0
  • 24 posts
Posted January 14

Thank you, it's working.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • AzizD
      [1.16.4] Custom item enchantability

      By AzizD · Posted 33 minutes ago

      I got it.
    • diesieben07
      [1.16.4] Custom item enchantability

      By diesieben07 · Posted 39 minutes ago

      Please don't use raw types. Store the Set in a field, don't create it every time.
    • AzizD
      [1.16.4] Custom item enchantability

      By AzizD · Posted 40 minutes ago

      It looks way better. Thanks for the advice. @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { Set e = ImmutableSet.of( Enchantments.SHARPNESS, Enchantments.LOOTING, Enchantments.FIRE_ASPECT, Enchantments.UNBREAKING, Enchantments.KNOCKBACK ); return e.contains(enchantment); }  
    • Nikibiki
      [1.16] Custom ItemGroup icon

      By Nikibiki · Posted 46 minutes ago

      I just want to say that this thread has been massively helpful to me! Thank you to all who have contributed.
    • diesieben07
      minecraft crashes as soon as I use shaders

      By diesieben07 · Posted 47 minutes ago

      That's the graphics driver
  • Topics

    • AzizD
      9
      [1.16.4] Custom item enchantability

      By AzizD
      Started 12 hours ago

    • JoieNL
      4
      [1.16] Custom ItemGroup icon

      By JoieNL
      Started September 25, 2020

    • JoehnMama
      4
      minecraft crashes as soon as I use shaders

      By JoehnMama
      Started 4 hours ago

    • MrDuck20
      1
      Error exit code 0 when i start the game.

      By MrDuck20
      Started 48 minutes ago

    • BBoi69
      1
      My modpack takes years to load

      By BBoi69
      Started 1 hour ago

  • Who's Online (See full list)

    • Zemelua
    • diesieben07
    • AzizD
    • kiou.23
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.15.2] How to apply bonus damage to item [Solved]
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community