Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
api:creative_tabs [2022/09/17 12:35] – created shedanielapi:creative_tabs [2023/05/24 16:23] (current) – Add 1.20 tabs shedaniel
Line 6: Line 6:
 The second argument is the icon of the new tab, which is a supplier to a ''ItemStack'' instance. The second argument is the icon of the new tab, which is a supplier to a ''ItemStack'' instance.
  
 +**1.20**
 <code java> <code java>
-public static final CreativeModeTab MY_TAB = CreativeTabsRegistry.create(new ResourceLocation("modid", "my_tab"), () -> new ItemStack(Items.STONE));+public static final DeferredRegister<CreativeModeTab> TABS = 
 +        DeferredRegister.create("modid", Registries.CREATIVE_MODE_TAB); 
 + 
 +public static final RegistrySupplier<CreativeModeTab> MY_TAB = TABS.register( 
 +        "test_tab", // Tab ID 
 +        () -> CreativeTabRegistry.create( 
 +                Component.translatable("category.architectury_test"), // Tab Name 
 +                () -> new ItemStack(TestRegistries.TEST_ITEM.get()) // Icon 
 +        ) 
 +); 
 +</code> 
 + 
 +**1.19.3 to 1.19.4** 
 +<code java> 
 +public static final CreativeTabRegistry.TabSupplier MY_TAB = CreativeTabRegistry.create( 
 +        new ResourceLocation("modid", "test_tab"), // Tab ID 
 +        () -> new ItemStack(Items.STONE) // Icon 
 +); 
 +</code> 
 + 
 +**1.19.2 or below** 
 + 
 +<code java> 
 +public static final CreativeModeTab MY_TAB = CreativeTabsRegistry.create( 
 +        new ResourceLocation("modid", "my_tab"), // Tab ID 
 +        () -> new ItemStack(Items.STONE) // Icon 
 +); 
 +</code> 
 + 
 +===== Using the tab ===== 
 +To add an item to the tab, you can use the `tab` method in Item.Properties, since this method has been removed by Mojang in 1.19.3 in favour for a more manual setup, Architectury includes a custom `arch$tab` method for you. 
 + 
 +**1.19.3 or above** 
 +<code java> 
 +new Item.Properties().arch$tab(MY_TAB); 
 +</code> 
 + 
 +**1.19.2 or below** 
 +<code java> 
 +new Item.Properties().tab(MY_TAB);
 </code> </code>