@@ -71,10 +71,12 @@ public static void registerCreativeTabs() {
71
71
// FIXME: this is a hack because creative tabs must be registered on startup but item stacks normally can't be
72
72
// parsed until the world is loaded. Use the default registries for now, as most things in item stacks aren't
73
73
// in dynamic registries yet. Fix this once creative tabs can be registered dynamically.
74
- var holderLookupProvider = new RegistryAccess .ImmutableRegistryAccess (BuiltInRegistries .REGISTRY .stream ().toList ());
74
+ // This only affects the icon of the creative tab and the contents, which is lazily populated and has access to
75
+ // the dynamic registries.
76
+ var builtinLookupProvider = new RegistryAccess .ImmutableRegistryAccess (BuiltInRegistries .REGISTRY .stream ().toList ());
75
77
tabs .forEach ((key , tab ) -> {
76
78
try {
77
- tab .registerCreativeTab (holderLookupProvider , key );
79
+ tab .registerCreativeTab (builtinLookupProvider , key );
78
80
} catch (Throwable e ) {
79
81
LOGGER .error ("Could not load tab {}" , key , e );
80
82
}
@@ -323,14 +325,14 @@ private static ItemStack singleItemFromNbt(HolderLookup.Provider holderLookupPro
323
325
}
324
326
325
327
private record Tab (CompoundTag icon , ListTag items ) {
326
- void registerCreativeTab (HolderLookup .Provider holderLookupProvider , String key ) {
328
+ void registerCreativeTab (HolderLookup .Provider builtinLookupProvider , String key ) {
327
329
Registry .register (BuiltInRegistries .CREATIVE_MODE_TAB , ResourceLocation .fromNamespaceAndPath ("clientcommands" , key ), FabricItemGroup .builder ()
328
330
.title (Component .literal (key ))
329
- .icon (() -> singleItemFromNbt (holderLookupProvider , icon ))
331
+ .icon (() -> singleItemFromNbt (builtinLookupProvider , icon ))
330
332
.displayItems ((displayContext , entries ) -> {
331
333
Set <ItemStack > existingStacks = ItemStackLinkedSet .createTypeAndComponentsSet ();
332
334
for (int i = 0 ; i < items .size (); i ++) {
333
- ItemStack stack = singleItemFromNbt (holderLookupProvider , items .getCompound (i ));
335
+ ItemStack stack = singleItemFromNbt (displayContext . holders () , items .getCompound (i ));
334
336
if (stack .isEmpty ()) {
335
337
continue ;
336
338
}
0 commit comments