fix bed sitting for new version

This commit is contained in:
Virt 2025-06-17 19:42:29 +02:00
commit 26df4015fe
3 changed files with 19 additions and 19 deletions

View file

@ -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

View file

@ -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);

View file

@ -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;