Jump to content

ConfigOption to allow users to show certain blocks/items in custom Creat


bl4ckscor3

Recommended Posts

[move]SOLVED!

[/move]

Hi guys!  I'm making a cool mod with my friend and we both don't know how we can create a line in the config which allows the user to show certain blocks/items in our custom Creative Tab. Currently, this is our Config code:

 


    package MoreDimensions;
     
    import net.minecraftforge.common.Configuration;
    import net.minecraftforge.common.Property;
    import MoreDimensions.MoreDimensions;
     
    public class MoreDimensionsConfig
    {
            public static Configuration config = MoreDimensions.config;
            public MoreDimensions md;
            static boolean showSlimePortalInCreativeTab = true;
            static boolean showSlimeBlockDummyInCreativeTab = true;
            static boolean showMDFireInCreativeTab = true;
           
            public MoreDimensionsConfig()
            {
                    md.config.load();
                   
                    md.slimeBlockID = config.get("Block IDs", "Slime Block ID", 3000).getInt();
                    md.slimeStairsID = config.get("Block IDs", "Slime Stairs ID", 3001).getInt();
                    //md.slimeSlabID = config.get("Block IDs", "Slime Slab ID", 3002).getInt();
                    md.slimeFenceID = config.get("Block IDs", "Slime Fence ID", 3003).getInt();
                    md.slimeOreID = config.get("Block IDs", "Slime Ore ID", 3004).getInt();
                    md.slimeLampID = config.get("Block IDs", "Slime Lamp ID", 3005).getInt();
                    md.slimeLampOnID = config.get("Block IDs", "Slime Lamp_On ID", 3006).getInt();
                    md.slimeGateID = config.get("Block IDs", "Slime Gate ID", 3007).getInt();
                    md.slimePortalID = config.get("Block IDs", "Slime Portal ID", 3008).getInt();
                    md.slimeStoneID = config.get("Block IDs", "Slime Stone ID", 3009).getInt();
                    md.slimeGrassID = config.get("Block IDs", "Slime Grass ID", 3010).getInt();
                    md.slimeDirtID = config.get("Block IDs", "Slime Dirt ID", 3011).getInt();
                    md.slimeCobbleID = config.get("Block IDs", "Slime Cobble ID", 3012).getInt();
                    md.slimeBlockDummyID = config.get("Block IDs", "Slime Block Dummy ID", 3013).getInt();
                    md.slimeWoodID = config.get("Block IDs", "Slime Wood ID", 3014).getInt();
                    md.slimePlanksID = config.get("Block IDs", "Slime Planks ID", 3015).getInt();
                    md.slimeLeavesID = config.get("Block IDs", "Slime Leaves ID", 3016).getInt();
                    md.slimeSaplingID = config.get("Block IDs", "Slime Sapling ID", 3017).getInt();
                    md.moreDimFireID = config.get("Block IDs", "More Dimensions Fire ID", 3018).getInt();
                   
                    md.slimeStickID = config.get("Item IDs", "Slime Stick ID", 23000).getInt();
                    md.slimeShardID = config.get("Item IDs", "Slime Shard ID", 23001).getInt();
                    md.slimePortalPlacerID = config.get("Item IDs", "Slime Portal Placer ID", 23002).getInt();
                    md.slimeBindingID = config.get("Item IDs", "Slime Binding ID", 23003).getInt();
                    md.slimeArrowID = config.get("Item IDs", "Slime Arrow ID", 23004).getInt();
                    md.edibleSlimeID = config.get("Item IDs", "Edible Slime ID", 23005).getInt();
                   
                    md.slimePickaxeID = config.get("Tool IDs", "Slime Pickaxe ID", 24000).getInt();
                    md.slimeAxeID = config.get("Tool IDs", "Slime Axe ID", 24001).getInt();
                    md.slimeShovelID = config.get("Tool IDs", "Slime Shovel ID", 24002).getInt();
                    md.slimeSwordID = config.get("Tool IDs", "Slime Sword ID", 24003).getInt();
                    md.slimePaxelID = config.get("Tool IDs", "Slime Paxel ID", 24004).getInt();
                    md.slimeBowID = config.get("Tool IDs", "Slime Bow ID", 24005).getInt();
                    md.moreDimFASID = config.get("Tool IDs", "Flint and Steel (More Dimensions) ID", 24006).getInt();
                   
                    showSlimePortalInCreativeTab = config.get("Show in Creative Tab", "Slime Portal", false).getBoolean(false);
                    showSlimeBlockDummyInCreativeTab = config.get("Show in Creative Tab", "Slime Block Dummy", false).getBoolean(false);
                    showMDFireInCreativeTab = config.get("Show in Creative Tab", "More Dimensions' Fire", false).getBoolean(false);
                   
                    //Show Portal in CreativeTab
                    if(showSlimePortalInCreativeTab)
                    {
                            md.slimePortal.setCreativeTab(md.moreDimensions);
                    }
                   
                    //Show Slime Block Dummy in CreativeTab
                    if(showSlimeBlockDummyInCreativeTab)
                    {
                            md.slimeBlockDummy.setCreativeTab(md.moreDimensions);
                    }
                   
                    //Show MD Fire in CreativeTab
                    if(showMDFireInCreativeTab)
                    {
                            md.moreDimFire.setCreativeTab(md.moreDimensions);
                    }
     
                    md.config.save();
            }
    }

 

This code is from the @PreInit method in our main class:

 

	@PreInit
public void preInit(FMLPreInitializationEvent event)
{
	//item ids fangen bei 23000 an, tool ids bei 24000 und block ids bei 3000
	config = new Configuration(event.getSuggestedConfigurationFile());
	new MoreDimensionsConfig();
}

 

 

But the code, in this case I, wrote doesn't work. Could you help us out with this, please?

 

Thanks in advance

~bl4ckscor3

↑↑↑↑↑↑↑↑↑↑ Click it please? :3 ↑↑↑↑↑↑↑↑↑↑

Link to comment
Share on other sites

What doesn't work about it?

 

BTW, you might try instead overriding getSubBlocks()/getSubItems() in your block and item files.

When I change the Config option to true, the block/item doesn't show up. And what are thoe getSubBlocks()/getSubItems() methods you are speaking of? Why do I need them?

↑↑↑↑↑↑↑↑↑↑ Click it please? :3 ↑↑↑↑↑↑↑↑↑↑

Link to comment
Share on other sites

What doesn't work about it?

 

BTW, you might try instead overriding getSubBlocks()/getSubItems() in your block and item files.

When I change the Config option to true, the block/item doesn't show up. And what are thoe getSubBlocks()/getSubItems() methods you are speaking of? Why do I need them?

They are meant for blocks that differentiate between metadata (and show multiple blocks in the creative tabs), but, if you use it to return an empty list, it will show nothing in the creative tabs, not even in the "all items" tab. Which, I assume, you would want.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

What doesn't work about it?

 

BTW, you might try instead overriding getSubBlocks()/getSubItems() in your block and item files.

When I change the Config option to true, the block/item doesn't show up. And what are thoe getSubBlocks()/getSubItems() methods you are speaking of? Why do I need them?

They are meant for blocks that differentiate between metadata (and show multiple blocks in the creative tabs), but, if you use it to return an empty list, it will show nothing in the creative tabs, not even in the "all items" tab. Which, I assume, you would want.

Hm. Basically I want to have a config option where the user can choose wether he wants the e.g. Slime Portal in the More Dimensions Creative Tab or not.

↑↑↑↑↑↑↑↑↑↑ Click it please? :3 ↑↑↑↑↑↑↑↑↑↑

Link to comment
Share on other sites

OK, I know how set up this.

Simply add to main mod file (the core) this:

public static Boolean[] par0Boolean = new Boolean[2];

and this you need to write into the config load:

par0Boolean[1] = config.get("GROUP","NAME", defaultBolean).getBoolean(true);

And for the setting the visibility of block/item you can use my API for this:

 

    public static void regTab(Block par1Block, CreativeTabs par2Tab, Boolean par3Boolean)

    {

    if(par3Boolean == true)

    {

    par1Block.setCreativeTab(par2Tab);

    }

    }

    public static void regTab(Item par1Item, CreativeTabs par2Tab, Boolean par3Boolean)

    {

    if(par3Boolean == true)

    {

    par1Item.setCreativeTab(par2Tab);

    }

    }

 

 

in the main file you need to add regTab(item(or block unlocalizedName),your creative tab,par0Boolean[1]);

example:  regTab(mixed_dust,tabOmega,par0Boolean[1]);

It works for me fine.

 

//EDIT

if you want the api I can send the file to you  :)

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Link to comment
Share on other sites

OK, I know how set up this.

Simply add to main mod file (the core) this:

public static Boolean[] par0Boolean = new Boolean[2];

and this you need to write into the config load:

par0Boolean[1] = config.get("GROUP","NAME", defaultBolean).getBoolean(true);

And for the setting the visibility of block/item you can use my API for this:

 

    public static void regTab(Block par1Block, CreativeTabs par2Tab, Boolean par3Boolean)

    {

    if(par3Boolean == true)

    {

    par1Block.setCreativeTab(par2Tab);

    }

    }

    public static void regTab(Item par1Item, CreativeTabs par2Tab, Boolean par3Boolean)

    {

    if(par3Boolean == true)

    {

    par1Item.setCreativeTab(par2Tab);

    }

    }

 

 

in the main file you need to add regTab(item(or block unlocalizedName),your creative tab,par0Boolean[1]);

example:  regTab(mixed_dust,tabOmega,par0Boolean[1]);

It works for me fine.

 

//EDIT

if you want the api I can send the file to you  :)

Thank you SO much :) That helped :) Oh, and could you send me the API please? I'm pretty interested in it.

↑↑↑↑↑↑↑↑↑↑ Click it please? :3 ↑↑↑↑↑↑↑↑↑↑

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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