Skip to content

Commit

Permalink
Improve block placing
Browse files Browse the repository at this point in the history
  • Loading branch information
Wide-Cat committed Aug 14, 2023
1 parent 74478bc commit 712d948
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ public static boolean place(BlockPos blockPos, Hand hand, int slot, boolean rota
side = Direction.UP;
neighbour = blockPos;
} else {
neighbour = blockPos.offset(side.getOpposite());
hitPos.add(side.getOffsetX() * 0.5, side.getOffsetY() * 0.5, side.getOffsetZ() * 0.5);
neighbour = blockPos.offset(side);
hitPos = hitPos.add(side.getOffsetX() * 0.5, side.getOffsetY() * 0.5, side.getOffsetZ() * 0.5);
}

BlockHitResult bhr = new BlockHitResult(hitPos, side, neighbour, false);
BlockHitResult bhr = new BlockHitResult(hitPos, side.getOpposite(), neighbour, false);

if (rotate) {
Rotations.rotate(Rotations.getYaw(hitPos), Rotations.getPitch(hitPos), rotationPriority, () -> {
Expand Down Expand Up @@ -148,8 +148,6 @@ public static boolean canPlace(BlockPos blockPos) {
public static Direction getPlaceSide(BlockPos blockPos) {
for (Direction side : Direction.values()) {
BlockPos neighbor = blockPos.offset(side);
Direction side2 = side.getOpposite();

BlockState state = mc.world.getBlockState(neighbor);

// Check if neighbour isn't empty
Expand All @@ -158,7 +156,7 @@ public static Direction getPlaceSide(BlockPos blockPos) {
// Check if neighbour is a fluid
if (!state.getFluidState().isEmpty()) continue;

return side2;
return side;
}

return null;
Expand Down

0 comments on commit 712d948

Please sign in to comment.