forked from neoforged/NeoForge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
GameTestHelper#forEveryBlockInStructure
including blocks that a…
…re not in the structure (neoforged#401)
- Loading branch information
1 parent
ae90c8a
commit 97f3373
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
patches/net/minecraft/gametest/framework/GameTestHelper.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- a/net/minecraft/gametest/framework/GameTestHelper.java | ||
+++ b/net/minecraft/gametest/framework/GameTestHelper.java | ||
@@ -836,7 +_,8 @@ | ||
|
||
public void forEveryBlockInStructure(Consumer<BlockPos> p_177293_) { | ||
AABB aabb = this.getRelativeBounds(); | ||
- BlockPos.MutableBlockPos.betweenClosedStream(aabb.move(0.0, 1.0, 0.0)).forEach(p_177293_); | ||
+ // Neo: Shrink AABB by one as an aabb surrounding two blocks is increased by one compared to the actual positions | ||
+ BlockPos.MutableBlockPos.betweenClosedStream(aabb.contract(1.0, 1.0, 1.0)).forEach(p_177293_); | ||
} | ||
|
||
public void onEachTick(Runnable p_177424_) { |
30 changes: 30 additions & 0 deletions
30
tests/src/main/java/net/neoforged/neoforge/debug/structure/StructureTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.debug.structure; | ||
|
||
import net.minecraft.gametest.framework.GameTest; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.neoforged.testframework.DynamicTest; | ||
import net.neoforged.testframework.annotation.ForEachTest; | ||
import net.neoforged.testframework.annotation.TestHolder; | ||
import net.neoforged.testframework.gametest.StructureTemplateBuilder; | ||
|
||
@ForEachTest(groups = StructureTests.GROUP) | ||
public class StructureTests { | ||
public static final String GROUP = "structure"; | ||
|
||
@GameTest | ||
@TestHolder(description = "Tests that the structure bounds for use in Game Tests is correct") | ||
static void everyBlockInStructure(final DynamicTest test) { | ||
test.registerGameTestTemplate(() -> StructureTemplateBuilder.withSize(3, 3, 3) | ||
.fill(0, 0, 0, 2, 2, 2, Blocks.DIAMOND_BLOCK)); | ||
|
||
test.onGameTest(helper -> helper.startSequence() | ||
.thenWaitUntil(0, () -> helper.forEveryBlockInStructure(pos -> helper.assertBlockPresent(Blocks.DIAMOND_BLOCK, pos))) | ||
.thenExecute(test::pass) | ||
.thenSucceed()); | ||
} | ||
} |