cabaletta / baritone

google maps for block game
GNU Lesser General Public License v3.0
7.12k stars 1.43k forks source link

Using mods which change your eye height causes block placement to fail #4484

Open Happyrobot33 opened 2 weeks ago

Happyrobot33 commented 2 weeks ago

When using a player scaling mod, breaking blocks will work completely fine, but trying to have baritone place blocks will end up with it constantly looking at the wrong angles to do so

May possibly be related to this hardcoded function here? I'm new to the codebase so excuse me if it isn't I'm just poking around to see https://github.com/cabaletta/baritone/blob/ef72c568330fb874ea6e912c7d6323cd79825057/src/api/java/baritone/api/utils/IPlayerContext.java#L102-L104

Some information

Operating system: Windows Java version: Fabric Minecraft version: 1.20.1 Baritone version: 1.10.1 fabric Other mods (if used): Pehkui

How to reproduce

Use a mod like Pehkui to change your player height to around a block or less and baritone will consistently fail to aim at the correct location and get stuck trying to place the block

Final checklist

ZacSharp commented 2 weeks ago

Yes, that method is likely part of the problem. However you should note that the usual player size is used in a lot more places so e.g. pathfinding will always search a path for a roughly one block wide and two blocks high player.

Happyrobot33 commented 2 weeks ago

Yes, that method is likely part of the problem. However you should note that the usual player size is used in a lot more places so e.g. pathfinding will always search a path for a roughly one block wide and two blocks high player.

In alot of cases the one block wide two block tall scenario works for characters smaller than default, although i think it would be neat if this could either be configured or calculated at runtime aswell, but thats out of scope for this current issue :). I tried getting a dev environment setup but gradle is complaining about pretty much all of the base API stuff not existing so i cant test a possible fix for this right now

Happyrobot33 commented 2 weeks ago

was able to get a really jank build environment going and can confirm that this is the code that needs to be changed. I tried making it dynamic but there's a bit of a static stackup happening and there isn't a reference to the player so I'm not sure how to do that myself, help would be appreciated there

Happyrobot33 commented 2 weeks ago

well then, ive half fixed the problem.

by doing this instead, it now correctly figures out what angle to look at when placing blocks its seems. But now I've run into a new issue where when my motion speed is adjusted up to match a regular players speed, it now overshoots the block its running on and falls off, presumably because it is not crouching early enough.

for context, the previous method call to the static function in IPlayerContext has been removed entirely along with the source method itself, as you can just ask for the eye height of a entity in different poses such as crouching.

public static Vec3 inferSneakingEyePosition(Entity entity) {
        return new Vec3(entity.getX(), entity.getY() + (entity.getEyeHeight(Pose.CROUCHING)), entity.getZ());
    } 
Happyrobot33 commented 2 weeks ago

This is motion scale at 1, meaning at my current single block size, my motion is also slower at half the normal block speed

https://github.com/user-attachments/assets/21a9c130-6573-445b-b016-84e872f2ff3d

This is motion scale at 2, meaning I move twice as fast as I would, but at my half size I move at the speed of a normal sized player

https://github.com/user-attachments/assets/c7dc0d01-8edd-4873-82d1-5bff5eae7a63

Where is the logic for determining when to start sneaking, because I could maybe start that earlier so you don't fall off the block?

Happyrobot33 commented 2 weeks ago

aha! turning off assumeSafeWalk makes it not fall off! So my code modification should be all that's needed to fix this issue I believe