Jump to content

[1.17]Creating Custom Rarity


ocome

Recommended Posts

Based on this Minecraft rarity, I'm going to create my own rarity.

 

Rarity.java

package net.minecraft.world.item;

import net.minecraft.ChatFormatting;

public enum Rarity implements net.minecraftforge.common.IExtensibleEnum {
   COMMON(ChatFormatting.WHITE),
   UNCOMMON(ChatFormatting.YELLOW),
   RARE(ChatFormatting.AQUA),
   EPIC(ChatFormatting.LIGHT_PURPLE);

   public final ChatFormatting color;

   private Rarity(ChatFormatting p_43028_) {
      this.color = p_43028_;
   }

   public static Rarity create(String name, ChatFormatting p_43028_) {
      throw new IllegalStateException("Enum not extended");
   }
}

 

However, after creating it, when I tried to give it to the item, it came up with a problem

NijiRarity.java

package com.ocome.nijisanjiworld.item.tool;

import net.minecraft.ChatFormatting;
import net.minecraftforge.common.IExtensibleEnum;

public enum NijiRarity implements IExtensibleEnum {
    COMMON(ChatFormatting.AQUA),
    UNCOMMON(ChatFormatting.YELLOW),
    RARE(ChatFormatting.AQUA),
    EPIC(ChatFormatting.LIGHT_PURPLE);

    public final ChatFormatting color;

    private NijiRarity(ChatFormatting p_43028_) {
        this.color = p_43028_;
    }

    public static NijiRarity create(String name, ChatFormatting p_43028_) {
        throw new IllegalStateException("Enum not extended");
    }
}

 

The problem is.

Error: Incompatible type: Cannot convert NijiRarity to Rarity:

This is it.

Why is it not applicable?

 

public class Item_Custom_Pickaxe extends PickaxeItem {
    public Item_Custom_Pickaxe() {
        super(NijiTiers.OCOME, 1, -2.4F, new Properties().tab(OcomeNiji.OCOMEMOD_TAB).rarity(NijiRarity.EPIC));
      											  =======Error======
    }
}

I added it this way with a pickaxe.

please help me :(

 

Link to comment
Share on other sites

  • 4 months later...

You need to use a normal class and the create function in Rarity.java like this:

public static final Rarity RARITY_NAME = Rarity.create("rarity_name", ChatFormatting.COLOR);

and if you want you can add

"rarity.rarity_name.name": "Rarity Name"

to your language file to make your rarity compatible with my rarity tooltip system, but this would only make sense when you're using 1.18.1 and please do what @diesieben07said and learn basic Java before you try making your own mod and if you don't want to learn basic Java but still want to make your own mod try using MCreator even tho you don't have any rights to your mod if you use MCreator.

Edited by Leon Henning
Link to comment
Share on other sites

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.