Last active
July 15, 2025 22:43
-
-
Save TelepathicGrunt/1a02321a884bec90eaca9f9815a98751 to your computer and use it in GitHub Desktop.
Fabric classload register
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Mod implements ModInitializer { | |
public static final String MODID = "mod"; | |
@Override | |
public void onInitialize() { | |
ModItems.initItems(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ModItems { | |
public static void initItems() {} | |
public static Item ITEM_A = RegisterItem("item_a", (key) -> new Item(new Item.Properties().setId(key))); | |
public static Item ITEM_B = RegisterItem("item_b", (key) -> new Item(new Item.Properties().setId(key))); | |
private static Item RegisterItem(String itemName, Function<ResourceKey<Item>, Item> itemSupplier) { | |
ResourceKey<Item> itemResourceKey = ResourceKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(MODID, itemName)); | |
return Registry.register(Registries.ITEM, itemResourceKey.location(), itemSupplier.apply(itemResourceKey)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment