goldodemon/most / ExampleMod.json
goldodemon's picture
download
raw
2.85 kB
{
"path": "Minecraft/mc-Data/ExampleMod.java",
"original_extension": "java",
"content": "package com.example.examplemod;\n\nimport net.fabricmc.api.ModInitializer;\nimport net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;\nimport net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;\nimport net.minecraft.block.Block;\nimport net.minecraft.block.AbstractBlock;\nimport net.minecraft.item.Item;\nimport net.minecraft.item.ItemGroups;\nimport net.minecraft.item.ItemStack;\nimport net.minecraft.registry.Registries;\nimport net.minecraft.registry.Registry;\nimport net.minecraft.registry.RegistryKey;\nimport net.minecraft.registry.RegistryKeys;\nimport net.minecraft.util.Identifier;\n\n/**\n * Entry point. Registered in fabric.mod.json under \"entrypoints\" -> \"main\".\n * Works unchanged across 1.21.7 - 1.21.11; registry/item APIs have been\n * stable through this range.\n */\npublic class ExampleMod implements ModInitializer {\n\n public static final String MOD_ID = \"examplemod\";\n\n // --- Item registration (key-first pattern, current best practice) ---\n public static final Item EXAMPLE_GEM = registerItem(\n \"example_gem\",\n settings -> new Item(settings)\n );\n\n // --- Block registration ---\n public static final Block EXAMPLE_BLOCK = registerBlock(\n \"example_block\",\n settings -> new Block(settings),\n AbstractBlock.Settings.create().strength(4.0f).requiresTool()\n );\n\n @Override\n public void onInitialize() {\n // Add our gem to the \"ingredients\" creative tab\n ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(entries ->\n entries.add(EXAMPLE_GEM)\n );\n\n // Add a BlockItem for our block so it shows up in the building blocks tab\n ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(entries ->\n entries.add(new ItemStack(EXAMPLE_BLOCK))\n );\n }\n\n private static Item registerItem(String path, java.util.function.Function<Item.Settings, Item> factory) {\n RegistryKey<Item> key = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(MOD_ID, path));\n Item item = factory.apply(new Item.Settings().registryKey(key));\n return Registry.register(Registries.ITEM, key, item);\n }\n\n private static Block registerBlock(String path,\n java.util.function.Function<AbstractBlock.Settings, Block> factory,\n AbstractBlock.Settings settings) {\n RegistryKey<Block> key = RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(MOD_ID, path));\n Block block = factory.apply(settings.registryKey(key));\n return Registry.register(Registries.BLOCK, key, block);\n }\n}\n"
}

Xet Storage Details

Size:
2.85 kB
·
Xet hash:
d6c7e998f1fbbc5ef02ebc315321307e02e46e1388d1da61d5e3982c08c7fa6b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.