Colored tool labels

Started by Siwek44 on Fri, 11/25/2022 - 11:20

Topic category: Help with modding (Java Edition)

Last seen on 17:04, 13. Jan 2023
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Colored tool labels
Fri, 11/25/2022 - 11:20

When creating an item, we can choose rarity (Common: White, Uncommon: Yellow, Rare: Aqua, Epic: Light Purple)
I would like to set this color for a sword (tool doesnt have a rarity tab like items). Is it possible by changing the code? Thanks in advance for your help

Last seen on 00:25, 25. Dec 2022
Joined Nov 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
use this symobl --> § and…
Sat, 11/26/2022 - 01:35

use this symobl --> § and numbers after it for coloring text, for example "§1Sword". the symbol will not show in-game. §r to get rid of color

Last seen on 23:35, 29. Nov 2022
Joined Jan 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
You can do this plain and…
Sat, 11/26/2022 - 20:15

You can do this plain and simple by changing the code.

Open your tool's code file and look for a line similar to this one (I've highlighted the important bit to look for in bold):

}, 3, -2f, new Item.Properties().tab(GerbilstuffModTabs.TAB_TAB_ITEMS).fireResistant());

Simply add ".rarity(Rarity.COMMON)" (or Rarity.UNCOMMON, Rarity.RARE, or Rarity.EPIC, depending on which rarity you want) near the end like so:

}, 3, -2f, new Item.Properties().tab(GerbilstuffModTabs.TAB_TAB_ITEMS).fireResistant().rarity(Rarity.COMMON));

Lastly add this line at the very top of your code file.

import net.minecraft.world.item.Rarity;

Hope this works for you!

 

 

Last seen on 17:04, 13. Jan 2023
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Thanks a lot!
Wed, 12/07/2022 - 21:08

Thanks a lot!