Get amount of damage item does

Discussion in 'Spigot Plugin Development' started by NoComment_, Apr 21, 2017.

  1. Hello,

    How can I get how many damage can does the item in the main hand of a Player, using PlayerInteractEvent (not EntiyDamageByEntityEvent)

    Thanks you :)
  2. There's no exact list of the amount every item does by hitting an entity, because its almost related to like enchantments / custom enchantments, so you could better create a small test class where you give people every item in a small shedule ( where it automatically hits a custom entity ) and you just store that data to a file and read the values from there. ( Might be different to some mobs / players / like +0.05 damage then to others)
  3. I say play with the damage first; These are values you need to know; Either check the Wiki or make an NPC and return the damage value. As the above pos says store em as a values
  4. You can calculate the damage, for example: a Diamond Sword with Fire Aspect II.
    Diamond Sword Damage: 7 (3.5 hearts)
    Fire Aspect Damage: (level * 4) - 1 (source Minecraft Wiki)
    Total Damage = 7 + (2 * 4) - 1 = 7 + 8 - 1 = 15 - 1 = 14. (7 hearts damage)

    Please correct me if I'm wrong.
  5. @Eelek - u were bothered xd
    Meths Wizz
    • Funny Funny x 1
  6. ;P

    All other enchantment data can be found on the wiki as well
  7. Yea, this could be possible but as @NoComment_ mentioned, he asked for something like whatever you hold in the Hand should be a damage calculated, so i think its a bit more complicated so i posted my answer to that, because he may use custom enchantments with different items so your idea is good, but too complex to get the exact values for every item that exists in the system
    (Not sure yet but i saw a method like event.getDamage() some months ago, but haven't actually tried that, might be also helpful)
  8. The PlayerInteractEvent doesn't have a getDamage() method.

    I believe (correct me if I'm wrong) every item that isn't a tool has a default damage that it deals on 'impact'. So you could use that value for non-tools.
    For tools, you'd need the base damage, but all that information can be found on the wiki. Same goes for enchantments. Just add up the numbers, like I did in my other post.
    For custom enchantments: If they're selfmade: he knows the effects (and if so the damage).
    If they're not self made, there could be some kind of documentation for it.

    It will take a lot of time, but it can be done.
  9. Yeah but it is very optimizes x) I wanted to found an another way more optimized ^^
    Yes, but doing this will take a long time
  10. Then I don't know.

    But there's plenty of fish in the sea :).
    • Funny Funny x 2