|
65 | 65 | import net.minecraft.server.v1_16_R3.CustomFunctionData;
|
66 | 66 | import net.minecraft.server.v1_16_R3.DispenserRegistry;
|
67 | 67 | import net.minecraft.server.v1_16_R3.EntityPlayer;
|
| 68 | +import net.minecraft.server.v1_16_R3.GameProfilerDisabled; |
68 | 69 | import net.minecraft.server.v1_16_R3.GameRules;
|
69 | 70 | import net.minecraft.server.v1_16_R3.IRecipe;
|
70 | 71 | import net.minecraft.server.v1_16_R3.IRegistry;
|
@@ -467,34 +468,30 @@ public <T> T getMinecraftServer() {
|
467 | 468 | // We're using 2 as the function compilation level.
|
468 | 469 | // Mockito.when(minecraftServerMock.??()).thenReturn(2);
|
469 | 470 | Mockito.when(minecraftServerMock.getFunctionData()).thenAnswer(i -> {
|
470 |
| - CustomFunctionData serverFunctionLibrary = Mockito.mock(CustomFunctionData.class); |
| 471 | + CustomFunctionData customFunctionData = Mockito.mock(CustomFunctionData.class); |
471 | 472 |
|
472 | 473 | // Functions
|
473 |
| - Mockito.when(serverFunctionLibrary.a(any(MinecraftKey.class))).thenAnswer(invocation -> Optional.ofNullable(functions.get(invocation.getArgument(0)))); |
474 |
| - Mockito.when(serverFunctionLibrary.f()).thenAnswer(invocation -> functions.keySet()); |
| 474 | + Mockito.when(customFunctionData.a(any(MinecraftKey.class))).thenAnswer(invocation -> Optional.ofNullable(functions.get(invocation.getArgument(0)))); |
| 475 | + Mockito.when(customFunctionData.f()).thenAnswer(invocation -> functions.keySet()); |
475 | 476 |
|
476 | 477 | // Tags
|
477 |
| - Mockito.when(serverFunctionLibrary.b(any())).thenAnswer(invocation -> { |
| 478 | + Mockito.when(customFunctionData.b(any())).thenAnswer(invocation -> { |
478 | 479 | Collection<CustomFunction> tagsFromResourceLocation = tags.getOrDefault(invocation.getArgument(0), List.of());
|
479 | 480 | return Tag.b(Set.copyOf(tagsFromResourceLocation));
|
480 | 481 | });
|
481 |
| - Mockito.when(serverFunctionLibrary.g()).thenAnswer(invocation -> tags.keySet()); |
482 |
| - |
483 |
| - return serverFunctionLibrary; |
484 |
| -// return new CustomFunctionManager(minecraftServerMock, serverFunctionLibrary) { |
485 |
| -// |
486 |
| -// // Make sure we don't use ServerFunctionManager#getDispatcher! |
487 |
| -// // That method accesses MinecraftServer.vanillaCommandDispatcher |
488 |
| -// // directly (boo) and that causes all sorts of nonsense. |
489 |
| -// @Override |
490 |
| -// public CommandDispatcher<CommandSourceStack> getDispatcher() { |
491 |
| -// return Brigadier.getCommandDispatcher(); |
492 |
| -// } |
493 |
| -// }; |
| 482 | + Mockito.when(customFunctionData.g()).thenAnswer(invocation -> tags.keySet()); |
| 483 | + |
| 484 | + // Command dispatcher |
| 485 | + Mockito.when(customFunctionData.getCommandDispatcher()).thenAnswer(invocation -> Brigadier.getCommandDispatcher()); |
| 486 | + |
| 487 | + // Command chain length |
| 488 | + Mockito.when(customFunctionData.b()).thenReturn(65536); |
| 489 | + |
| 490 | + return customFunctionData; |
494 | 491 | });
|
495 | 492 |
|
496 | 493 | Mockito.when(minecraftServerMock.getGameRules()).thenAnswer(i -> new GameRules());
|
497 |
| -// Mockito.when(minecraftServerMock.getMethodProfiler()).thenAnswer(i -> InactiveMetricsRecorder.INSTANCE.getProfiler()); |
| 494 | + Mockito.when(minecraftServerMock.getMethodProfiler()).thenAnswer(i -> GameProfilerDisabled.a); |
498 | 495 |
|
499 | 496 |
|
500 | 497 | return (T) minecraftServerMock;
|
|
0 commit comments