Skip to content

Commit

Permalink
Registry rework: fix link and expand special DR example
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Nov 24, 2023
1 parent e9f355d commit 00303d8
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions content/news/20.2registry-rework.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This blog post will go through the most important changes that were made,
to act as a migration guide for modders.

This rework is the first of the three big reworks to land
after [our initial 20.2 release](../20.2release).
after [our initial 20.2 release](../20.2release/).
The other two systems that will receive an overhaul in the coming weeks
are **capabilities** and **networking**.
Once these also land we will be aiming for a 20.2 stable release.
Expand Down Expand Up @@ -82,14 +82,25 @@ Here are is an example:
NeoForge also provides `DeferredHolder` and `DeferredRegister` specializations for items and blocks
that implement `ItemLike`. For example:
```java
// Make sure you use the special DeferredRegister.Blocks and DeferredRegister.Items types,
// NOT DeferredRegister<Block> or DeferredRegister<Item>!
private static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks("mymod");
private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems("mymod");

// If you are registering blocks or items directly, use a normal `register` call:
public static final DeferredBlock<MyBlock> MY_BLOCK = BLOCKS.register("my_block", () -> new MyBlock(/* create block */));
public static final DeferredItem<MyItem> MY_ITEM = ITEMS.register("my_item", () -> new MyItem(/* create item */));

// There are also a few extra helper functions, for example `registerBlockItem`:
public static final DeferredItem<BlockItem> MY_BLOCK_ITEM = ITEMS.registerBlockItem(MY_BLOCK);
// There are also a few extra helper functions.
// `registerBlock` to directly register a `new Block` from some block properties:
public static final DeferredBlock<Block> MY_SIMPLE_BLOCK =
BLOCKS.registerBlock("simple_block", BlockBehaviour.Properties.of().mapColor(MapColor.STONE));
// `registerItem` to directly register a `new Item` from some item properties:
public static final DeferredItem<Item> MY_SIMPLE_ITEM =
ITEMS.registerItem("simple_item", new Item.Properties().stacksTo(1));
// `registerBlockItem` to directly register a `new BlockItem` for a block:
public static final DeferredItem<BlockItem> MY_BLOCK_ITEM =
ITEMS.registerBlockItem(MY_BLOCK);
```

As usual, don't forget to pass your mod bus to your `DeferredRegister`s:
Expand Down

0 comments on commit 00303d8

Please sign in to comment.