package com.thebrokenrail.energonrelics.api.block; import com.thebrokenrail.energonrelics.EnergonRelics; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.util.Identifier; import net.minecraft.util.Rarity; import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.ApiStatus; /** * Simple Block */ public class SimpleBlock extends Block { public SimpleBlock(Settings settings) { super(settings); } /** * Register Block And Block Item * @param id ID */ public void register(Identifier id) { Registry.register(Registry.BLOCK, id, this); if (registerItem()) { Item.Settings settings = new Item.Settings(); if (addToItemGroup() || FabricLoader.getInstance().isDevelopmentEnvironment()) { settings.group(getItemGroup()); } if (isEpic()) { settings.rarity(Rarity.EPIC); } settings.maxCount(getMaxCount()); Registry.register(Registry.ITEM, id, new BlockItem(this, settings)); } } /** * Register Block And Block Item * @param name ID */ public final void register(String name) { register(new Identifier(EnergonRelics.NAMESPACE, name)); } /** * Get Item Group To Add Block Item To * @return Item Group */ @SuppressWarnings("SameReturnValue") @ApiStatus.OverrideOnly protected ItemGroup getItemGroup() { return EnergonRelics.Items.ITEM_GROUP; } /** * Should The Block item be Added To An Item Group In A Non-Development Environment * @return Should it Be Added */ @ApiStatus.OverrideOnly protected boolean addToItemGroup() { return true; } /** * Should A Block Item Be Registered * @return Should It Be Registered */ @ApiStatus.OverrideOnly protected boolean registerItem() { return true; } /** * Get Max Stack Count * @return Max Stack Count */ @ApiStatus.OverrideOnly protected int getMaxCount() { return 64; } /** * Should The Item Rarity be Epic * @return Should It Be Epic */ @ApiStatus.OverrideOnly protected boolean isEpic() { return false; } }