2424import net .minecraft .core .Direction ;
2525import net .minecraft .core .MappedRegistry ;
2626import net .minecraft .core .registries .BuiltInRegistries ;
27+ import net .minecraft .gametest .framework .GameTestAssertPosException ;
2728import net .minecraft .gametest .framework .GameTestHelper ;
2829import net .minecraft .network .chat .MutableComponent ;
2930import net .minecraft .world .item .ItemStack ;
@@ -112,7 +113,7 @@ public static boolean areItemStacksEqual(List<ItemStack> stack1, List<ItemStack>
112113 * @return {@code true} if fluids and amounts are equal
113114 */
114115 public static boolean isFluidStackEqual (FluidStack stack1 , FluidStack stack2 ) {
115- return stack1 . isFluidEqual ( stack2 ) && stack1 .getAmount () == stack2 .getAmount ();
116+ return FluidStack . isSameFluid ( stack1 , stack2 ) && stack1 .getAmount () == stack2 .getAmount ();
116117 }
117118
118119 /**
@@ -121,7 +122,7 @@ public static boolean isFluidStackEqual(FluidStack stack1, FluidStack stack2) {
121122 * @return {@code true} if items are equal, and if stack2's amount is within range.
122123 */
123124 public static boolean isFluidStackWithinRange (FluidStack stack1 , FluidStack stack2 , int min , int max ) {
124- return stack1 . isFluidEqual ( stack2 ) && isFluidWithinRange (stack2 , min , max );
125+ return FluidStack . isSameFluid ( stack1 , stack2 ) && isFluidWithinRange (stack2 , min , max );
125126 }
126127
127128 /**
@@ -271,10 +272,10 @@ public static void assertEqual(GameTestHelper helper, ItemStack stack1, ItemStac
271272 }
272273
273274 public static void assertEqual (GameTestHelper helper , FluidStack stack1 , FluidStack stack2 ) {
274- helper .assertTrue (stack1 . isFluidStackIdentical ( stack2 ),
275+ helper .assertTrue (FluidStack . matches ( stack1 , stack2 ),
275276 "Fluid stacks not equal: \" %s %d\" != \" %s %d\" " .formatted (
276- stack1 .getDisplayName ().getString (), stack1 .getAmount (),
277- stack2 .getDisplayName ().getString (), stack2 .getAmount ()));
277+ stack1 .getHoverName ().getString (), stack1 .getAmount (),
278+ stack2 .getHoverName ().getString (), stack2 .getAmount ()));
278279 }
279280
280281 public static void assertLampOn (GameTestHelper helper , BlockPos pos ) {
@@ -317,4 +318,31 @@ public static void succeedAfterTest(GameTestHelper helper, long timeout) {
317318 public static void assertEqual (GameTestHelper helper , @ Nullable BlockPos pos1 , @ Nullable BlockPos pos2 ) {
318319 helper .assertTrue (pos1 != null && pos1 .equals (pos2 ), "Expected %s to equal to %s" .formatted (pos1 , pos2 ));
319320 }
321+
322+ public static void assertRedstone (GameTestHelper helper , BlockPos pos , int min , int max ) {
323+ BlockPos absolutePos = helper .absolutePos (pos );
324+ int strength = helper .getLevel ().getBestNeighborSignal (absolutePos );
325+ if (strength > max || strength < min ) {
326+ throw new GameTestAssertPosException (
327+ "Expected redstone signal between %d and %d, got %d" .formatted (min , max , strength ),
328+ absolutePos , pos , helper .getTick ());
329+ }
330+ }
331+
332+ public static void assertRedstoneEither (GameTestHelper helper , BlockPos pos , int ... values ) {
333+ BlockPos absolutePos = helper .absolutePos (pos );
334+ int strength = helper .getLevel ().getBestNeighborSignal (absolutePos );
335+ boolean pass = false ;
336+ for (int i : values ) {
337+ if (i == strength ) {
338+ pass = true ;
339+ break ;
340+ }
341+ }
342+ if (!pass ) {
343+ throw new GameTestAssertPosException (
344+ "Expected redstone signal to be one of %s, got %d" .formatted (values , strength ),
345+ absolutePos , pos , helper .getTick ());
346+ }
347+ }
320348}
0 commit comments