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

Strange offset in GameTest position #1948

Closed
Edivad99 opened this issue Feb 8, 2025 · 12 comments · Fixed by #1949
Closed

Strange offset in GameTest position #1948

Edivad99 opened this issue Feb 8, 2025 · 12 comments · Fixed by #1949
Labels
1.21.3 Targeted at Minecraft 1.21.3 1.21.4 Targeted at Minecraft 1.21.4 vanilla bug A bug or error in the base Minecraft game

Comments

@Edivad99
Copy link
Contributor

Edivad99 commented Feb 8, 2025

Minecraft Version: 1.21.3

NeoForge Version: 21.3.63

Steps to Reproduce:

  1. Use the /test pos command

Image

  1. Set the value reported by the command to the code
    Image

  2. The test fails because it does not find the button
    Image

This is the code that was in 1.21.1

public BlockPos absolutePos(BlockPos pos) {
    BlockPos blockpos = this.testInfo.getStructureBlockPos();
    BlockPos blockpos1 = blockpos.offset(pos);
    return StructureTemplate.transform(blockpos1, Mirror.NONE, this.testInfo.getRotation(), blockpos);
}

and this in 1.21.3

public BlockPos absolutePos(BlockPos pos) {
    BlockPos blockpos = this.testInfo.getTestOrigin();
    BlockPos blockpos1 = blockpos.offset(pos);
    return StructureTemplate.transform(blockpos1, Mirror.NONE, this.testInfo.getRotation(), blockpos);
}

When doing a test, blockpos gets two different values ​​and it is probably the cause of the problem

@Edivad99 Edivad99 added the triage Needs triaging and confirmation label Feb 8, 2025
@ChampionAsh5357 ChampionAsh5357 added vanilla bug A bug or error in the base Minecraft game 1.21.3 Targeted at Minecraft 1.21.3 1.21.4 Targeted at Minecraft 1.21.4 and removed triage Needs triaging and confirmation labels Feb 9, 2025
@ChampionAsh5357
Copy link
Contributor

Okay, so I see the issue now. Basically, the way that TestCommand#showPos works is that it gets the position relative to the structure block. However, getTestOrigin gets the position relative to the corner of the test boundary, which by default is one above the structure block, making the test position inputted wrong as it doesn't take into account the structure offset. This is fixed in the 1.21.5 snapshots, but it can be backported.

@ChampionAsh5357
Copy link
Contributor

Bug report on 1.21.5 snapshot that was resolved: https://bugs.mojang.com/browse/MC-279599

@neoforged-releases
Copy link

🚀 This issue has been resolved in NeoForge version 21.4.88-beta, as part of #1949.

@Edivad99
Copy link
Contributor Author

Edivad99 commented Feb 9, 2025

@ChampionAsh5357
The problem remains.
When I run /test pos, it now returns 0,2,3.
But if I run the test it fails and the red block is rendered at 0,3,3
wyetrackpassive failed! Expected button at 10,60,2 (relative: 0,3,3) (t=0)

@Edivad99
Copy link
Contributor Author

Edivad99 commented Feb 9, 2025

Even if it writes 0,3,3 I put 0,2,3

@GameTest(template = "wye_track_passive")
public static void wyeTrackPassive(GameTestHelper helper) {
    helper.pressButton(0, 2, 3);
    helper.succeedWhenEntityPresent(EntityType.MINECART, 3, 2, 5);
}

@ChampionAsh5357
Copy link
Contributor

I am unable to verify after the PR. You are welcome to provide the NBT file in question so that I may further test.

@Edivad99
Copy link
Contributor Author

Edivad99 commented Feb 9, 2025

Ok, strangely enough I had to run a gradle build and then it worked

@Edivad99
Copy link
Contributor Author

Edivad99 commented Feb 9, 2025

If I change a coordinate by decreasing the y by 1 and immediately run GameTestServer, it fails.
While if I change and do a gradle build and then run GameTestServer it works.
Is it normal?

@ChampionAsh5357
Copy link
Contributor

To me, that suggests there's something wrong with the compilation process of your buildscript and that the classes in the build folder aren't getting updated.

Running the tests on my end shows no issue, so there's probably something weird going on with your buildscript.

@Edivad99
Copy link
Contributor Author

Edivad99 commented Feb 9, 2025

I don't know, it doesn't seem strange to me. https://github.com/railcraft-reborn/railcraft/blob/1.21.3%2B/build.gradle

@ChampionAsh5357
Copy link
Contributor

Hmm, I've done a bit of testing, but I'm still having trouble replicating your situation. My best guess is that something strange is happening when the source set is applied to the run configurations such that it doesn't use the changes unless explicitly told to by building. Best I can suggest is try invalidating the gradle caches; otherwise, it would probably require a deep dive or someone with more knowledge than me to take a look at the situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.3 Targeted at Minecraft 1.21.3 1.21.4 Targeted at Minecraft 1.21.4 vanilla bug A bug or error in the base Minecraft game
Projects
None yet
2 participants