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

fix searching for main supporting block #1709

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

Cyramek
Copy link
Contributor

@Cyramek Cyramek commented Sep 11, 2024

fixes #1698

main issue was

int minBlockX = (int) Math.floor(checkBox.minX);
int maxBlockX = (int) Math.floor(checkBox.maxX);
int minBlockY = (int) Math.floor(checkBox.minY);
int maxBlockY = (int) Math.floor(checkBox.maxY);
int minBlockZ = (int) Math.floor(checkBox.minZ);
int maxBlockZ = (int) Math.floor(checkBox.maxZ);

being different than vanilla

also there is no reason for cloning WrapperBlockState in Collisions#hasMaterial as we don't modify the state anywhere

@ManInMyVan
Copy link
Contributor

ManInMyVan commented Sep 11, 2024

What version(s) source have you checked when making this? Asking because it might have changed at some point

@Cyramek
Copy link
Contributor Author

Cyramek commented Sep 11, 2024

What version(s) source have you checked when making this? Asking because it might have changed at some point

1.16 - 1.20.1, main supporting block was added in 1.19 iirc, so it should be fine

@ManInMyVan
Copy link
Contributor

What version(s) source have you checked when making this? Asking because it might have changed at some point

1.16 - 1.20.1, main supporting block was added in 1.19 iirc, so it should be fine

Can you test this (and or check source) in 1.21, 1.12, and 1.8?

@Cyramek
Copy link
Contributor Author

Cyramek commented Sep 11, 2024

I tested this with 1.21.1 client, but I was checking 1.20.1, 1.18, 1.16.4 sources

1.20.1, 1.18.2, 1.16.4 source it is all the same:

        int i = Mth.floor(box.minX - 1.0E-7D) - 1;
        int j = Mth.floor(box.maxX + 1.0E-7D) + 1;
        int k = Mth.floor(box.minY - 1.0E-7D) - 1;
        int l = Mth.floor(box.maxY + 1.0E-7D) + 1;
        int m = Mth.floor(box.minZ - 1.0E-7D) - 1;
        int n = Mth.floor(box.maxZ + 1.0E-7D) + 1;

in 1.8 it is different:

        int i = MathHelper.floor_double(bb.minX);
        int j = MathHelper.floor_double(bb.maxX + 1.0D);
        int k = MathHelper.floor_double(bb.minY);
        int l = MathHelper.floor_double(bb.maxY + 1.0D);
        int i1 = MathHelper.floor_double(bb.minZ);
        int j1 = MathHelper.floor_double(bb.maxZ + 1.0D);

and in 1.12.2:

        int i = MathHelper.floor(p_191504_2_.minX) - 1;
        int j = MathHelper.ceil(p_191504_2_.maxX) + 1;
        int k = MathHelper.floor(p_191504_2_.minY) - 1;
        int l = MathHelper.ceil(p_191504_2_.maxY) + 1;
        int i1 = MathHelper.floor(p_191504_2_.minZ) - 1;
        int j1 = MathHelper.ceil(p_191504_2_.maxZ) + 1;

the Collisions#hasMaterial method doesn't check whether there is a collision with player's AABB (maybe there should be one?), so that's why i didn't want to modify it directly

edit: also there is diff in 1.8 and 1.12, idk if it makes any difference:

1.8 - 1.12

    public boolean intersects(double x1, double y1, double z1, double x2, double y2, double z2)
    {
        return this.minX < x2 && this.maxX > x1 && this.minY < y2 && this.maxY > y1 && this.minZ < z2 && this.maxZ > z1;
    }

1.20.1

    public static boolean voxelShapeIntersect(final AABB box, final double minX, final double minY, final double minZ,
                                              final double maxX, final double maxY, final double maxZ) {
        return (box.minX - maxX) < -COLLISION_EPSILON && (box.maxX - minX) > COLLISION_EPSILON &&
               (box.minY - maxY) < -COLLISION_EPSILON && (box.maxY - minY) > COLLISION_EPSILON &&
               (box.minZ - maxZ) < -COLLISION_EPSILON && (box.maxZ - minZ) > COLLISION_EPSILON;
    }

@Cyramek
Copy link
Contributor Author

Cyramek commented Sep 11, 2024

if anyone want to reproduce this:
image
there must be ice around, I wasn't able to reproduce it without it

@ManInMyVan
Copy link
Contributor

I tested this with 1.21.1 client, but I was checking 1.20.1, 1.18, 1.16.4 sources

1.20.1, 1.18.2, 1.16.4 source it is all the same:

        int i = Mth.floor(box.minX - 1.0E-7D) - 1;
        int j = Mth.floor(box.maxX + 1.0E-7D) + 1;
        int k = Mth.floor(box.minY - 1.0E-7D) - 1;
        int l = Mth.floor(box.maxY + 1.0E-7D) + 1;
        int m = Mth.floor(box.minZ - 1.0E-7D) - 1;
        int n = Mth.floor(box.maxZ + 1.0E-7D) + 1;

in 1.8 it is different:

        int i = MathHelper.floor_double(bb.minX);
        int j = MathHelper.floor_double(bb.maxX + 1.0D);
        int k = MathHelper.floor_double(bb.minY);
        int l = MathHelper.floor_double(bb.maxY + 1.0D);
        int i1 = MathHelper.floor_double(bb.minZ);
        int j1 = MathHelper.floor_double(bb.maxZ + 1.0D);

and in 1.12.2:

        int i = MathHelper.floor(p_191504_2_.minX) - 1;
        int j = MathHelper.ceil(p_191504_2_.maxX) + 1;
        int k = MathHelper.floor(p_191504_2_.minY) - 1;
        int l = MathHelper.ceil(p_191504_2_.maxY) + 1;
        int i1 = MathHelper.floor(p_191504_2_.minZ) - 1;
        int j1 = MathHelper.ceil(p_191504_2_.maxZ) + 1;

the Collisions#hasMaterial method doesn't check whether there is a collision with player's AABB (maybe there should be one?), so that's why i didn't want to modify it directly

edit: also there is diff in 1.8 and 1.12, idk if it makes any difference:

1.8 - 1.12

    public boolean intersects(double x1, double y1, double z1, double x2, double y2, double z2)
    {
        return this.minX < x2 && this.maxX > x1 && this.minY < y2 && this.maxY > y1 && this.minZ < z2 && this.maxZ > z1;
    }

1.20.1

    public static boolean voxelShapeIntersect(final AABB box, final double minX, final double minY, final double minZ,
                                              final double maxX, final double maxY, final double maxZ) {
        return (box.minX - maxX) < -COLLISION_EPSILON && (box.maxX - minX) > COLLISION_EPSILON &&
               (box.minY - maxY) < -COLLISION_EPSILON && (box.maxY - minY) > COLLISION_EPSILON &&
               (box.minZ - maxZ) < -COLLISION_EPSILON && (box.maxZ - minZ) > COLLISION_EPSILON;
    }

I think COLLISION_EPSILON is just 0 in 1.8-1.12

@SamB440
Copy link
Collaborator

SamB440 commented Sep 11, 2024

The new code only runs on modern versions so it shouldn't matter for old versions

@SamB440 SamB440 merged commit c4c0634 into GrimAnticheat:2.0 Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

false when player step fence
3 participants