Jump to content

Custom ID's for blocks and items


Khrouhman

Recommended Posts

 

Hello I am new to mod making but I made a few items and want to organize them in my creative tab. I want to be able to set the id's for items, specifically the sword because they are not next to each other in the creative tab. Is there anyway to edit the creative tabs or do I have to just make the swords in order.

I inserted the code for my custom swords and I was wondering if there was a way to put the ID in a constructor so I could set it while making a new sword?

thanks in advance

 

Spoiler

package com.romods.mod1.items.tools;

import com.romods.mod1.Main;
import com.romods.mod1.init.ModItems;
import com.romods.mod1.init.ModTabs;
import com.romods.mod1.util.IHasModel;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;

public class CustomSword extends ItemSword implements IHasModel {
    
    //makes item look enchanted
    boolean shiny = false;
    Item ID;

    public CustomSword(String name, ToolMaterial material, boolean shiny1) 
    {
        super(material);
        
        this.setRegistryName(name);
        this.setUnlocalizedName(name);
        this.setCreativeTab(ModTabs.R_ITEMS);
        //this.setID(4200);

        ModItems.ITEMS.add(this);
        
        shiny = shiny1;
    }
    
    public boolean hasEffect(ItemStack par1ItemStack)
    {
            return shiny;
    }

    @Override
    public void registerModels() 
    {
        Main.proxy.registerItemRenderer(this, 0, "inventory");
    }

}

for example can i set these swords to be 4200 and 4201 instead of 4102 and 4104

 

 

Link to comment
Share on other sites

 

32 minutes ago, diesieben07 said:

Numerical IDs are effectively random and can change.

To sort your creative tab, override ItemGroup#fill, call super and the sort the list however you want.

Hi I'm not sure how to do an override. I am modding for minecraft 1.12.2 if that makes a difference. Is there any way I could get an example or a walkthrough on how to call super and sort the list?

Edited by Khrouhman
Link to comment
Share on other sites

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.