package dev.sillyangel.nuggetmod.block; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.Identifier; import dev.sillyangel.nuggetmod.NuggetMod; import dev.sillyangel.nuggetmod.item.ModItems; import net.minecraft.util.valueproviders.UniformInt; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.DropExperienceBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraftforge.eventbus.api.bus.BusGroup; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import java.util.function.Supplier; public class ModBlocks { public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, NuggetMod.MOD_ID); public static final RegistryObject NUGGET_BLOCK = registerBlock("nugget_block", () -> new Block(BlockBehaviour.Properties.of() .setId(ResourceKey.create(Registries.BLOCK, Identifier.fromNamespaceAndPath(NuggetMod.MOD_ID, "nugget_block"))) .strength(4f).requiresCorrectToolForDrops().sound(SoundType.AMETHYST))); public static final RegistryObject RAW_NUGGET_BLOCK = registerBlock("raw_nugget_block", () -> new Block(BlockBehaviour.Properties.of() .setId(ResourceKey.create(Registries.BLOCK, Identifier.fromNamespaceAndPath(NuggetMod.MOD_ID, "raw_nugget_block"))) .strength(3f).requiresCorrectToolForDrops())); // ores public static final RegistryObject NUGGET_ORE = registerBlock("nugget_ore", () -> new DropExperienceBlock(UniformInt.of(2, 4), BlockBehaviour.Properties.of() .setId(ResourceKey.create(Registries.BLOCK, Identifier.fromNamespaceAndPath(NuggetMod.MOD_ID, "nugget_ore"))) .strength(4f).requiresCorrectToolForDrops())); public static final RegistryObject NUGGET_DEEPSLATE_ORE = registerBlock("nugget_deepslate_ore", () -> new DropExperienceBlock(UniformInt.of(2, 4), BlockBehaviour.Properties.of() .setId(ResourceKey.create(Registries.BLOCK, Identifier.fromNamespaceAndPath(NuggetMod.MOD_ID, "nugget_deepslate_ore"))) .strength(5f).requiresCorrectToolForDrops().sound(SoundType.DEEPSLATE))); private static RegistryObject registerBlock(String name, Supplier block) { RegistryObject toReturn = BLOCKS.register(name, block); registerBlockItem(name, toReturn); return toReturn; } private static void registerBlockItem(String name, RegistryObject block) { ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties() .setId(ResourceKey.create(Registries.ITEM, Identifier.fromNamespaceAndPath(NuggetMod.MOD_ID, name))))); } public static void register(BusGroup busGroup) { BLOCKS.register(busGroup); } }