Item Rarity Tutorial

Started by rjc22222 on

Topic category: User side tutorials

Last seen on 21:54, 7. Apr 2021
Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Item Rarity Tutorial

Rarities in minecraft change the color of item names, and there are four rarities: Common, Uncommon, Rare, and Epic

This tutorial will help you make items with rarities, and even create your own rarities!

 

Making Items with Rarities

In order to give your item a custom rarity, you must put in the following code into the Item class in the code.

public EnumRarity getRarity(ItemStack stack)

{
          return EnumRarity.Rarity
}

where Rarity is the rarity you want.

You will have to put the code in with the item classifying functions for most items.

For most tools, you have to put the code in with the "getToolClasses" function.

Axes have classifications more like normal items.

For armor, you have to put "{}" brackets after the part where the armor piece is classified (where it says "new ItemArmor(enuma, 0, EntityEquipmentSlot.(Text does not matter here, it could be anything)" and you put the rarity code into the brackets.

You'll have to reformat your code and imports.

You can put an if statement in it to make it to where the item can have a different rarity when enchanted, has a meta value, or anything really.

 

Making Custom Rarities

In order to make your own custom rarities, you have to create a new class.

When you create a class, you should see this code in it:

public class (Class name here){

}

(Class name here) is the class name.

In the code, you can put the following code in there

public static EnumRarity RARITY_NAME = EnumHelper.addRarity("RARITY_NAME", TextFormatting.COLOR, "display name")

where "RARITY_NAME" is the code name of your rarity, "COLOR" is the color of your rarity (Choose a color in the TextFormatting class), and "display name" is the display name of your rarity.

Don't forget to reformat your code and imports!

To use your custom Rarity, follow the instructions for making items with rarities, but use replace "return EnumRarity" with "return (Class name here)" and use a custom rarity.

 

 

Last seen on 09:43, 4. Jan 2022
Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
what code should I change…
Sat, 02/23/2019 - 08:07

what code should I change for Tools? I want a sword with a rarity

Last seen on 19:28, 26. May 2021
Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you make a video…
Sat, 02/23/2019 - 11:35

Can you make a video tutorial ? x) or add image because i don't understand anything xD

Last seen on 21:54, 7. Apr 2021
Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Item Code, where the return…
Sat, 02/23/2019 - 12:43

Item Code (The rarity code is in the class that extends Item)

Item Code, where the return statement can be what you want, defined in an item class.

 

Tool code (The rarity code is in with the getToolClasses function)Sword/Pickaxe/Shovel/Hoe Code, where the return statement can be what you want, defined in a tool class that is not an axe.

 

Axe code (The rarity code is in the class that extends ItemTool)

Axe code, where once again, the return code can be what you want, defined in a tool class that is an axe.

Armor code (The rarity code is in brackets after the ItemArmor class things)

Armor code, where the return statements can be whatever you want, defined in an armor class.

Custom Rarity (An EnumRarity thing equals a rarity added by EnumHelper)

Custom Rarity Code, where the rarity is defined in a custom class.

 

Hope this is allowed and helps!

Last seen on 09:43, 4. Jan 2022
Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
why it don't work for my tool
Sat, 02/23/2019 - 14:29

why it don't work for my tool

Last seen on 21:54, 7. Apr 2021
Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
did you reformat the imports…
Sat, 02/23/2019 - 16:14

did you reformat the imports?

 

Last seen on 19:28, 26. May 2021
Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks Its Working ! :P
Sat, 02/23/2019 - 17:19

Thanks Its Working ! :P

Last seen on 09:43, 4. Jan 2022
Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I don't know how to reformat…
Sat, 02/23/2019 - 17:22

I don't know how to reformat the import, and you explain me from A to Z? what I must change, what I must add, where I must add

Last seen on 21:54, 7. Apr 2021
Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Press the button that says …
Sat, 02/23/2019 - 20:21

Press the button that says "Reformat the code and imports" in the code tab with the item code open, and the imports will be reformatted. But if there is a weird difference between the mcreator i use and the mcreator you use, then search up any missing symbols in the search tab and create an import code thing at the top.

Import for EnumRarity:

import net.minecraft.item.EnumRarity;

where net.minecraft is the minecraft source code folder, and net.minecraftforge is the minecraft forge source code folder.

Last seen on 21:54, 7. Apr 2021
Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok, so to add rarities to…
Sun, 02/24/2019 - 04:46

Ok, so to add rarities to items, you have to put a "getRarity" function from the codes above into the proper place, as seen above for tools, items, and armors.

The return statement in the function is where you define the rarity. You put something like "return EnumRarity.EPIC" for vanilla rarities.

To make custom rarities, you have to make a class and define custom rarities by typing something like

'public static EnumRarity CUSTOM_RARITY = EnumHelper.addRarity("CUSTOM_RARITY", TextFormatting.COLOR, "Custom Rarity")'

In order to apply custom rarities, use the same code for vanilla rarities, but in the return statement, replace "EnumRarity" with the name of your custom rarity class.

Hope this helps, i didn't get the idea that i had to write a summary of it, for some reason.

Last seen on 17:49, 25. Mar 2021
Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I didn't even know the color…
Sun, 02/24/2019 - 07:52

I didn't even know the color of the items is the their rarity...

Last seen on 09:43, 4. Jan 2022
Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
well me too
Sun, 02/24/2019 - 09:10

well me too

Last seen on 09:43, 4. Jan 2022
Joined May 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think that Rarities are 1…
Sun, 02/24/2019 - 11:13

I think that Rarities are 1.13.2 only? because I don't see any item with a Rarity color EXCEPT Enchant items in blue name in 1.12.2