This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
api:creative_tabs [2022/09/17 12:35] – created shedaniel | api: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 '' | The second argument is the icon of the new tab, which is a supplier to a '' | ||
+ | **1.20** | ||
<code java> | <code java> | ||
- | public static final CreativeModeTab MY_TAB = CreativeTabsRegistry.create(new ResourceLocation(" | + | public static final DeferredRegister< |
+ | DeferredRegister.create(" | ||
+ | |||
+ | public static final RegistrySupplier< | ||
+ | " | ||
+ | () -> CreativeTabRegistry.create( | ||
+ | Component.translatable(" | ||
+ | () -> new ItemStack(TestRegistries.TEST_ITEM.get()) // Icon | ||
+ | ) | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | **1.19.3 to 1.19.4** | ||
+ | <code java> | ||
+ | public static final CreativeTabRegistry.TabSupplier MY_TAB = CreativeTabRegistry.create( | ||
+ | new ResourceLocation(" | ||
+ | () -> new ItemStack(Items.STONE) // Icon | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | **1.19.2 or below** | ||
+ | |||
+ | <code java> | ||
+ | public static final CreativeModeTab MY_TAB = CreativeTabsRegistry.create( | ||
+ | | ||
+ | | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | ===== Using the tab ===== | ||
+ | To add an item to the tab, you can use the `tab` method in Item.Properties, | ||
+ | |||
+ | **1.19.3 or above** | ||
+ | <code java> | ||
+ | new Item.Properties().arch$tab(MY_TAB); | ||
+ | </ | ||
+ | |||
+ | **1.19.2 or below** | ||
+ | <code java> | ||
+ | new Item.Properties().tab(MY_TAB); | ||
</ | </ |