generated from FabricMC/fabric-example-mod
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
112 additions
and
81 deletions.
There are no files selected for viewing
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
6 changes: 3 additions & 3 deletions
6
...e/packtest/fake/FakeClientConnection.java → ...packtest/dummy/DummyClientConnection.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
30 changes: 30 additions & 0 deletions
30
src/main/java/io/github/misode/packtest/mixin/GameTestRunnerMixin.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 @@ | ||
package io.github.misode.packtest.mixin; | ||
|
||
import io.github.misode.packtest.dummy.Dummy; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.gametest.framework.GameTestRunner; | ||
import net.minecraft.gametest.framework.GameTestTicker; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.server.level.ServerLevel; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Remove all test players when running <code>/test clearall</code>. | ||
*/ | ||
@Mixin(GameTestRunner.class) | ||
public class GameTestRunnerMixin { | ||
|
||
@Inject(method = "clearAllTests", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/BlockPos;betweenClosedStream(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;)Ljava/util/stream/Stream;", shift = At.Shift.AFTER)) | ||
private static void clearTestPlayers(ServerLevel level, BlockPos pos, GameTestTicker ticker, int radius, CallbackInfo ci) { | ||
List<Dummy> testPlayers = level.getServer().getPlayerList().getPlayers().stream() | ||
.filter(p -> p instanceof Dummy && p.distanceToSqr(pos.getCenter()) <= radius) | ||
.map(p -> (Dummy)p) | ||
.toList(); | ||
testPlayers.forEach(p -> p.leave(Component.literal("Cleared tests"))); | ||
} | ||
} |
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