Jump to content

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


Recommended Posts

Posted

[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 ↑↑↑↑↑↑↑↑↑↑

Posted

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

Posted

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.

Posted

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

Posted

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!

Posted

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

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

    • log: https://mclo.gs/QJg3wYX as stated in the title, my game freezes upon loading into the server after i used a far-away waystone in it. The modpack i'm using is better minecraft V18. Issue only comes up in this specific server, singleplayer and other servers are A-okay. i've already experimented with removing possible culprits like modernfix and various others to no effect. i've also attempted a full reinstall of the modpack profile. Issue occurs shortly after the 'cancel' button dissapears on the 'loading world' section of the loading screen.   thanks in advance.
    • You would have better results asking a more specific question. What have you done? What exactly do you need help with? Please also read the FAQ regarding posting logs.
    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
    • I am trying to develop a modpack for me and my friends to use on our server. Does anyone know how to develop a modpack for a server or could they help take a look at my modpack to potentially help at all?
  • Topics

×
×
  • Create New...

Important Information

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