-
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.
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
------------------------------------------------------ | ||
Version 0.1.1 | ||
------------------------------------------------------ | ||
**Additions** | ||
- Added a helper method for spawning server players | ||
|
||
------------------------------------------------------ | ||
Version 0.1.0 | ||
------------------------------------------------------ | ||
Initial release | ||
|
||
**Additions** | ||
- Fix for test cases that are run multiple times |
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
23 changes: 23 additions & 0 deletions
23
src/main/java/io/github/ladysnake/elmendorf/GameTestUtil.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,23 @@ | ||
package io.github.ladysnake.elmendorf; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.test.GameTestException; | ||
import net.minecraft.test.TestContext; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
import java.util.UUID; | ||
|
||
public final class GameTestUtil { | ||
public static void assertTrue(boolean b, String errorMessage) { | ||
if (!b) throw new GameTestException(errorMessage); | ||
} | ||
|
||
public static ServerPlayerEntity spawnPlayer(TestContext ctx, double x, double y, double z) { | ||
ServerPlayerEntity mockPlayer = new ServerPlayerEntity(ctx.getWorld().getServer(), ctx.getWorld(), new GameProfile(UUID.randomUUID(), "test-mock-player")); | ||
Vec3d vec3d = ctx.getAbsolute(new Vec3d(x, y, z)); | ||
mockPlayer.refreshPositionAndAngles(vec3d.x, vec3d.y, vec3d.z, mockPlayer.getYaw(), mockPlayer.getPitch()); | ||
ctx.getWorld().spawnEntity(mockPlayer); | ||
return mockPlayer; | ||
} | ||
} |