baritone icon indicating copy to clipboard operation
baritone copied to clipboard

1.20.1 Use pose system for calculating the height of crouching instead of hardcoded values

Open Happyrobot33 opened this issue 1 year ago • 6 comments

instead of using hardcoded crouching values, just use the built in method for geting a entitys eye height with a specific pose. Should close #4484 from personal testing

closes #4484

Happyrobot33 avatar Aug 28 '24 15:08 Happyrobot33

Removing a public method from the API package. I'd say an @Deprecated is more appropriate.

Otherwise a simple and sane looking change.

ZacSharp avatar Aug 29 '24 16:08 ZacSharp

IPlayerContext does have access to the player entity, so you could just put the pose thing in the old function

wagyourtail avatar Sep 06 '24 11:09 wagyourtail

IPlayerContext does have access to the player entity, so you could just put the pose thing in the old function

the problem is its static so I'm not sure how to even reference the IPlayerContext directly here since it doesn't have a instance reference. and if it was changed to non static it would still be a breaking change

Happyrobot33 avatar Sep 06 '24 17:09 Happyrobot33

There is the possibility of BaritoneAPI.getProvider().getAllBaritones().stream().map(Baritone::getPlayerContext).filter(c -> c.player() == entity).findFirst().get().getEyeHeight(true), but that's clearly worse and (re?)introducing BaritoneProvider::getBaritoneForPlayer wouldn't help much. Also why assume the entity is a player? I'd say either the method has to take a LocalPlayer argument or assuming the entity is a player is plain wrong. Not sure whether we should assume there is a Baritone instance for the passed player.

EDIT: I've been tricked by an interface default implementation. IBaritoneProvider::getBaritoneForPlayer does exist, but not in the file I looked at. So it would be BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) entity).getPlayerContext().getEyeHeight(true), with potential for CCE and NPE for no reason.

ZacSharp avatar Sep 06 '24 22:09 ZacSharp

There is the possibility of BaritoneAPI.getProvider().getAllBaritones().stream().map(Baritone::getPlayerContext).filter(c -> c.player() == player).findFirst().get().getEyeHeight(true), but that's clearly worse and (re?)introducing BaritoneProvider::getBaritoneForPlayer wouldn't help much. Also why assume the entity is a player? I'd say either the method has to take a LocalPlayer argument or assuming the entity is a player is plain wrong. Not sure whether we should assume there is a Baritone instance for the passed player.

yeah that long method call is just painful to read as is and feels very breakable lol. I think deprecating it is a better option here, and anyone using it should just refer to the entity itself in the same way the codebase does

Happyrobot33 avatar Sep 06 '24 23:09 Happyrobot33

can this be done to the 1.19 branch?

leijurv avatar Sep 16 '24 06:09 leijurv

Rebased onto 1.19.4: https://github.com/cabaletta/baritone/pull/4713

ZacSharp avatar Apr 18 '25 21:04 ZacSharp