Skip to content

Commit 021de87

Browse files
committed
port: update gametest to 1.21.5
1 parent af67b02 commit 021de87

File tree

8 files changed

+48
-65
lines changed

8 files changed

+48
-65
lines changed

src/gametest/java/dev/isxander/debugify/test/DebugifyGameTestMain.java

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/gametest/java/dev/isxander/debugify/test/DebugifyTestUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dev.isxander.debugify.test.suites.MC8187;
44
import net.minecraft.core.BlockPos;
55
import net.minecraft.gametest.framework.GameTestHelper;
6+
import net.minecraft.network.chat.Component;
67
import net.minecraft.world.entity.EquipmentSlot;
78
import net.minecraft.world.item.Item;
89
import net.minecraft.world.item.ItemStack;
@@ -39,14 +40,14 @@ public static void bonemealIndefinitely(GameTestHelper ctx, BlockPos pos) {
3940
* Asserts that blocks in a given area are as expected.
4041
*/
4142
public static void assertBlockFill(GameTestHelper ctx, BlockPos start, BlockPos end, Predicate<Block> test, String message) {
42-
area(start, end, pos -> ctx.assertBlock(pos, test, message));
43+
area(start, end, pos -> ctx.assertBlock(pos, test, block -> Component.literal(message)));
4344
}
4445

4546
/**
4647
* Asserts that blockstates in a given area are as expected.
4748
*/
4849
public static void assertBlockStateFill(GameTestHelper ctx, BlockPos start, BlockPos end, Predicate<BlockState> test, String message) {
49-
area(start, end, pos -> ctx.assertBlockState(pos, test, () -> message));
50+
area(start, end, pos -> ctx.assertBlockState(pos, test, block -> Component.literal(message)));
5051
}
5152

5253
/**

src/gametest/java/dev/isxander/debugify/test/suites/MC100991.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package dev.isxander.debugify.test.suites;
22

3-
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
3+
import net.fabricmc.fabric.api.gametest.v1.GameTest;
44
import net.minecraft.core.BlockPos;
5-
import net.minecraft.gametest.framework.GameTest;
65
import net.minecraft.gametest.framework.GameTestHelper;
76
import net.minecraft.world.InteractionHand;
87
import net.minecraft.world.entity.EntityType;
@@ -13,8 +12,8 @@
1312
import net.minecraft.world.item.Items;
1413
import net.minecraft.world.level.GameType;
1514

16-
public class MC100991 implements FabricGameTest {
17-
@GameTest(template = EMPTY_STRUCTURE)
15+
public class MC100991 {
16+
@GameTest
1817
public void statTrackRodKill(GameTestHelper ctx) {
1918
Mob targetMob = ctx.spawnWithNoFreeWill(EntityType.CREEPER, new BlockPos(4, 0, 4));
2019

src/gametest/java/dev/isxander/debugify/test/suites/MC30391.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
package dev.isxander.debugify.test.suites;
22

3-
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
4-
import net.minecraft.client.Minecraft;
3+
import net.fabricmc.fabric.api.gametest.v1.GameTest;
54
import net.minecraft.core.BlockPos;
6-
import net.minecraft.gametest.framework.GameTest;
75
import net.minecraft.gametest.framework.GameTestHelper;
86
import net.minecraft.world.entity.EntityType;
97
import net.minecraft.world.entity.Mob;
108

11-
public class MC30391 implements FabricGameTest {
9+
public class MC30391 {
1210

13-
@GameTest(template = EMPTY_STRUCTURE)
11+
@GameTest
1412
public void blaze(GameTestHelper ctx) {
1513
testWithEntity(ctx, EntityType.BLAZE);
1614
}
1715

18-
@GameTest(template = EMPTY_STRUCTURE)
16+
@GameTest
1917
public void chicken(GameTestHelper ctx) {
2018
testWithEntity(ctx, EntityType.CHICKEN);
2119
}
2220

23-
@GameTest(template = EMPTY_STRUCTURE)
21+
@GameTest
2422
public void wither(GameTestHelper ctx) {
2523
testWithEntity(ctx, EntityType.WITHER);
2624
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package dev.isxander.debugify.test.suites;
22

3-
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
3+
import net.fabricmc.fabric.api.gametest.v1.GameTest;
44
import net.minecraft.core.BlockPos;
5-
import net.minecraft.gametest.framework.GameTest;
65
import net.minecraft.gametest.framework.GameTestHelper;
6+
import net.minecraft.network.chat.Component;
77
import net.minecraft.world.entity.EntityType;
88
import net.minecraft.world.entity.ai.attributes.Attributes;
9-
import net.minecraft.world.entity.animal.Wolf;
9+
import net.minecraft.world.entity.animal.wolf.Wolf;
1010
import net.minecraft.world.entity.projectile.Snowball;
1111

12-
public class MC72151 implements FabricGameTest {
13-
@GameTest(template = EMPTY_STRUCTURE)
12+
public class MC72151 {
13+
@GameTest
1414
public void mc72151(GameTestHelper ctx) {
1515
BlockPos wolfPos = new BlockPos(4, 0, 4);
1616
Wolf wolf = ctx.spawnWithNoFreeWill(EntityType.WOLF, wolfPos);
@@ -23,6 +23,6 @@ public void mc72151(GameTestHelper ctx) {
2323
double h = Math.sqrt(e * e + g * g) * 0.2F;
2424
snowball.shoot(e, f + h, g, 1.6F, 0f);
2525

26-
ctx.succeedIf(() -> ctx.assertTrue(wolf.getHealth() == wolf.getMaxHealth(), "Wolf shouldn't be damaged."));
26+
ctx.succeedIf(() -> ctx.assertTrue(wolf.getHealth() == wolf.getMaxHealth(), Component.literal("Wolf shouldn't be damaged.")));
2727
}
2828
}

src/gametest/java/dev/isxander/debugify/test/suites/MC8187.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package dev.isxander.debugify.test.suites;
22

33
import dev.isxander.debugify.test.DebugifyTestUtils;
4-
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
4+
import net.fabricmc.fabric.api.gametest.v1.GameTest;
55
import net.minecraft.core.BlockPos;
6-
import net.minecraft.gametest.framework.GameTest;
76
import net.minecraft.gametest.framework.GameTestHelper;
7+
import net.minecraft.network.chat.Component;
88
import net.minecraft.tags.BlockTags;
99
import net.minecraft.world.level.block.*;
1010
import net.minecraft.world.level.block.state.BlockState;
@@ -17,7 +17,7 @@
1717
* @author Ampflower
1818
* @since 1.20.1+1.2
1919
**/
20-
public class MC8187 implements FabricGameTest {
20+
public class MC8187 {
2121
private static final String TEMPLATE = "debugify:mc-8187";
2222

2323
// Adjust this if you move the center, as the tests assume this is accurate.
@@ -36,7 +36,7 @@ public class MC8187 implements FabricGameTest {
3636
*/
3737
private static void testTreeRandomTick(GameTestHelper ctx, Block sapling, Block log, BlockPos growCorner, boolean small) {
3838
// Ensure that parameters are correct.
39-
ctx.assertTrue(sapling instanceof SaplingBlock, sapling + " is not a sapling");
39+
ctx.assertTrue(sapling instanceof SaplingBlock, Component.literal(sapling + " is not a sapling"));
4040
testTreeParamCommon(ctx, sapling, log, growCorner, true);
4141

4242
// Setup
@@ -52,7 +52,7 @@ private static void testTreeRandomTick(GameTestHelper ctx, Block sapling, Block
5252
*/
5353
private static void testTreeBonemeal(GameTestHelper ctx, Block sapling, Block log, BlockPos growCorner, boolean small) {
5454
// Ensure that parameters are correct.
55-
ctx.assertTrue(sapling instanceof SaplingBlock, sapling + " is not a sapling");
55+
ctx.assertTrue(sapling instanceof SaplingBlock, Component.literal(sapling + " is not a sapling"));
5656
testTreeParamCommon(ctx, sapling, log, growCorner, false);
5757

5858
// Setup
@@ -68,7 +68,7 @@ private static void testTreeBonemeal(GameTestHelper ctx, Block sapling, Block lo
6868
*/
6969
private static void testAzalea(GameTestHelper ctx, Block sapling, Block log, BlockPos growCorner) {
7070
// Ensure that parameters are correct.
71-
ctx.assertTrue(sapling instanceof AzaleaBlock, sapling + " is not a sapling");
71+
ctx.assertTrue(sapling instanceof AzaleaBlock, Component.literal(sapling + " is not a sapling"));
7272
testTreeParamCommon(ctx, sapling, log, growCorner, false);
7373

7474
DebugifyTestUtils.bonemealIndefinitely(ctx, growCorner);
@@ -82,9 +82,9 @@ private static void testAzalea(GameTestHelper ctx, Block sapling, Block log, Blo
8282
* This is to catch errors quickly as the input is sensitive to off by 1 errors.
8383
*/
8484
private static void testTreeParamCommon(GameTestHelper ctx, Block sapling, Block log, BlockPos growCorner, boolean requiresDay) {
85-
ctx.assertTrue(log instanceof RotatedPillarBlock, log + " does not appear like a log");
85+
ctx.assertTrue(log instanceof RotatedPillarBlock, Component.literal(log + " does not appear like a log"));
8686
ctx.assertTrue(growCorner.getY() == START_CORNER.getY(),
87-
"Incorrect Y, got " + growCorner.getY() + ", expected " + START_CORNER.getY());
87+
Component.literal("Incorrect Y, got " + growCorner.getY() + ", expected " + START_CORNER.getY()));
8888

8989
// Ensure that the structure is correctly set up.
9090
assertSuitable(ctx, requiresDay);
@@ -97,86 +97,86 @@ private static void testTreeCommon(GameTestHelper ctx, BlockState sapling, Block
9797
DebugifyTestUtils.fill(ctx, START_CORNER, END_CORNER, sapling);
9898

9999
if (small) {
100-
ctx.succeedWhen(() -> ctx.assertBlock(growCorner, block -> block == log, "Incorrect log, expected " + log));
100+
ctx.succeedWhen(() -> ctx.assertBlock(growCorner, block -> block == log, block -> Component.literal("Incorrect log, expected " + log)));
101101
} else {
102102
ctx.succeedWhen(() -> DebugifyTestUtils.assertBlockFill(ctx, START_CORNER, END_CORNER, block -> block == log,
103103
"Incorrect log, expected " + log));
104104
}
105105
}
106106

107-
@GameTest(template = TEMPLATE, batch = "daylight")
107+
@GameTest(structure = TEMPLATE, skyAccess = true)
108108
public void oak_randomTick_NW(GameTestHelper ctx) {
109109
testTreeRandomTick(ctx, Blocks.OAK_SAPLING, Blocks.OAK_LOG, START_CORNER, true);
110110
}
111111

112-
@GameTest(template = TEMPLATE, batch = "daylight")
112+
@GameTest(structure = TEMPLATE, skyAccess = true)
113113
public void birch_randomTick_NW(GameTestHelper ctx) {
114114
testTreeRandomTick(ctx, Blocks.BIRCH_SAPLING, Blocks.BIRCH_LOG, START_CORNER, true);
115115
}
116116

117-
@GameTest(template = TEMPLATE, batch = "daylight")
117+
@GameTest(structure = TEMPLATE, skyAccess = true)
118118
public void spruce_randomTick_NW(GameTestHelper ctx) {
119119
testTreeRandomTick(ctx, Blocks.SPRUCE_SAPLING, Blocks.SPRUCE_LOG, START_CORNER, false);
120120
}
121121

122-
@GameTest(template = TEMPLATE, batch = "daylight")
122+
@GameTest(structure = TEMPLATE, skyAccess = true)
123123
public void jungle_randomTick_NW(GameTestHelper ctx) {
124124
testTreeRandomTick(ctx, Blocks.JUNGLE_SAPLING, Blocks.JUNGLE_LOG, START_CORNER, false);
125125
}
126126

127-
@GameTest(template = TEMPLATE, batch = "daylight")
127+
@GameTest(structure = TEMPLATE, skyAccess = true)
128128
public void acacia_randomTick_NW(GameTestHelper ctx) {
129129
testTreeRandomTick(ctx, Blocks.ACACIA_SAPLING, Blocks.ACACIA_LOG, START_CORNER, true);
130130
}
131131

132-
@GameTest(template = TEMPLATE, batch = "daylight")
132+
@GameTest(structure = TEMPLATE, skyAccess = true)
133133
public void darkOak_randomTick_NW(GameTestHelper ctx) {
134134
testTreeRandomTick(ctx, Blocks.DARK_OAK_SAPLING, Blocks.DARK_OAK_LOG, START_CORNER, false);
135135
}
136136

137-
@GameTest(template = TEMPLATE, batch = "daylight")
137+
@GameTest(structure = TEMPLATE, skyAccess = true)
138138
public void cherry_randomTick_NW(GameTestHelper ctx) {
139139
testTreeRandomTick(ctx, Blocks.CHERRY_SAPLING, Blocks.CHERRY_LOG, START_CORNER, true);
140140
}
141141

142142

143-
@GameTest(template = TEMPLATE)
143+
@GameTest(structure = TEMPLATE)
144144
public void oak_bonemeal_NW(GameTestHelper ctx) {
145145
testTreeBonemeal(ctx, Blocks.OAK_SAPLING, Blocks.OAK_LOG, START_CORNER, true);
146146
}
147147

148-
@GameTest(template = TEMPLATE)
148+
@GameTest(structure = TEMPLATE)
149149
public void birch_bonemeal_NW(GameTestHelper ctx) {
150150
testTreeBonemeal(ctx, Blocks.BIRCH_SAPLING, Blocks.BIRCH_LOG, START_CORNER, true);
151151
}
152152

153-
@GameTest(template = TEMPLATE)
153+
@GameTest(structure = TEMPLATE)
154154
public void spruce_bonemeal_NW(GameTestHelper ctx) {
155155
testTreeBonemeal(ctx, Blocks.SPRUCE_SAPLING, Blocks.SPRUCE_LOG, START_CORNER, false);
156156
}
157157

158-
@GameTest(template = TEMPLATE)
158+
@GameTest(structure = TEMPLATE)
159159
public void jungle_bonemeal_NW(GameTestHelper ctx) {
160160
testTreeBonemeal(ctx, Blocks.JUNGLE_SAPLING, Blocks.JUNGLE_LOG, START_CORNER, false);
161161
}
162162

163-
@GameTest(template = TEMPLATE)
163+
@GameTest(structure = TEMPLATE)
164164
public void acacia_bonemeal_NW(GameTestHelper ctx) {
165165
testTreeBonemeal(ctx, Blocks.ACACIA_SAPLING, Blocks.ACACIA_LOG, START_CORNER, true);
166166
}
167167

168-
@GameTest(template = TEMPLATE)
168+
@GameTest(structure = TEMPLATE)
169169
public void darkOak_bonemeal_NW(GameTestHelper ctx) {
170170
testTreeBonemeal(ctx, Blocks.DARK_OAK_SAPLING, Blocks.DARK_OAK_LOG, START_CORNER, false);
171171
}
172172

173-
@GameTest(template = TEMPLATE)
173+
@GameTest(structure = TEMPLATE)
174174
public void cherry_bonemeal_NW(GameTestHelper ctx) {
175175
testTreeBonemeal(ctx, Blocks.CHERRY_SAPLING, Blocks.CHERRY_LOG, START_CORNER, true);
176176
}
177177

178178
// The following two needs to be special-cased.
179-
@GameTest(template = TEMPLATE)
179+
@GameTest(structure = TEMPLATE)
180180
public void azaleaNW(GameTestHelper ctx) {
181181
testAzalea(ctx, Blocks.AZALEA, Blocks.OAK_LOG, START_CORNER);
182182
}
@@ -199,6 +199,6 @@ private static void assertSuitable(GameTestHelper ctx, boolean requiresDay) {
199199
final var pos = CORNER;
200200
DebugifyTestUtils.assertBlockStateFill(ctx, pos, pos.offset(1, 0, 1), b -> b.is(BlockTags.DIRT), "Invalid template; not dirt");
201201
DebugifyTestUtils.assertBlockFill(ctx, pos.above(), pos.offset(1, 1, 1), b -> b == Blocks.AIR, "Invalid template; not air");
202-
ctx.assertBlockState(pos.offset(-1, 1, -1), b -> !b.canBeReplaced(), () -> "Invalid template; NW block not solid");
202+
ctx.assertBlockState(pos.offset(-1, 1, -1), b -> !b.canBeReplaced(), block -> Component.literal("Invalid template; NW block not solid"));
203203
}
204204
}

src/gametest/java/dev/isxander/debugify/test/suites/MC93018.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package dev.isxander.debugify.test.suites;
22

3-
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
4-
import net.minecraft.gametest.framework.GameTest;
3+
import net.fabricmc.fabric.api.gametest.v1.GameTest;
54
import net.minecraft.gametest.framework.GameTestHelper;
5+
import net.minecraft.network.chat.Component;
66
import net.minecraft.world.InteractionHand;
77
import net.minecraft.world.entity.EntityType;
88
import net.minecraft.world.entity.ai.attributes.Attributes;
9-
import net.minecraft.world.entity.animal.Wolf;
9+
import net.minecraft.world.entity.animal.wolf.Wolf;
1010
import net.minecraft.world.entity.player.Player;
1111
import net.minecraft.world.item.Items;
1212
import net.minecraft.world.level.GameType;
1313

14-
public class MC93018 implements FabricGameTest {
14+
public class MC93018 {
1515

16-
@GameTest(template = EMPTY_STRUCTURE)
16+
@GameTest
1717
public void mc93018(GameTestHelper ctx) {
1818
Player player = ctx.makeMockPlayer(GameType.SURVIVAL);
1919
player.setItemInHand(InteractionHand.MAIN_HAND, Items.BONE.getDefaultInstance());
@@ -23,7 +23,7 @@ public void mc93018(GameTestHelper ctx) {
2323
wolf.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.0);
2424

2525
wolf.mobInteract(player, InteractionHand.MAIN_HAND);
26-
ctx.succeedIf(() -> ctx.assertTrue(wolf.getInLoveTime() <= 0, "Wolf shouldn't love player"));
26+
ctx.succeedIf(() -> ctx.assertTrue(wolf.getInLoveTime() <= 0, Component.literal("Wolf shouldn't love player")));
2727
}
2828

2929

src/gametest/resources/fabric.mod.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
"environment": "*",
88
"icon": "debugify.png",
99
"entrypoints": {
10-
"main": [
11-
"dev.isxander.debugify.test.DebugifyGameTestMain"
12-
],
1310
"fabric-gametest": [
1411
"dev.isxander.debugify.test.suites.MC72151",
1512
"dev.isxander.debugify.test.suites.MC8187",

0 commit comments

Comments
 (0)