simplify code

This commit is contained in:
DBotThePony 2021-08-15 11:08:54 +07:00
parent 2328cd75b6
commit 71e83874c0
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -35,19 +35,7 @@ public abstract class BlockMatteryRotatable extends BlockMattery {
@Nullable
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
Direction find_first = null;
for (Direction direction : context.getNearestLookingDirections()) {
if (FACING.getPossibleValues().contains(direction)) {
find_first = direction;
break;
}
}
if (find_first == null)
return this.defaultBlockState();
return this.defaultBlockState().setValue(FACING, faceToPlayer(context) ? find_first.getOpposite() : find_first);
return this.defaultBlockState().setValue(FACING, faceToPlayer(context) ? context.getHorizontalDirection().getOpposite() : context.getHorizontalDirection());
}
public boolean faceToPlayer(BlockPlaceContext context) {