Skip to content

Commit

Permalink
Fix CustomDoubleWidthBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
FirstMegaGame4 committed Nov 11, 2023
1 parent 8a52e52 commit 2fe34c2
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ public CustomDoubleWidthBlock(Settings settings, boolean hasItem, Item.Settings
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
OrientedBlockPos oriented = OrientedBlockPos.of(ctx.getBlockPos()).apply(ctx.getPlayerFacing());
boolean validOrigin = this.canPlacePartAt(ctx.getWorld().getBlockState(oriented), ctx);
boolean validSub0 = this.canPlacePartAt(ctx.getWorld().getBlockState(oriented.front()), ctx);
boolean validSub1 = this.canPlacePartAt(ctx.getWorld().getBlockState(oriented.front().left()), ctx);
boolean validSub2 = this.canPlacePartAt(ctx.getWorld().getBlockState(oriented.left()), ctx);
boolean validOrigin = this.canPlacePartAt(ctx.getWorld(), new BlockPos(oriented), ctx.getWorld().getBlockState(oriented), ctx);
boolean validSub0 = this.canPlacePartAt(ctx.getWorld(), new BlockPos(oriented.front()), ctx.getWorld().getBlockState(oriented.front()), ctx);
boolean validSub1 = this.canPlacePartAt(ctx.getWorld(), new BlockPos(oriented.front().left()), ctx.getWorld().getBlockState(oriented.front().left()), ctx);
boolean validSub2 = this.canPlacePartAt(ctx.getWorld(), new BlockPos(oriented.left()), ctx.getWorld().getBlockState(oriented.left()), ctx);
return validOrigin && validSub0 && validSub1 && validSub2 ? this.getDefaultState().with(PART, DoubleWidthPart.ORIGIN).with(FACING, ctx.getPlayerFacing()) : null;
}

public boolean canPlacePartAt(BlockState state, ItemPlacementContext ctx) {
public boolean canPlacePartAt(World world, BlockPos pos, BlockState state, ItemPlacementContext ctx) {
return state.canReplace(ctx);
}

Expand Down

0 comments on commit 2fe34c2

Please sign in to comment.