|
|
@@ -11,25 +11,32 @@ import net.minecraft.item.BlockItem;
|
|
|
import net.minecraft.item.Item;
|
|
|
import net.minecraft.registry.Registries;
|
|
|
import net.minecraft.registry.Registry;
|
|
|
+import net.minecraft.registry.RegistryKey;
|
|
|
+import net.minecraft.registry.RegistryKeys;
|
|
|
import net.minecraft.util.Identifier;
|
|
|
|
|
|
public class ModBlocks {
|
|
|
public static final Block DISASSEMBLER_BLOCK = registerBlock("disassembler",
|
|
|
- new DisassemblerBlock(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque()));
|
|
|
+ DisassemblerBlock::new, AbstractBlock.Settings.create().nonOpaque());
|
|
|
|
|
|
public static final BlockEntityType<DisassemblerBlockEntity> DISASSEMBLER_BLOCK_ENTITY =
|
|
|
Registry.register(Registries.BLOCK_ENTITY_TYPE,
|
|
|
Identifier.of("husj", "disassembler_block_entity"),
|
|
|
FabricBlockEntityTypeBuilder.create(DisassemblerBlockEntity::new, DISASSEMBLER_BLOCK).build());
|
|
|
|
|
|
- private static Block registerBlock(String name, Block block) {
|
|
|
- registerBlockItem(name, block);
|
|
|
- return Registry.register(Registries.BLOCK, Identifier.of("husj", name), block);
|
|
|
- }
|
|
|
+ private static Block registerBlock(String name, java.util.function.Function<AbstractBlock.Settings, Block> factory,
|
|
|
+ AbstractBlock.Settings settings) {
|
|
|
+ RegistryKey<Block> blockKey = RegistryKey.of(RegistryKeys.BLOCK, Identifier.of("husj", name));
|
|
|
+ settings.registryKey(blockKey);
|
|
|
+ Block block = factory.apply(settings);
|
|
|
+
|
|
|
+ Registry.register(Registries.BLOCK, blockKey, block);
|
|
|
+
|
|
|
+ RegistryKey<Item> itemKey = RegistryKey.of(RegistryKeys.ITEM, Identifier.of("husj", name));
|
|
|
+ Item.Settings itemSettings = new Item.Settings().registryKey(itemKey).useBlockPrefixedTranslationKey();
|
|
|
+ Registry.register(Registries.ITEM, itemKey, new BlockItem(block, itemSettings));
|
|
|
|
|
|
- private static Item registerBlockItem(String name, Block block) {
|
|
|
- return Registry.register(Registries.ITEM, Identifier.of("husj", name),
|
|
|
- new BlockItem(block, new Item.Settings()));
|
|
|
+ return block;
|
|
|
}
|
|
|
|
|
|
public static void registerModBlocks() {
|