22
33import com .mojang .serialization .MapCodec ;
44import net .minecraft .core .BlockPos ;
5+ import net .minecraft .world .item .context .BlockPlaceContext ;
56import net .minecraft .world .level .BlockGetter ;
67import net .minecraft .world .level .block .BaseEntityBlock ;
78import net .minecraft .world .level .block .entity .BlockEntity ;
1516
1617import javax .annotation .Nullable ;
1718
18- public class QerEntityBlock extends BaseEntityBlock {
19- public static final VoxelShape SHAPE = makeShape ();
19+ public class QerEntityBlock extends DirectionalEntityBlock {
2020 private static final MapCodec <QerEntityBlock > CODEC = simpleCodec (QerEntityBlock ::new );
2121
2222 public QerEntityBlock () {
@@ -27,27 +27,6 @@ private QerEntityBlock(Properties properties) {
2727 super (properties );
2828 }
2929
30- @ SuppressWarnings ("DuplicatedCode" )
31- private static VoxelShape makeShape () {
32- VoxelShape shape = Shapes .empty ();
33- shape = Shapes .join (shape , Shapes .box (0.25 , -0.0015625000000000083 , 0.25 , 0.75 , 0.125 , 0.75 ), BooleanOp .OR );
34- shape = Shapes .join (shape , Shapes .box (0.25 , 0 , 0.25 , 0.75 , 0.25 , 0.75 ), BooleanOp .OR );
35- shape = Shapes .join (shape , Shapes .box (-0.004441738241592191 , -0.125 , 0.3124999999999999 , 0.05805826175840764 , 0.3125 , 0.5625 ), BooleanOp .OR );
36- shape = Shapes .join (shape , Shapes .box (0.9419417382415922 , -0.125 , 0.4375 , 1.0044417382415922 , 0.3125 , 0.6875000000000001 ), BooleanOp .OR );
37- shape = Shapes .join (shape , Shapes .box (0.9419417382415922 , -0.125 , 0.3125 , 1.0044417382415922 , 0.3125 , 0.5625000000000001 ), BooleanOp .OR );
38- shape = Shapes .join (shape , Shapes .box (0.3124999999999999 , -0.125 , 0.9419417382415922 , 0.5625 , 0.3125 , 1.0044417382415922 ), BooleanOp .OR );
39- shape = Shapes .join (shape , Shapes .box (0.12055826175840781 , 0.3125 , 0.3749999999999999 , 0.18305826175840764 , 0.6875 , 0.625 ), BooleanOp .OR );
40- shape = Shapes .join (shape , Shapes .box (0.3749999999999999 , 0.3125 , 0.8169417382415923 , 0.625 , 0.6875 , 0.8794417382415922 ), BooleanOp .OR );
41- shape = Shapes .join (shape , Shapes .box (0.375 , 0.3125 , 0.12055826175840778 , 0.6250000000000001 , 0.6875 , 0.18305826175840767 ), BooleanOp .OR );
42- shape = Shapes .join (shape , Shapes .box (0.8169417382415923 , 0.3125 , 0.375 , 0.8794417382415922 , 0.6875 , 0.6250000000000001 ), BooleanOp .OR );
43- shape = Shapes .join (shape , Shapes .box (0.25 , 0.8125 , 0.25 , 0.75 , 0.875 , 0.75 ), BooleanOp .OR );
44- shape = Shapes .join (shape , Shapes .box (0.375 , 0.625 , 0.375 , 0.625 , 0.6875 , 0.625 ), BooleanOp .OR );
45- shape = Shapes .join (shape , Shapes .box (0.375 , 0.125 , 0.375 , 0.625 , 0.4375 , 0.625 ), BooleanOp .OR );
46- shape = Shapes .join (shape , Shapes .box (0.4375 , 0.4375 , 0.4375 , 0.5625 , 1.1875 , 0.5625 ), BooleanOp .OR );
47- shape = Shapes .join (shape , Shapes .box (0.375 , 1 , 0.375 , 0.625 , 1.0625 , 0.625 ), BooleanOp .OR );
48- return shape ;
49- }
50-
5130 @ Override
5231 protected MapCodec <? extends BaseEntityBlock > codec () {
5332 return CODEC ;
@@ -60,7 +39,7 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
6039 }
6140
6241 @ Override
63- protected VoxelShape getShape ( BlockState state , BlockGetter level , BlockPos pos , CollisionContext context ) {
64- return SHAPE ;
42+ public BlockState getStateForPlacement ( BlockPlaceContext context ) {
43+ return this . defaultBlockState (). setValue ( FACING , context . getClickedFace ()) ;
6544 }
6645}
0 commit comments