Topic category: Feature requests and ideas for MCreator
(I tested this on NeoForge 1.20.4 by manually building the workspace myself, I don't know if it works on older Forge versions)
I know this has probably been suggested before BUT I feel like it would be incredibly easy to implement. Even I can do it with just 2 lines of code! So hear me out:
(I will refer to the mod name as "example")
So, after we put our EXAMPLE_ITEM_1 in the "Ingredients" Creative tab, this is the ExampleModTabs.JAVA file:
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ExampleModTabs {
public static final DeferredRegister<CreativeModeTab> REGISTRY = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, ExampleMod.MODID);
@SubscribeEvent
public static void buildTabContentsVanilla(BuildCreativeModeTabContentsEvent tabData) {
if (tabData.getTabKey() == CreativeModeTabs.INGREDIENTS) {
tabData.accept(ExampleModItems.EXAMPLE_ITEM_1.get());
This code puts the EXAMPLE_ITEM_1 into the first empty spot it finds in the vanilla tab "Ingredients"
Now, it is very easy to manipulate this code and make the example item go specifically AFTER or BEFORE an already existing item. (Sadly, MCreator regenerates this file very run, so you cannot manually change it.) Here's how:
@SubscribeEvent
public static void buildTabContentsVanilla(BuildCreativeModeTabContentsEvent tabData) {
if (tabData.getTabKey() == CreativeModeTabs.INGREDDIENTS) {
tabData.accept(ExampleModItems.EXAMPLE_ITEM_1.get());
}
We simply replace this "tabData.accept(ExampleModItems.EXAMPLE_ITEM_1.get());
" with: "tabData.getEntries().putAfter(Items.IRON_INGOT.getDefaultInstance(), ExampleModItems.EXAMPLE_ITEM_1.get().getDefaultInstance(), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
"
We simply use the "putAfter" event!
@SubscribeEvent
public static void buildTabContentsVanilla(BuildCreativeModeTabContentsEvent tabData) {
if(tabData.getTabKey() == CreativeModeTabs.INGREDIENTS) {
tabData.getEntries().putAfter(Items.IRON_INGOT.getDefaultInstance(), ExampleModItems.EXAMPLE_IEM_1.get().getDefaultInstance(), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
}
}
}
This simple change will put our EXAMPLE_ITEM_1 right after the Iron Ingot in the "Ingredients" tab, we can also put items before a specific item using the "putBefore" event
@SubscribeEvent
public static void buildTabContentsVanilla(BuildCreativeModeTabContentsEvent tabData) {
if(tabData.getTabKey() == CreativeModeTabs.INGREDIENTS) {
tabData.getEntries().putBefore(Items.IRON_INGOT.getDefaultInstance(), ExampleModItems.EXAMPLE_IEM_2.get().getDefaultInstance(), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
}
}
}
This will put the EXAMPLE_ITEM_2 right before the Iron Ingot in the "Ingredients" tab.
In conclusion, with only a single line of code we can change where our items are in Vanilla Creative tabs, therefore it seems really easy to implement this into MCreator. Of course, I don't know what goes on in the background of this software, but this feature would be really helpful.