package ru.betterend.blocks.basis; import java.util.Collections; import java.util.List; import java.util.Optional; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.WeightedPressurePlateBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.storage.loot.LootContext; import ru.betterend.client.models.BlockModelProvider; import ru.betterend.client.models.Patterns; public class EndMetalPlateBlock extends WeightedPressurePlateBlock implements BlockModelProvider { private final Block parent; public EndMetalPlateBlock(Block source) { super(15, FabricBlockSettings.copyOf(source).noCollission().noOcclusion().requiresCorrectToolForDrops().strength(0.5F)); this.parent = source; } @Override public List getDrops(BlockState state, LootContext.Builder builder) { return Collections.singletonList(new ItemStack(this)); } @Override public Optional getModelString(String block) { ResourceLocation blockId = Registry.BLOCK.getKey(this); ResourceLocation parentId = Registry.BLOCK.getKey(parent); if (block.contains("down")) { return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath()); } return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath()); } }