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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • WHO CAN HELP ME GET MY BITC0IN BACK WITH MIGHTY HACKER REC0VERY AND HIRE THE BEST HACKER FOR ALL HACKER SERVICES AT MIGHTY HACKER RECOVERY I can't believe the turn of events that led me to reclaiming my lost Bitc0in! A few months ago, I fell victim to a phishing scam and lost a significant amount of money. I was devastated and hopeless, believing I'd never see my money again. After some research, I came across Mighty Hacker Rec0very. Skeptical but desperate, I decided to contact them. I began chatting with one of their hackers and was immediately impressed by their expertise and professionalism. They patiently walked me through the recovery process, reassuring me along the way. They worked diligently on my case for several weeks, using their expertise to locate my lost funds. It was intense, but I felt optimistic for the first time since the scam. The communication was clear, and I received regular updates, which reduced my anxiety. Finally, I received the news that my Bitc0in had been successfully recovered! I couldn't believe it—I was ecstatic! I'm extremely grateful to the hacker who assisted me. Mighty Hacker Rec0very transformed a nightmare into a triumph, and I'm grateful beyond words. If anyone is in a similar situation, I highly recommend contacting them! WH@TS@PP: +1 8  45 6 99 50  44 EM@IL: support @ mightyhackerrecovery . com FB: mighty hacker recovery
    • A friend found this code, but I don't know where. It seems to be very outdated, maybe from 1.12? and so uses TextureManager$loadTexture and TextureManager$deleteTexture which both don't seem to exist anymore. It also uses Minecraft.getMinecraft().mcDataDir.getCanonicalPath() which I replaced with the resource location of my texture .getPath()? Not sure if thats entirely correct. String textureName = "entitytest.png"; File textureFile = null; try { textureFile = new File(Minecraft.getMinecraft().mcDataDir.getCanonicalPath(), textureName); } catch (Exception ex) { } if (textureFile != null && textureFile.exists()) { ResourceLocation MODEL_TEXTURE = Resources.OTHER_TESTMODEL_CUSTOM; TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); texturemanager.deleteTexture(MODEL_TEXTURE); Object object = new ThreadDownloadImageData(textureFile, null, MODEL_TEXTURE, new ImageBufferDownload()); texturemanager.loadTexture(MODEL_TEXTURE, (ITextureObject)object); return true; } else { return false; }   Then I've been trying to go through the source code of the reload resource packs from minecraft, to see if I can "cache" some data and simply reload some textures and swap them out, but I can't seem to figure out where exactly its "loading" the texture files and such. Minecraft$reloadResourcePacks(bool) seems to be mainly controlling the loading screen, and using this.resourcePackRepository.reload(); which is PackRepository$reload(), but that function seems to be using this absolute confusion of a line List<String> list = this.selected.stream().map(Pack::getId).collect(ImmutableList.toImmutableList()); and then this.discoverAvailable() and this.rebuildSelected. The rebuild selected seemed promising, but it seems to just be going through each pack and doing this to them? pack.getDefaultPosition().insert(list, pack, Functions.identity(), false); e.g. putting them into a list of packs and returning that into this.selected? Where do the textures actually get baked/loaded/whatever? Any info on how Minecraft reloads resource packs or how the texture manager works would be appreciated!
    • This might be a long shot , but do you remember how you fixed that?
    • Yeah, I'll start with the ones I added last night.  Wasn't crashing until today and wasn't crashing at all yesterday (+past few days since removing Cupboard), so deductive reasoning says it's likeliest to be one of the new ones.  A few horse armor mods and a corn-based add-on to Farmer's Delight, the latter which I hope to keep - I could do without the horse armor mods if necessary.  Let me try a few things and we'll see. 
  • Topics

×
×
  • Create New...

Important Information

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