How to properly create attributes of item

Started by KeizuMoon on

Topic category: Help with modding (Java Edition)

Last seen on 22:29, 1. Jan 2024
Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to properly create attributes of item

I want to create many swords. I have textures and models for them. And I want swords to have custom properties. For example: pve damage. If they hit NOT a player, but some mob, with a sword, then the value that will be written in the sword itself is added to the damage. Since I will have many swords, I do not want to do a separate procedure for each one. I want to make sure there is one procedure for all swords. It should check whether the sword has such a modifier and if it does AND the player hits NOT the player, then increase the damage (edited)

 

how i can do it?

Last seen on 20:43, 20. Aug 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could either make…
Sat, 12/30/2023 - 14:57

You could either make multiple items with unique properties, (one item for each sword), and then use tags to determine which items use which properties. Then, you can make procedures with the 'before entity is hurt' global trigger, and check if the item in the main hand of the source entity, (the one attacking), is tagged in any given group. If it is, run whatever code you need depending on which property it had. 

Another option is to make one sword item, and then have a custom NBT tag for that item that determines what type of sword it is. (You could then make a procedure that determines the state of the sword based on this tag, and program in different textures for each in the 'item properties' tab.) This would be more difficult, as you couldn't hard code unique properties for each sword; you would have one item with basic properties, and then have to code in any alterations to those properties in a procedure. However, this approach might save time in the long run. If you're just starting out, and especially if you don't have that many swords, just making a unique item for each and grouping them using tags is the easier option.