package de.slpnetwork.brewcraft.block; import de.slpnetwork.brewcraft.Brewcraft; import de.slpnetwork.brewcraft.item.ModItems; 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.Blocks; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraftforge.eventbus.api.IEventBus; 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, Brewcraft.MODID); // example development block public static final RegistryObject SAPPHIRE_BLOCK = registerBlock("sapphire_block", () -> new Block(BlockBehaviour.Properties.copy(Blocks.EMERALD_BLOCK).sound(SoundType.AMETHYST))); /** * Handles registering the block itself and registering it as an item * @param name the blocks name * @param block the blocks properties * @return the blocks registryObject */ private static RegistryObject registerBlock(String name, Supplier block){ RegistryObject toReturn = BLOCKS.register(name, block); registerBlockItem(name, toReturn); return toReturn; } /** * registers blocks as item * @param name the blocks name * @param block the block * @return an item containing that block */ private static RegistryObject registerBlockItem(String name, RegistryObject block) { return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties())); } public static void register(IEventBus eventBus) { BLOCKS.register(eventBus); } }