fix: floral workbench shape
This commit is contained in:
parent
85bc6293b1
commit
5dd5d23221
1 changed files with 25 additions and 1 deletions
|
@ -4,6 +4,7 @@ import fr.sushi.charmsnfabrics.common.entities.block.FloralWorkstationBlockEntit
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
|
@ -13,17 +14,33 @@ import net.minecraft.world.level.block.state.BlockBehaviour;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class FloralWorkstation extends Block implements EntityBlock
|
||||
{
|
||||
public static final EnumProperty<Direction> FACING =
|
||||
HorizontalDirectionalBlock.FACING;
|
||||
|
||||
private static final VoxelShape LEGS =
|
||||
Shapes.or(Block.box(1.0, 0.0, 1.0, 3.0, 12.0, 3.0),
|
||||
Block.box(1.0, 0.0, 13.0, 3.0, 12.0, 15.0),
|
||||
Block.box(13.0, 0.0, 13.0, 15.0, 12.0, 15.0),
|
||||
Block.box(13.0, 0.0, 1.0, 15.0, 12.0, 3.0));
|
||||
private static final VoxelShape TABLE = Block.column(16.0, 12.0, 14.0);
|
||||
private static final VoxelShape SUPPORT = Block.column(12.0, 2.0, 3.0);
|
||||
private static final Map<Direction.Axis, VoxelShape> SHAPES =
|
||||
Shapes.rotateHorizontalAxis(Shapes.or(LEGS, TABLE, SUPPORT));
|
||||
|
||||
public FloralWorkstation(BlockBehaviour.Properties properties)
|
||||
{
|
||||
super(properties);
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
|
||||
this.registerDefaultState(
|
||||
this.stateDefinition.any().setValue(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,6 +63,13 @@ public class FloralWorkstation extends Block implements EntityBlock
|
|||
return state.setValue(FACING, rot.rotate(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VoxelShape getShape(BlockState state, BlockGetter level,
|
||||
BlockPos pos, CollisionContext context)
|
||||
{
|
||||
return SHAPES.get(state.getValue(FACING).getAxis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockEntity newBlockEntity(BlockPos pos, BlockState state)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue