From 3a56b1980d87e915474a294ce286dac9d3d53996 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Tue, 6 Aug 2024 11:08:48 -0500 Subject: [PATCH] sit command try to sit at look target, before falling back to below --- .../one/oth3r/sit/command/SitCommand.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/one/oth3r/sit/command/SitCommand.java b/src/main/java/one/oth3r/sit/command/SitCommand.java index 5ab50f1..a2545fe 100644 --- a/src/main/java/one/oth3r/sit/command/SitCommand.java +++ b/src/main/java/one/oth3r/sit/command/SitCommand.java @@ -56,19 +56,23 @@ public class SitCommand { return 1; } + // player + if (args[0].equalsIgnoreCase("sit")) { - // todo make the command target the block that the player is looking at, if not looking at a block default to below - BlockPos pos = player.getBlockPos(); + // if the player can't sit where they're looking, try to sit below + if (!Logic.sitLooking(player)) { + BlockPos pos = player.getBlockPos(); - if (!(player.getY() -((int) player.getY()) > 0.00)) { - pos = pos.add(0,-1,0); + if (!(player.getY() - ((int) player.getY()) > 0.00)) { + pos = pos.add(0, -1, 0); + } + + // if already sitting, ignore + if (FileData.getSitEntity(player) != null) return 1; + + // try to make the player sit + Logic.sit(player, pos, null); } - - // if already sitting, ignore - if (FileData.getSitEntity(player) != null) return 1; - - // try to make the player sit - Logic.sit(player,pos,null); } if (args[0].equalsIgnoreCase("reload")) {