mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +00:00
Fix game test structure rotations being inconsistent (#10391) Fix redstone update order not matching vanilla. (#10392) Fix redstone updates for comparators going up/down incorrectly. Related: #9973 Make block pos assertions in GameTestHelper behave like in 1.21.3, thus fixing rotated tests functionality. This can be disabled in the Forge config if you have old tests that this breaks. Tho it is recommended you update your tests. --------- Co-authored-by: LexManos <[email protected]>
75 lines
3.6 KiB
Diff
75 lines
3.6 KiB
Diff
--- a/net/minecraft/gametest/framework/GameTestHelper.java
|
|
+++ b/net/minecraft/gametest/framework/GameTestHelper.java
|
|
@@ -61,7 +_,7 @@
|
|
import net.minecraft.world.phys.BlockHitResult;
|
|
import net.minecraft.world.phys.Vec3;
|
|
|
|
-public class GameTestHelper {
|
|
+public class GameTestHelper implements net.minecraftforge.common.extensions.IForgeGameTestHelper {
|
|
private final GameTestInfo testInfo;
|
|
private boolean finalCheckAdded;
|
|
|
|
@@ -870,26 +_,30 @@
|
|
}
|
|
|
|
public BlockPos absolutePos(BlockPos p_177450_) {
|
|
- BlockPos blockpos = this.testInfo.getStructureBlockPos();
|
|
+ // Forge: Use IForgeGameTestInfo#getTestOrigin to account for rotations and to mimic 1.21.3 behavior
|
|
+ BlockPos blockpos = this.testInfo.getTestOrigin();
|
|
BlockPos blockpos1 = blockpos.offset(p_177450_);
|
|
return StructureTemplate.transform(blockpos1, Mirror.NONE, this.testInfo.getRotation(), blockpos);
|
|
}
|
|
|
|
public BlockPos relativePos(BlockPos p_177453_) {
|
|
- BlockPos blockpos = this.testInfo.getStructureBlockPos();
|
|
+ // Forge: Use IForgeGameTestInfo#getTestOrigin to account for rotations and to mimic 1.21.3 behavior
|
|
+ BlockPos blockpos = this.testInfo.getTestOrigin();
|
|
Rotation rotation = this.testInfo.getRotation().getRotated(Rotation.CLOCKWISE_180);
|
|
BlockPos blockpos1 = StructureTemplate.transform(p_177453_, Mirror.NONE, rotation, blockpos);
|
|
return blockpos1.subtract(blockpos);
|
|
}
|
|
|
|
public Vec3 absoluteVec(Vec3 p_177228_) {
|
|
- Vec3 vec3 = Vec3.atLowerCornerOf(this.testInfo.getStructureBlockPos());
|
|
- return StructureTemplate.transform(vec3.add(p_177228_), Mirror.NONE, this.testInfo.getRotation(), this.testInfo.getStructureBlockPos());
|
|
+ // Forge: Use IForgeGameTestInfo#getTestOrigin to account for rotations and to mimic 1.21.3 behavior
|
|
+ Vec3 vec3 = Vec3.atLowerCornerOf(this.testInfo.getTestOrigin());
|
|
+ return StructureTemplate.transform(vec3.add(p_177228_), Mirror.NONE, this.testInfo.getRotation(), this.testInfo.getTestOrigin());
|
|
}
|
|
|
|
public Vec3 relativeVec(Vec3 p_251543_) {
|
|
- Vec3 vec3 = Vec3.atLowerCornerOf(this.testInfo.getStructureBlockPos());
|
|
- return StructureTemplate.transform(p_251543_.subtract(vec3), Mirror.NONE, this.testInfo.getRotation(), this.testInfo.getStructureBlockPos());
|
|
+ // Forge: Use IForgeGameTestInfo#getTestOrigin to account for rotations and to mimic 1.21.3 behavior
|
|
+ Vec3 vec3 = Vec3.atLowerCornerOf(this.testInfo.getTestOrigin());
|
|
+ return StructureTemplate.transform(p_251543_.subtract(vec3), Mirror.NONE, this.testInfo.getRotation(), this.testInfo.getTestOrigin());
|
|
}
|
|
|
|
public Rotation getTestRotation() {
|
|
@@ -954,5 +_,25 @@
|
|
if (either.right().isPresent()) {
|
|
this.fail("Failed to set biome for test");
|
|
}
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Adds a cleanup handler that will be called when the test is done, pass or fail.
|
|
+ */
|
|
+ public void addCleanup(Consumer<Boolean> handler) {
|
|
+ this.testInfo.addListener(new GameTestListener() {
|
|
+ @Override
|
|
+ public void testPassed(GameTestInfo info, GameTestRunner runner) {
|
|
+ handler.accept(true);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void testFailed(GameTestInfo info, GameTestRunner runner) {
|
|
+ handler.accept(false);
|
|
+ }
|
|
+
|
|
+ @Override public void testStructureLoaded(GameTestInfo info) { }
|
|
+ @Override public void testAddedForRerun(GameTestInfo oldInfo, GameTestInfo newInfo, GameTestRunner runner) { }
|
|
+ });
|
|
}
|
|
}
|