NullPointerException caused by code issues in LookBehavior.java
DylanWake opened this issue ยท 0 comments
Some information
Operating system: Windows 10
Java version: jdk 1.8u261
Minecraft version: 1.16.1 - Baritone Development environment
Baritone version: Baritone Development Environment
Forge mods (if used): null
Exception, error or logs
[21:41:56] [main/INFO]: [CHAT] [ @KJCrack: ] => implemented
[21:41:56] [main/INFO]: [CHAT] [ @KJCrack: ] => ---------<Status>---------
[21:41:56] [main/INFO]: [CHAT] [ @KJCrack: ] => Thread: Thread-5
[21:41:56] [main/INFO]: [CHAT] [ @KJCrack: ] => --------------------------
[21:41:57] [Thread-5/INFO]: [STDERR]: java.lang.NullPointerException
[21:41:57] [Thread-5/INFO]: [STDERR]: at baritone.behavior.LookBehavior.updateTarget(LookBehavior.java:58)
[21:41:57] [Thread-5/INFO]: [STDERR]: at baritone.pathing.movement.Movement.lambda$update$1(Movement.java:137)
[21:41:57] [Thread-5/INFO]: [STDERR]: at java.util.Optional.ifPresent(Optional.java:159)
[21:41:57] [Thread-5/INFO]: [STDERR]: at baritone.pathing.movement.Movement.update(Movement.java:136)
[21:41:57] [Thread-5/INFO]: [STDERR]: at kitejencien.cracker.crack_commands.TestCommand.exec(TestCommand.java:53)
[21:41:57] [Thread-5/INFO]: [STDERR]: at kitejencien.cracker.CrackSample.lambda$parseRequest$0(CrackSample.java:95)
[21:41:57] [Thread-5/INFO]: [STDERR]: at java.util.HashMap.forEach(HashMap.java:1289)
[21:41:57] [Thread-5/INFO]: [STDERR]: at kitejencien.cracker.CrackSample.parseRequest(CrackSample.java:93)
[21:41:57] [Thread-5/INFO]: [STDERR]: at kitejencien.cracker.CrackSampleListener.run(CrackSampleListener.java:34)
How to reproduce
Run the following code somewhere in baritone ( I did this to manually use the movement system inside baritone from another thread ):
Movement startup = new MovementParkour(baritone, ctx.playerFeet(), 2,Direction.fromAngle(180),true);
currentState = startup.updateState(currentState);
currentState.setTarget(new MovementState.MovementTarget(new Rotation(0,0),false));
while (!currentState.getStatus().equals(MovementStatus.SUCCESS) &&
!currentState.getStatus().equals(MovementStatus.FAILED)) {
startup.updateState(currentState);
startup.update();
}
And the code that causes the exception is:
@Override
public void updateTarget(Rotation target, boolean force) {
this.target = target;
if (!force) {
double rand = Math.random() - 0.5;
if (Math.abs(rand) < 0.1) {
rand *= 4;
}
(HERE)-> this.target = new Rotation(this.target.getYaw() + (float) (rand * Baritone.settings().randomLooking113.value), this.target.getPitch());
}
this.force = force || !Baritone.settings().freeLook.value;
}
The issue might be cause by initializing a variable using itself, and can be fixed through changing line 58 to:
this.target = new Rotation(target.getYaw() + (float) (rand * Baritone.settings().randomLooking113.value), target.getPitch());
Modified settings
To get the modified settings run #modified
in game
Final checklist
- I know how to properly use check boxes
- I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
- I have included logs, exceptions and / or steps to reproduce the issue.
- I have not used any OwO's or UwU's in this issue.