40 lines
1.5 KiB
Java
40 lines
1.5 KiB
Java
package magistu.siegemachines.block;
|
|
|
|
import magistu.siegemachines.SiegeMachines;
|
|
import magistu.siegemachines.item.ModItems;
|
|
import net.minecraft.block.AbstractBlock;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.SoundType;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.item.BlockItem;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraftforge.eventbus.api.IEventBus;
|
|
import net.minecraftforge.fml.RegistryObject;
|
|
import net.minecraftforge.registries.DeferredRegister;
|
|
import net.minecraftforge.registries.ForgeRegistries;
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
public class ModBlocks
|
|
{
|
|
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, SiegeMachines.ID);
|
|
public static final RegistryObject<SiegeWorkbench> SIEGE_WORKBENCH = registerBlock("siege_workbench", () -> new SiegeWorkbench(AbstractBlock.Properties.of(Material.WOOD).strength(2.5f).sound(SoundType.WOOD)));
|
|
|
|
private static <T extends Block>RegistryObject<T> registerBlock(String name, Supplier<T> block)
|
|
{
|
|
RegistryObject<T> toReturn = BLOCKS.register(name, block);
|
|
registerBlockItem(name, toReturn);
|
|
return toReturn;
|
|
}
|
|
|
|
private static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block)
|
|
{
|
|
ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().tab(ModItems.GROUP_SM)));
|
|
}
|
|
|
|
public static void register(IEventBus eventBus)
|
|
{
|
|
BLOCKS.register(eventBus);
|
|
}
|
|
}
|