How to make a throwable that has it self for ammo lose durabillity each time it hits something.

Started by ManTruck29 on

Topic category: Help with modding (Java Edition)

Last seen on 18:50, 18. May 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make a throwable that has it self for ammo lose durabillity each time it hits something.

Hello, so i have a throwable axe that uses it self as ammo and when you throw it it get's removed from your inventory and when it hit's either ground either entity it will drop as an item in that location. The problem is i can't figure how to keep the durabillity of it and deal damage to it when it hit's something. Anyone that could help?

Last seen on 12:31, 22. Jan 2024
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ok i see why you are…
Wed, 10/25/2023 - 20:06

ok i see why you are confused because this involves using some complex stuff

in the text below i will refer to the entity that is flying in the air (like an arrow or a bullet) as the "ranged item entity"

so the problem is that when you throw the axe, it resets the durability because the ranged item entity isnt actually able to store a durability value because it's an entity not an item

so the solution to this is to create an NBT variable that is stored inside the ranged item entity

this NBT variable would store the durability of the item

when you throw the item, it would set the durability NBT variable of the ranged item entity = to the durability of the item

and when it lands on the ground, it would set the ground item's durability NBT = to the ranged item entity's NBT

sorry if this is unclear, if you're confused then tell me that and i will draw a picture or something