package ru.bclib.blocks; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.storage.loot.LootContext; import ru.bclib.interfaces.BlockModelProvider; import java.util.Collections; import java.util.List; import java.util.function.Consumer; /** * Base class for a default Block. *

* This Block-Type will: *

*/ public class BaseBlock extends Block implements BlockModelProvider { /** * Creates a new Block with the passed properties * * @param settings The properties of the Block. */ public BaseBlock(Properties settings) { super(settings); } /** * {@inheritDoc} *

* This implementation will drop the Block itself */ @Override @SuppressWarnings("deprecation") public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } /** * {@inheritDoc} *

* This implementation will load the Block-Model and return it as the Item-Model */ @Override public BlockModel getItemModel(ResourceLocation blockId) { return getBlockModel(blockId, defaultBlockState()); } /** * This method is used internally. *

* It is called from Block-Contructors, to allow the augmentation of the blocks * preset properties. *

* For example in {@link BaseLeavesBlock#BaseLeavesBlock(Block, MaterialColor, Consumer)} * * @param customizeProperties A {@link Consumer} to call with the preset properties * @param settings The properties as created by the Block * @return The reconfigured {@code settings} */ static FabricBlockSettings acceptAndReturn(Consumer customizeProperties, FabricBlockSettings settings) { customizeProperties.accept(settings); return settings; } }