Fix crouch timer, bed collision on sleep, and pathfinding: better node evaluator maluses, path-aware door opening

This commit is contained in:
2026-06-14 01:57:58 +03:00
parent a43adb0de2
commit ff6046e89c
3 changed files with 58 additions and 13 deletions
@@ -6,6 +6,8 @@ import net.minecraft.world.entity.ai.goal.Goal;
import net.minecraft.world.level.block.BedBlock;
import net.minecraft.world.level.block.DoorBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.pathfinder.Node;
import net.minecraft.world.level.pathfinder.Path;
import net.minecraft.world.phys.Vec3;
import java.util.EnumSet;
@@ -86,8 +88,24 @@ public class EllieSleepGoal extends Goal {
}
private void tryOpenDoor() {
Path path = ellie.getNavigation().getPath();
BlockPos entityPos = ellie.blockPosition();
if (path != null) {
for (int i = 0; i < Math.min(4, path.getNodeCount()); i++) {
Node node = path.getNode(i);
BlockPos checkPos = new BlockPos(node.x, node.y, node.z);
if (checkPos.distSqr(entityPos) > 9) break;
BlockState state = ellie.level().getBlockState(checkPos);
if (state.getBlock() instanceof DoorBlock) {
if (!state.getValue(DoorBlock.OPEN)) {
ellie.level().setBlock(checkPos, state.setValue(DoorBlock.OPEN, true), 3);
}
return;
}
}
}
for (int i = 0; i < 3; i++) {
BlockPos checkPos = ellie.blockPosition().relative(ellie.getDirection(), i);
BlockPos checkPos = entityPos.relative(ellie.getDirection(), i);
BlockState state = ellie.level().getBlockState(checkPos);
if (state.getBlock() instanceof DoorBlock) {
if (!state.getValue(DoorBlock.OPEN)) {