diff options
Diffstat (limited to 'src/main/java/com/example/examplemod/ExampleMod.java')
| -rw-r--r-- | src/main/java/com/example/examplemod/ExampleMod.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/main/java/com/example/examplemod/ExampleMod.java b/src/main/java/com/example/examplemod/ExampleMod.java index f6a02a8..e967e83 100644 --- a/src/main/java/com/example/examplemod/ExampleMod.java +++ b/src/main/java/com/example/examplemod/ExampleMod.java @@ -2,6 +2,7 @@ package com.example.examplemod; import com.mojang.logging.LogUtils; import net.minecraft.client.Minecraft; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.BlockItem; @@ -20,13 +21,13 @@ import net.neoforged.fml.common.Mod; import net.neoforged.fml.config.ModConfig; import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; -import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; import net.neoforged.neoforge.event.server.ServerStartingEvent; +import net.neoforged.neoforge.registries.DeferredBlock; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredRegister; -import net.neoforged.neoforge.registries.ForgeRegistries; -import net.neoforged.neoforge.registries.RegistryObject; import org.slf4j.Logger; // The value here should match an entry in the META-INF/mods.toml file @@ -38,23 +39,23 @@ public class ExampleMod // Directly reference a slf4j logger private static final Logger LOGGER = LogUtils.getLogger(); // Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace - public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); + public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID); // Create a Deferred Register to hold Items which will all be registered under the "examplemod" namespace - public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); + public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(MODID); // Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "examplemod" namespace public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID); // Creates a new Block with the id "examplemod:example_block", combining the namespace and path - public static final RegistryObject<Block> EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE))); + public static final DeferredBlock<Block> EXAMPLE_BLOCK = BLOCKS.registerBlock("example_block", BlockBehaviour.Properties.of().mapColor(MapColor.STONE)); // Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path - public static final RegistryObject<Item> EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties())); + public static final DeferredItem<BlockItem> EXAMPLE_BLOCK_ITEM = ITEMS.registerBlockItem("example_block", EXAMPLE_BLOCK); // Creates a new food item with the id "examplemod:example_id", nutrition 1 and saturation 2 - public static final RegistryObject<Item> EXAMPLE_ITEM = ITEMS.register("example_item", () -> new Item(new Item.Properties().food(new FoodProperties.Builder() - .alwaysEat().nutrition(1).saturationMod(2f).build()))); + public static final DeferredItem<Item> EXAMPLE_ITEM = ITEMS.registerItem("example_item", new Item.Properties().food(new FoodProperties.Builder() + .alwaysEat().nutrition(1).saturationMod(2f).build())); // Creates a creative tab with the id "examplemod:example_tab" for the example item, that is placed after the combat tab - public static final RegistryObject<CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder() + public static final DeferredHolder<CreativeModeTab, CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder() .withTabsBefore(CreativeModeTabs.COMBAT) .icon(() -> EXAMPLE_ITEM.get().getDefaultInstance()) .displayItems((parameters, output) -> { @@ -91,7 +92,7 @@ public class ExampleMod LOGGER.info("HELLO FROM COMMON SETUP"); if (Config.logDirtBlock) - LOGGER.info("DIRT BLOCK >> {}", ForgeRegistries.BLOCKS.getKey(Blocks.DIRT)); + LOGGER.info("DIRT BLOCK >> {}", BuiltInRegistries.BLOCK.getKey(Blocks.DIRT)); LOGGER.info(Config.magicNumberIntroduction + Config.magicNumber); |
