Skip to content

Commit

Permalink
Return null if state for placement is null
Browse files Browse the repository at this point in the history
  • Loading branch information
hlysine committed Jul 26, 2024
1 parent 3c42286 commit 72241c0
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public boolean isPathfindable(@NotNull BlockState pState, @NotNull BlockGetter p
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
Axis axis = context.getNearestLookingDirection().getAxis();
return stateForPlacement.setValue(AXIS, axis);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private static VoxelShape calculateMultifaceShape(BlockState pState) {
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
BlockPos blockPos = context.getClickedPos();
BlockState state = context.getLevel().getBlockState(blockPos);
if (state.is(this)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public boolean isPathfindable(BlockState pState, BlockGetter pLevel, BlockPos pP
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
BlockPos blockPos = context.getClickedPos();
BlockState state = context.getLevel().getBlockState(blockPos);
Vec3 bias = Vec3.atLowerCornerOf(context.getClickedFace().getNormal()).scale(1 / 16f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public Vec3i getVectorFromProperty(BlockState state, String property) {
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
BlockPos blockPos = context.getClickedPos();
BlockState state = context.getLevel().getBlockState(blockPos);
if (state.is(this)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public boolean isPathfindable(@NotNull BlockState pState, @NotNull BlockGetter p
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;

Direction facing = context.getClickedFace().getOpposite();
double offset1, offset2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockSt
@Override
public BlockState getStateForPlacement(@NotNull BlockPlaceContext pContext) {
BlockState stateForPlacement = super.getStateForPlacement(pContext);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
return stateForPlacement.setValue(FACING, pContext.getHorizontalDirection().getOpposite());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public boolean isIgnoredConnectivitySide(BlockAndTintGetter reader, BlockState s
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
BlockPos blockPos = context.getClickedPos();
BlockState state = context.getLevel().getBlockState(blockPos);
if (state.is(this)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public boolean canConnectTexturesToward(String property, BlockAndTintGetter read
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
BlockPos blockPos = context.getClickedPos();
BlockState state = context.getLevel().getBlockState(blockPos);
if (state.is(this)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public boolean isPathfindable(BlockState pState, BlockGetter pLevel, BlockPos pP
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
BlockPos blockPos = context.getClickedPos();
BlockState state = context.getLevel().getBlockState(blockPos);
if (state.is(this)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public boolean isPathfindable(@NotNull BlockState pState, @NotNull BlockGetter p
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
Direction facing = context.getHorizontalDirection();
Half half = context.getClickedFace() == Direction.DOWN
? Half.TOP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockSt
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
BlockPos blockPos = context.getClickedPos();
BlockState state = context.getLevel().getBlockState(blockPos);
if (state.is(this)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public boolean isPathfindable(@NotNull BlockState pState, @NotNull BlockGetter p
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;
BlockPos blockPos = context.getClickedPos();
BlockState state = context.getLevel().getBlockState(blockPos);
if (state.is(this)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public boolean isPathfindable(@NotNull BlockState pState, @NotNull BlockGetter p
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;

int xOffset = context.getClickLocation().x - context.getClickedPos().getX() > 0.5 ? 1 : -1;
int zOffset = context.getClickLocation().z - context.getClickedPos().getZ() > 0.5 ? 1 : -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public boolean isPathfindable(@NotNull BlockState pState, @NotNull BlockGetter p
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState stateForPlacement = super.getStateForPlacement(context);
assert stateForPlacement != null;
if (stateForPlacement == null) return null;

int xOffset = context.getClickLocation().x - context.getClickedPos().getX() > 0.5 ? 1 : -1;
int zOffset = context.getClickLocation().z - context.getClickedPos().getZ() > 0.5 ? 1 : -1;
Expand Down

0 comments on commit 72241c0

Please sign in to comment.