Skip to content

Commit

Permalink
Fix open double
Browse files Browse the repository at this point in the history
  • Loading branch information
AmarokIce committed Jun 10, 2024
1 parent e65de34 commit 9c081b1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/ho/artisan/bdo/event/BDOPlayerEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,20 @@ private static void openDoor(Level level, BlockPos pos, BlockState state, Player
level.gameEvent(player, GameEvent.BLOCK_OPEN, pos);

var side = state.getValue(DoorBlock.HINGE);
pos = side == DoorHingeSide.RIGHT
? pos.offset(-face.getStepZ(), face.getStepY(), -face.getStepX())
: pos.offset(face.getStepZ(), face.getStepY(), face.getStepX());

var flag = side == DoorHingeSide.RIGHT;
var reverse = (flag ? -1 : 1) * ((face == Direction.NORTH || face == Direction.SOUTH) ? -1 : 1);
pos = pos.offset(face.getStepZ() * reverse, face.getStepY(), face.getStepX() * reverse);

state = level.getBlockState(pos);
if (!state.is(BlockTags.DOORS)) return;
if (state.getValue(BlockStateProperties.OPEN)) return;
if (state.getValue(DoorBlock.HINGE) != (flag ? DoorHingeSide.LEFT : DoorHingeSide.RIGHT)) return;

state = state.cycle(DoorBlock.OPEN);
level.setBlock(pos, state, 10);
level.gameEvent(player, GameEvent.BLOCK_OPEN, pos);
}
}


@SuppressWarnings("unused")
Expand Down

0 comments on commit 9c081b1

Please sign in to comment.