-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite block and item registration based on Terrestria.
Update to Terraform API 6.1.1.
- Loading branch information
1 parent
f0d4bfb
commit a917fa1
Showing
5 changed files
with
185 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
32 changes: 32 additions & 0 deletions
32
common/src/main/java/com/terraformersmc/traverse/init/helpers/TraverseRegistry.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.terraformersmc.traverse.init.helpers; | ||
|
||
import com.terraformersmc.traverse.Traverse; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.item.BlockItem; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class TraverseRegistry { | ||
@SuppressWarnings("UnnecessaryReturnStatement") | ||
public TraverseRegistry() { | ||
return; | ||
} | ||
|
||
public static BlockItem registerBlockItem(String name, Block block) { | ||
BlockItem item = new BlockItem(block, new Item.Settings()); | ||
return register(name, item); | ||
} | ||
|
||
public static <I extends Item> I register(String name, I item) { | ||
if (item instanceof BlockItem blockItem) { | ||
blockItem.appendBlocks(Item.BLOCK_ITEMS, blockItem); | ||
} | ||
return Registry.register(Registries.ITEM, Identifier.of(Traverse.MOD_ID, name), item); | ||
} | ||
|
||
public static <B extends Block> B register(String name, B block) { | ||
return Registry.register(Registries.BLOCK, Identifier.of(Traverse.MOD_ID, name), block); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.