Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm working on Mod which makes minecraft more Hardcore. But i figured one major problem in my mod. This problem is my custom item doesn't disappear after crafting another item with my custom item.

 

Spoiler

My ColoredItem Class


public class HColoredItem extends HItem implements IItemColor{


    private int colorIndex = 0;

    public HColoredItem(String name) {
        super(name);
        setMaxDamage(0);
        setContainerItem(this);
        setHasSubtypes(true);
        setColored(true);
    }

    public HColoredItem(String name, CreativeTabs tabs) {
        super(name, tabs);
        setMaxDamage(0);
        setContainerItem(this);
        setHasSubtypes(true);
        setColored(true);
    }


    public HColoredItem colorIndex(int index){
        this.colorIndex = index;
        return this;
    }

    @Override
    public int getMetadata(int damage)
    {
        return damage;
    }

    @Override
    public String getUnlocalizedName(ItemStack stack)
    {
        if(colorIndex == 0){
            return getUnlocalizedName() + "." + DyeColor.byMetadata(stack.getMetadata()).getUnlocalizedName();
        }else{
            return getUnlocalizedName() + "." + MaterialColor.byMetadata(stack.getMetadata()).getUnlocalizedName();
        }
    }

    @Override
    public void getSubItems(net.minecraft.creativetab.CreativeTabs tab, NonNullList<ItemStack> items) {
        if(isInCreativeTab(tab)) {
            for(int i = 0; i < (this.colorIndex == 0 ? DyeColor.values().length: MaterialColor.values().length); i++){
                ItemStack is = new ItemStack(this,1,i);
                items.add(is);
            }
        }
    }

    @Override
    public int colorMultiplier(ItemStack stack, int tintIndex) {
        if(colorIndex == 0){
            return DyeColor.byMetadata(stack.getItemDamage()).getColorValue();
        }else{
            return MaterialColor.byMetadata(stack.getItemDamage()).getColorValue();
        }
    }



}

My CustomItem Class


public class HItem extends Item {

    private boolean colored = false;
    private boolean oreDictionary = false;
    private String oreDictionaryName = "oreHmm";
    private String name = "";

    public HItem(String name){
        this(name,null);
    }

    public HItem(String name,CreativeTabs tabs){
        setName(name);
        setUnlocalizedName(name);
        setRegistryName(name);
        if ((tabs == null)) {
            setCreativeTab(HMM.TABS[0]);
        } else {
            setCreativeTab(tabs.getTab());
        }
    }

    public HItem setOreDictionary(String oreDictionaryName){
        this.oreDictionary = true;
        this.oreDictionaryName = oreDictionaryName;
        return this;
    }

    public boolean isOreDictionary() {
        return oreDictionary;
    }

    public String getOreDictionaryName() {
        return oreDictionaryName;
    }

    public void setColored(boolean colored) {
        this.colored = colored;
    }

    public boolean isColored(){
        return colored;
    }


    public String getName() {
        return name;
    }

    private void setName(String name) {
        this.name = name;
    }
}

My Recipe Json


{
  "type": "minecraft:crafting_shapeless",
  "group": "hmm:wool_piece",
  "ingredients": [
    {
      "item": "minecraft:dye",
      "data": 4
    },
    {
      "item": "hmm:wool_piece",
      "data": 0
    }
  ],
  "result": {
    "item": "hmm:wool_piece",
    "data": 11
  }
}

 

                         Before Crafting

V903DP.png 

                         After Crafting

16LGJY.png

Developing Kodev Minecraft Hardcore Mod!

If You're Wondering, My Mod Page. http://minecraft.curseforge.com/projects/minecraft-hardcore-mod

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.