Jump to content

[SOLVED][1.19.4] How to order/place mod tabs inside the inventory?


Recommended Posts

Posted (edited)

In my mod I add several new creative tabs, and I want them to be displayed in a specific order. Specifically, I register these tabs inside the CreativeModeTabEvent.Register event

@SubscribeEvent
public static void register(CreativeModeTabEvent.Register event) {
  BUILDING_BLOCKS = registerTab(event, "building_blocks", () -> new ItemStack(BLBlocks.RUBY_BLOCK.get()));
  COLORED_BLOCKS = registerTab(event, "colored_blocks", () -> new ItemStack(BLBlocks.YELLOW_CONCRETE_STAIRS.get()));
  NATURAL = registerTab(event, "natural", () -> new ItemStack(BLBlocks.HOLLOW_BIRCH_LOG.get()));
  FUNCTIONAL = registerTab(event, "functional", () -> new ItemStack(Items.PAINTING));
  REDSTONE = registerTab(event, "redstone", () -> new ItemStack(BLBlocks.COPPER_BUTTON.get()));
  TOOLS = registerTab(event, "tools", () -> new ItemStack(BLItems.EMERALD_PICKAXE.get()));
  COMBAT = registerTab(event, "combat", () -> new ItemStack(BLItems.KATANA.get()));
  FOOD_AND_DRINK = registerTab(event, "food_and_drink", () -> new ItemStack(BLItems.SASHIMI.get()));
  INGREDIENTS = registerTab(event, "ingredients", () -> new ItemStack(BLItems.RUBY.get()));
  SPAWN_EGGS = registerTab(event, "spawn_eggs", () -> new ItemStack(BLItems.COPPER_GOLEM_SPAWN_EGG.get()));
}

private static CreativeModeTab registerTab(CreativeModeTabEvent.Register event, String name, Supplier<ItemStack> iconSupplier) {
  return event.registerCreativeModeTab(new ResourceLocation(BlazersMod.MOD_ID, name),
                                       builder -> builder
                                       .icon(iconSupplier)
                                       .title(Component.translatable("itemGroup." + BlazersMod.MOD_ID + "." + name))
                                       .build());
}

and I thought they were displayed in this order, so the first mod tab would be building blocks, the next would be colored blocks etc...
However when I load the game they are misplaced. Specifically the first tab I see is the mod's spawn eggs tab, which is the last one registered, than the mod's ingredients tab and then the tools tabs, so isn't in the reverse registration order. If I intercept the CreativeModeTabEvent.BuildContents event to see when those tabs are populated I get the same wrong ordering, so it makes sense that in game they are ordered like this. Do I need to specify something to make them ordered in the same order as they are registered?

Edited by JimiIT92
solved

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • JimiIT92 changed the title to [SOLVED][1.19.4] How to order/place mod tabs inside the inventory?
Posted

Sure, the only difference is that I'm now passing the previous tab to the method I use to register all my tabs. So now I have this
 

BUILDING_BLOCKS = registerTab(event, "building_blocks", CreativeModeTabs.SPAWN_EGGS, () -> new ItemStack(BLBlocks.RUBY_BLOCK.get()));
COLORED_BLOCKS = registerTab(event, "colored_blocks", BUILDING_BLOCKS,()  -> new ItemStack(BLBlocks.YELLOW_CONCRETE_STAIRS.get()));
NATURAL = registerTab(event, "natural", COLORED_BLOCKS, () -> new ItemStack(BLBlocks.HOLLOW_BIRCH_LOG.get()));
FUNCTIONAL = registerTab(event, "functional", NATURAL, () -> new ItemStack(Items.PAINTING));
REDSTONE = registerTab(event, "redstone", FUNCTIONAL, () -> new ItemStack(BLBlocks.COPPER_BUTTON.get()));
TOOLS = registerTab(event, "tools", REDSTONE, () -> new ItemStack(BLItems.EMERALD_PICKAXE.get()));
COMBAT = registerTab(event, "combat", TOOLS, () -> new ItemStack(BLItems.KATANA.get()));
FOOD_AND_DRINK = registerTab(event, "food_and_drink", COMBAT, () -> new ItemStack(BLItems.SASHIMI.get()));
INGREDIENTS = registerTab(event, "ingredients", FOOD_AND_DRINK, () -> new ItemStack(BLItems.RUBY.get()));
SPAWN_EGGS = registerTab(event, "spawn_eggs", INGREDIENTS, () -> new ItemStack(BLItems.COPPER_GOLEM_SPAWN_EGG.get()));

where I pass the previous tab to all the registerTab methods.
So my register tab method now simply adds the provided the tab to the "afterTab" list parameter provided to the registerCreativeModeTab function

private static CreativeModeTab registerTab(CreativeModeTabEvent.Register event, String name, CreativeModeTab afterTab, Supplier<ItemStack> iconSupplier) {
  return event.registerCreativeModeTab(new ResourceLocation(BlazersMod.MOD_ID, name),
                                       List.of(),
                                       List.of(afterTab),
                                       builder -> builder
                                       .icon(iconSupplier)
                                       .title(Component.translatable("itemGroup." + BlazersMod.MOD_ID + "." + name))
                                       .build());
}

It would be cool if the ordering was automatic like it was before, but I guess is not the end of the world to provide an extra parameter 😅

Don't blame me if i always ask for your help. I just want to learn to be better :)

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

    • UPDATE: this seems to be an Arch-specific issue. Switching to Ubuntu server fixed EVERYTHING.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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