2
2
3
3
import com .mojang .logging .LogUtils ;
4
4
import net .minecraft .client .Minecraft ;
5
+ import net .minecraft .core .registries .BuiltInRegistries ;
5
6
import net .minecraft .core .registries .Registries ;
6
7
import net .minecraft .world .food .FoodProperties ;
7
8
import net .minecraft .world .item .BlockItem ;
20
21
import net .neoforged .fml .config .ModConfig ;
21
22
import net .neoforged .fml .event .lifecycle .FMLClientSetupEvent ;
22
23
import net .neoforged .fml .event .lifecycle .FMLCommonSetupEvent ;
23
- import net .neoforged .fml .javafmlmod .FMLJavaModLoadingContext ;
24
24
import net .neoforged .neoforge .common .NeoForge ;
25
25
import net .neoforged .neoforge .event .BuildCreativeModeTabContentsEvent ;
26
26
import net .neoforged .neoforge .event .server .ServerStartingEvent ;
27
+ import net .neoforged .neoforge .registries .DeferredBlock ;
28
+ import net .neoforged .neoforge .registries .DeferredHolder ;
29
+ import net .neoforged .neoforge .registries .DeferredItem ;
27
30
import net .neoforged .neoforge .registries .DeferredRegister ;
28
- import net .neoforged .neoforge .registries .ForgeRegistries ;
29
- import net .neoforged .neoforge .registries .RegistryObject ;
30
31
import org .slf4j .Logger ;
31
32
32
33
// The value here should match an entry in the META-INF/mods.toml file
@@ -38,23 +39,23 @@ public class ExampleMod
38
39
// Directly reference a slf4j logger
39
40
private static final Logger LOGGER = LogUtils .getLogger ();
40
41
// Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace
41
- public static final DeferredRegister < Block > BLOCKS = DeferredRegister .create ( ForgeRegistries . BLOCKS , MODID );
42
+ public static final DeferredRegister . Blocks BLOCKS = DeferredRegister .createBlocks ( MODID );
42
43
// Create a Deferred Register to hold Items which will all be registered under the "examplemod" namespace
43
- public static final DeferredRegister < Item > ITEMS = DeferredRegister .create ( ForgeRegistries . ITEMS , MODID );
44
+ public static final DeferredRegister . Items ITEMS = DeferredRegister .createItems ( MODID );
44
45
// Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "examplemod" namespace
45
46
public static final DeferredRegister <CreativeModeTab > CREATIVE_MODE_TABS = DeferredRegister .create (Registries .CREATIVE_MODE_TAB , MODID );
46
47
47
48
// Creates a new Block with the id "examplemod:example_block", combining the namespace and path
48
- public static final RegistryObject <Block > EXAMPLE_BLOCK = BLOCKS .register ("example_block" , () -> new Block ( BlockBehaviour .Properties .of ().mapColor (MapColor .STONE ) ));
49
+ public static final DeferredBlock <Block > EXAMPLE_BLOCK = BLOCKS .registerBlock ("example_block" , BlockBehaviour .Properties .of ().mapColor (MapColor .STONE ));
49
50
// Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path
50
- public static final RegistryObject < Item > EXAMPLE_BLOCK_ITEM = ITEMS .register ("example_block" , () -> new BlockItem ( EXAMPLE_BLOCK . get (), new Item . Properties ()) );
51
+ public static final DeferredItem < BlockItem > EXAMPLE_BLOCK_ITEM = ITEMS .registerBlockItem ("example_block" , EXAMPLE_BLOCK );
51
52
52
53
// Creates a new food item with the id "examplemod:example_id", nutrition 1 and saturation 2
53
- public static final RegistryObject <Item > EXAMPLE_ITEM = ITEMS .register ("example_item" , () -> new Item ( new Item .Properties ().food (new FoodProperties .Builder ()
54
- .alwaysEat ().nutrition (1 ).saturationMod (2f ).build ()))) ;
54
+ public static final DeferredItem <Item > EXAMPLE_ITEM = ITEMS .registerItem ("example_item" , new Item .Properties ().food (new FoodProperties .Builder ()
55
+ .alwaysEat ().nutrition (1 ).saturationMod (2f ).build ()));
55
56
56
57
// Creates a creative tab with the id "examplemod:example_tab" for the example item, that is placed after the combat tab
57
- public static final RegistryObject < CreativeModeTab > EXAMPLE_TAB = CREATIVE_MODE_TABS .register ("example_tab" , () -> CreativeModeTab .builder ()
58
+ public static final DeferredHolder < CreativeModeTab , CreativeModeTab > EXAMPLE_TAB = CREATIVE_MODE_TABS .register ("example_tab" , () -> CreativeModeTab .builder ()
58
59
.withTabsBefore (CreativeModeTabs .COMBAT )
59
60
.icon (() -> EXAMPLE_ITEM .get ().getDefaultInstance ())
60
61
.displayItems ((parameters , output ) -> {
@@ -91,7 +92,7 @@ private void commonSetup(final FMLCommonSetupEvent event)
91
92
LOGGER .info ("HELLO FROM COMMON SETUP" );
92
93
93
94
if (Config .logDirtBlock )
94
- LOGGER .info ("DIRT BLOCK >> {}" , ForgeRegistries . BLOCKS .getKey (Blocks .DIRT ));
95
+ LOGGER .info ("DIRT BLOCK >> {}" , BuiltInRegistries . BLOCK .getKey (Blocks .DIRT ));
95
96
96
97
LOGGER .info (Config .magicNumberIntroduction + Config .magicNumber );
97
98
0 commit comments