Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash on custom goal request #4307

Open
Redhawk18 opened this issue Mar 19, 2024 · 7 comments
Open

crash on custom goal request #4307

Redhawk18 opened this issue Mar 19, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@Redhawk18
Copy link

Redhawk18 commented Mar 19, 2024

case ShulkerSearchPathing: {
    if (baritone.getCustomGoalProcess().isActive()) {
        Helper.HELPER.logDirect("custom goal to path to shulker");
        return; // Wait to get there
    }

    curCheckingShulker = getShulkerToCheck();
    Helper.HELPER.logDirect("found current shulker: " + curCheckingShulker.toString());
    if (curCheckingShulker == null) {
        ...
    }

    Optional<Rotation> shulkerReachable = RotationUtils.reachable(ctx.player(), curCheckingShulker,
            ctx.playerController().getBlockReachDistance());

    if (shulkerReachable.isPresent()) {
        ...
    } else {
        Helper.HELPER.logDirect("Going to shulker");
        // crash happens here vvv
        baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(getPathingSpotByShulker(curCheckingShulker)));
    }
    break;
}

This leads to this error

[19:38:34] [Render thread/ERROR]: Unreported exception thrown!
java.lang.IllegalArgumentException: Multiple entries with same key: class_2338{x=-322, y=63, z=-61}=net.minecraft.class_2627@5c367bff and BetterBlockPos{x=-322,y=63,z=-61}=net.minecraft.class_2627@32300150

and crashes the rendering thread so crashing the game.

@Redhawk18 Redhawk18 added the bug Something isn't working label Mar 19, 2024
@ZacSharp
Copy link
Collaborator

Did you find the reason for the crash?

@Redhawk18
Copy link
Author

Did you find the reason for the crash?

I haven't I'm going to circle back because I just found out how to turn off obfuscation for baritone

@Redhawk18 Redhawk18 reopened this Apr 11, 2024
@Redhawk18
Copy link
Author

Redhawk18 commented Apr 11, 2024

Did you find the reason for the crash?

i just fixed it, the problem was that baritone would insert a BetterBlockPos into it the map of blockpos that minecraft uses cause them to collide. This is the code that fixed it, while it does get ride of a lot of the gains BetterBlockPos gives it's worth it to not have my game crash.

--- a/src/api/java/baritone/api/utils/BetterBlockPos.java
+++ b/src/api/java/baritone/api/utils/BetterBlockPos.java
@@ -80,7 +80,7 @@ public final class BetterBlockPos extends BlockPos {
 
     @Override
     public int hashCode() {
-        return (int) longHash(x, y, z);
+        return super.hashCode();
     }

While this works, a better solution for upstream should be implemented.

@ZacSharp
Copy link
Collaborator

What would such a fix look like?

  • Not extending BlockPos. A very disruptive change for anyone using BetterBlockPos and making it far less convenient to use.
  • Making BetterBlockPos compare not equal to any BlockPos. Confusing and annoying to work with.
  • Fix the place inserting the BetterBlockPos and hope things work for another five years without breaking.

@Redhawk18
Copy link
Author

What would such a fix look like?

* Not extending `BlockPos`. A very disruptive change for anyone using `BetterBlockPos` and making it far less convenient to use.

* Making `BetterBlockPos` compare not equal to any `BlockPos`. Confusing and annoying to work with.

* Fix the place inserting the `BetterBlockPos` and hope things work for another five years without breaking.

I have no idea, but correct is better than incorrect with any speed up.

@ZacSharp
Copy link
Collaborator

Can you maybe provide the place leaking the BetterBlockPos? Reproducing on your branch failed and I currently don't have the time to figure it out using just the error message.

@Redhawk18
Copy link
Author

Can you maybe provide the place leaking the BetterBlockPos? Reproducing on your branch failed and I currently don't have the time to figure it out using just the error message.

This is what I was told by a friend who's one of the lead meteor maintainers.

this would only happen if you

    1. call WorldChunk#addBlockEntity or WorldChunk#setBlockEntity with
    1. a block entity where BlockEntity#getPos is a baritone BetterBlockPos

We likely have a problem with the 2nd one, it seems baritone doesn't often do this so this must have never got caught.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants