76 lines
2.6 KiB
Java
76 lines
2.6 KiB
Java
package fr.adrien1106.reframed.block;
|
|
|
|
import fr.adrien1106.reframed.util.blocks.BlockHelper;
|
|
import fr.adrien1106.reframed.util.blocks.Corner;
|
|
import fr.adrien1106.reframed.util.blocks.Edge;
|
|
import fr.adrien1106.reframed.util.blocks.StairShape;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockState;
|
|
import net.minecraft.block.ShapeContext;
|
|
import net.minecraft.item.ItemPlacementContext;
|
|
import net.minecraft.state.StateManager;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.util.math.Direction;
|
|
import net.minecraft.util.shape.VoxelShape;
|
|
import net.minecraft.world.BlockView;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import static fr.adrien1106.reframed.block.ReFramedHalfStairBlock.HALF_STAIR_VOXELS;
|
|
import static fr.adrien1106.reframed.block.ReFramedStairBlock.getStairShape;
|
|
import static fr.adrien1106.reframed.util.blocks.BlockProperties.EDGE;
|
|
import static fr.adrien1106.reframed.util.blocks.Edge.*;
|
|
import static net.minecraft.util.shape.VoxelShapes.empty;
|
|
|
|
public class ReFramedHalfStairsStairBlock extends WaterloggableReFramedDoubleBlock {
|
|
public ReFramedHalfStairsStairBlock(Settings settings) {
|
|
super(settings);
|
|
setDefaultState(getDefaultState().with(EDGE, NORTH_DOWN));
|
|
}
|
|
|
|
@Override
|
|
public Object getModelCacheKey(BlockState state) {
|
|
return state.get(EDGE);
|
|
}
|
|
|
|
@Override
|
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
|
super.appendProperties(builder.add(EDGE));
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
|
return super.getPlacementState(ctx).with(EDGE, BlockHelper.getPlacementEdge(ctx));
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getCullingShape(BlockState state, BlockView view, BlockPos pos) {
|
|
return isGhost(view, pos) ? empty(): getStairShape(state.get(EDGE), StairShape.STRAIGHT);
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
|
return getStairShape(state.get(EDGE), StairShape.STRAIGHT);
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getShape(BlockState state, int i) {
|
|
Edge edge = state.get(EDGE);
|
|
Direction side = i == 1
|
|
? edge.getRightDirection()
|
|
: edge.getLeftDirection();
|
|
Corner corner = Corner.getByDirections(
|
|
edge.getFirstDirection(),
|
|
edge.getSecondDirection(),
|
|
side
|
|
|
|
);
|
|
return HALF_STAIR_VOXELS[corner.getID() * 3 + corner.getDirectionIndex(side)];
|
|
}
|
|
|
|
@Override
|
|
public int getTopThemeIndex(BlockState state) {
|
|
return 2;
|
|
}
|
|
}
|