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.
Merge remote-tracking branch 'upstream/1.20.x' into 1.20.x
- Loading branch information
Showing
8 changed files
with
231 additions
and
19 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_) { |
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
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
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
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
27 changes: 27 additions & 0 deletions
27
...ated/resources/data/neotests_mod_datapack/advancements/recipes/misc/test_advancement.json
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,27 @@ | ||
{ | ||
"parent": "minecraft:recipes/root", | ||
"criteria": { | ||
"has_scute": { | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": [ | ||
"minecraft:scute" | ||
] | ||
} | ||
] | ||
}, | ||
"trigger": "minecraft:inventory_changed" | ||
} | ||
}, | ||
"requirements": [ | ||
[ | ||
"has_scute" | ||
] | ||
], | ||
"rewards": { | ||
"recipes": [ | ||
"minecraft:turtle_helmet" | ||
] | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
tests/src/main/java/net/neoforged/neoforge/debug/resources/ModDatapackTest.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,52 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.debug.resources; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import net.minecraft.advancements.Advancement; | ||
import net.minecraft.advancements.AdvancementRewards; | ||
import net.minecraft.advancements.CriteriaTriggers; | ||
import net.minecraft.advancements.critereon.InventoryChangeTrigger; | ||
import net.minecraft.advancements.critereon.ItemPredicate; | ||
import net.minecraft.data.recipes.RecipeBuilder; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.Items; | ||
import net.neoforged.neoforge.common.data.AdvancementProvider; | ||
import net.neoforged.neoforge.event.OnDatapackSyncEvent; | ||
import net.neoforged.testframework.DynamicTest; | ||
import net.neoforged.testframework.annotation.ForEachTest; | ||
import net.neoforged.testframework.annotation.TestHolder; | ||
|
||
@ForEachTest(groups = ModDatapackTest.GROUP) | ||
public class ModDatapackTest { | ||
public static final String GROUP = "resources"; | ||
|
||
@TestHolder(description = "Tests that mod datapacks are loaded properly on initial load and reload", enabledByDefault = true) | ||
static void modDatapack(final DynamicTest test) { | ||
final ResourceLocation testAdvancement = new ResourceLocation(test.createModId(), "recipes/misc/test_advancement"); | ||
|
||
test.registrationHelper().addProvider(event -> { | ||
List<AdvancementProvider.AdvancementGenerator> generators = List.of((registries, saver, existingFileHelper) -> Advancement.Builder.recipeAdvancement() | ||
.parent(RecipeBuilder.ROOT_RECIPE_ADVANCEMENT) | ||
.addCriterion("has_scute", CriteriaTriggers.INVENTORY_CHANGED.createCriterion( | ||
new InventoryChangeTrigger.TriggerInstance( | ||
Optional.empty(), InventoryChangeTrigger.TriggerInstance.Slots.ANY, List.of( | ||
ItemPredicate.Builder.item().of(Items.SCUTE).build())))) | ||
.rewards(AdvancementRewards.Builder.recipe(new ResourceLocation("minecraft:turtle_helmet"))) | ||
.save(saver, testAdvancement, existingFileHelper)); | ||
return new AdvancementProvider(event.getGenerator().getPackOutput(), event.getLookupProvider(), event.getExistingFileHelper(), generators); | ||
}); | ||
|
||
test.eventListeners().forge().addListener((OnDatapackSyncEvent event) -> { | ||
if (event.getPlayerList().getServer().getAdvancements().get(testAdvancement) != null) { | ||
test.pass(); | ||
} else { | ||
test.fail("Test advancement not loaded"); | ||
} | ||
}); | ||
} | ||
} |
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()); | ||
} | ||
} |