From 4894d720c8793a37a2f2daee54449bf1c39726b0 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Tue, 13 Aug 2024 13:02:39 -0500 Subject: [PATCH] better(ish) interaction detecting for server fix --- src/main/java/one/oth3r/sit/utl/Utl.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 2eb176b..f070ca7 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -171,7 +171,9 @@ public class Utl { Block block = blockState.getBlock(); // make sure that the block that is being sit on has no interaction when hand sitting - if (hit != null && blockState.onUse(player.getWorld(), player, hit).isAccepted()) return null; + if (hit != null && hasInteraction(blockState)) { + return null; + } // only if custom is enabled if (config.isCustomEnabled()) { @@ -201,6 +203,23 @@ public class Utl { return null; } + /** + * checks if a block has an interaction + * @param blockState + * @return + */ + public static boolean hasInteraction(BlockState blockState) { + // todo flush out + Block block = blockState.getBlock(); + // most blocks with entity has an interaction, just block all of them + if (block instanceof BlockWithEntity) return true; + if (block instanceof BedBlock) return true; + if (block instanceof DoorBlock) return true; + if (block instanceof TrapdoorBlock) return true; + + return false; + } + public static class Entity { /**