56 lines
1.9 KiB
Java
56 lines
1.9 KiB
Java
package ru.betterend.blocks.basis;
|
|
|
|
import java.io.Reader;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
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.StairBlock;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.storage.loot.LootContext;
|
|
import ru.betterend.patterns.BlockModelProvider;
|
|
import ru.betterend.patterns.Patterns;
|
|
|
|
public class EndStairsBlock extends StairBlock implements BlockModelProvider {
|
|
|
|
private final Block parent;
|
|
|
|
public EndStairsBlock(Block source) {
|
|
super(source.defaultBlockState(), FabricBlockSettings.copyOf(source));
|
|
this.parent = source;
|
|
}
|
|
|
|
@Override
|
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
|
return Collections.singletonList(new ItemStack(this));
|
|
}
|
|
|
|
@Override
|
|
public String getStatesPattern(Reader data) {
|
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
|
return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
|
|
}
|
|
|
|
@Override
|
|
public String getModelString(String block) {
|
|
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
|
if (block.contains("inner")) {
|
|
return Patterns.createJson(Patterns.BLOCK_STAIR_INNER, parentId.getPath(), blockId.getPath());
|
|
}
|
|
if (block.contains("outer")) {
|
|
return Patterns.createJson(Patterns.BLOCK_STAIR_OUTER, parentId.getPath(), blockId.getPath());
|
|
}
|
|
return Patterns.createJson(Patterns.BLOCK_STAIR, parentId.getPath(), blockId.getPath());
|
|
}
|
|
|
|
@Override
|
|
public ResourceLocation statePatternId() {
|
|
return Patterns.STATE_STAIRS;
|
|
}
|
|
}
|