From 26df4015fee5010778694aae4233e79351c16442 Mon Sep 17 00:00:00 2001 From: Virt <41426325+VirtCode@users.noreply.github.com> Date: Tue, 17 Jun 2025 19:42:29 +0200 Subject: [PATCH] fix bed sitting for new version --- gradle/wrapper/gradle-wrapper.properties | 2 +- src/main/java/one/oth3r/sit/utl/Logic.java | 29 ++++++++-------------- src/main/java/one/oth3r/sit/utl/Utl.java | 7 ++++++ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9355b41..cea7a79 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/one/oth3r/sit/utl/Logic.java b/src/main/java/one/oth3r/sit/utl/Logic.java index 2da2cd6..82a0e81 100644 --- a/src/main/java/one/oth3r/sit/utl/Logic.java +++ b/src/main/java/one/oth3r/sit/utl/Logic.java @@ -1,5 +1,6 @@ package one.oth3r.sit.utl; +import net.minecraft.block.BlockState; import net.minecraft.entity.decoration.DisplayEntity; import net.minecraft.registry.Registries; import net.minecraft.registry.tag.TagKey; @@ -18,7 +19,6 @@ import java.awt.*; public class Logic { - private static double BED_HEIGHT = 0.5625; /** * checks if the player can sit at the block specified @@ -34,39 +34,32 @@ public class Logic { // if sitting on a sit entity and sit while seated off, false if (!FileData.getServerConfig().canSitWhileSeated() && Data.getSitEntity(player) != null) return false; - ServerWorld serverWorld = player.getServerWorld(); + ServerWorld serverWorld = player.getWorld(); BlockState blockState = serverWorld.getBlockState(blockPos); - Double sitHeight = null; - // is a bed? if (blockState.isIn(TagKey.of(Registries.BLOCK.getKey(), Identifier.tryParse("minecraft:beds")))) { - if (hitResult != null) { - - // is a cookie? - if (Registries.ITEM.getId(player.getStackInHand(Hand.MAIN_HAND).getItem()).toString().equals("minecraft:cookie")) - sitHeight = BED_HEIGHT; - else return false; - - } else { - sitHeight = BED_HEIGHT; - } + // hit result == null means mod right? + if (hitResult != null && !Registries.ITEM.getId(player.getStackInHand(Hand.MAIN_HAND).getItem()).toString().equals("minecraft:cookie")) + return false; // behave normally otherwise } else { + // if hit result isnt null (check the hands of the player) & the player hand checker returns false (can't sit with the items in the hand), quit if (hitResult != null) { if (!checkHands(player)) return false; } - - sitHeight = Utl.getSittingHeight(blockState, player, blockPos, hitResult); } // check if the block is in the right y level limits from the config if (!checkYLimits(player, blockPos)) return false; - // if the sit height is null, its not a sittable block - if (sitHeight == null) return false; + Double sitHeight = Utl.getSittingHeight(player, blockPos, hitResult); + + // if the sit height is null, it's not a sittable block + if (sitHeight == null) + return false; DisplayEntity.TextDisplayEntity entity = Utl.Entity.create(serverWorld,blockPos,sitHeight); diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 305d5ca..a3c9286 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -43,6 +43,8 @@ import java.util.List; public class Utl { + private static double BED_HEIGHT = 0.5625; + /** * check if a block is obstructed (no collision) * @return true if not obstructed @@ -166,6 +168,11 @@ public class Utl { BlockState blockState = serverWorld.getBlockState(blockPos); Block block = blockState.getBlock(); + // check bed first + if (blockState.isIn(TagKey.of(Registries.BLOCK.getKey(), Identifier.tryParse("minecraft:beds")))) { + return BED_HEIGHT; + } + // make sure that the block that is being sit on has no interaction when hand sitting if (hit != null && blockIsInList(config.getInteractionBlocks(), blockState)) { return null;