PackTest

PackTest

Fabric mod for testing data packs, with data packs!

von
14.7K Downloads
fabricmanagementutility
Server mit dieser Mod mieten

Screenshots

Test results with messages
The code for a test
Test code using a structure template

Über diese Mod

PackTest

PackTest allows you to write game tests in a data pack. Tests are *.mcfunction files in a test folder. They can be used to test custom data packs.

Example

data/example/test/foo.mcfunction

#> Summons an armor stand and finds it
# @template example:small_platform
# @optional

summon armor_stand ~1.5 ~1 ~1.5
execute positioned ~1.5 ~1 ~1.5 run assert entity @e[type=armor_stand,dx=0]

assert predicate example:test

setblock ~1 ~1 ~1 grass_block
execute if block ~1 ~1 ~1 stone run succeed

fail "Oh no"

Async tests

Test functions can be asynchronous, using the await keyword!

setblock ~ ~ ~ stone
summon item ~ ~6 ~

await entity @e[type=item,distance=..2]

await delay 1s

data merge entity @e[type=item,distance=..2,limit=1] {Motion: [0.0, 0.01, 0.0]}

Running tests

Tests can be run in-game using the test command.

  • test runall: runs all the tests
  • test runall <namespace>: runs all tests from a specified namespace
  • test run <test>: runs the test with a specified name
  • test runfailed: runs all the previously failed tests
  • test runthis: runs the closes test
  • test runthese: runs all tests within 200 blocks

Auto test server

Tests can also be run automatically, for instance in a CI environment. When -Dpacktest.auto is set, the game test server will start automatically with the loaded tests. The process will exit when all tests have finished with the exist code set to the number of failed tests.

Setting -Dpacktest.auto.annotations will emit GitHub annotations for all test failures and resource load errors.

The following example can be adapted into a GitHub action workflow.

on: [push, pull_request]

env:
  # Make sure to update these links!
  TEST_FABRIC_SERVER: https://meta.fabricmc.net/v2/versions/loader/1.20.4/0.15.3/0.11.2/server/jar
  TEST_FABRIC_API: https://cdn.modrinth.com/data/P7dR8mSH/versions/JMCwDuki/fabric-api-0.92.0%2B1.20.4.jar
  TEST_PACKTEST: https://cdn.modrinth.com/data/XsKUhp45/versions/18smpIeE/packtest-1.6-mc1.20.4.jar

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: '17'
      - name: Download and prepare files
        run: |
          curl -o server.jar $TEST_FABRIC_SERVER
          mkdir mods
          curl -o mods/fabric-api.jar $TEST_FABRIC_API
          curl -o mods/packtest.jar $TEST_PACKTEST
          mkdir -p world/datapacks
          cp -r datapack world/datapacks/datapack
      - name: Run tests
        run: |
          java -Xmx2G -Dpacktest.auto -Dpacktest.auto.annotations -jar server.jar nogui

Commands

fail

  • fail <text component>: fails the current test and returns from the function

succeed

  • succeed: always succeeds the current test and returns from the function

assert

  • assert <condition>: if condition is unsuccessful, fails the current test and returns from the function
  • assert not <condition>: if condition is successful, fails the current test and returns from the function

await

  • await <condition>: similar to assert, but keeps trying the condition every tick until the test times our or the condition succeeds
  • await not <condition>: keeps trying the condition until it fails
  • await delay <time>: waits for a specified time with unit

Conditions

  • block <pos> <block>: checks if the block at the specified position matches the block predicate
  • data ...: checks NBT data using the same syntax as execute if score
  • entity <selector>: checks if the selector matches any entity (can also find entities outside the structure bounds)
  • predicate <predicate>: checks a predicate in a data pack
  • score ...: checks scores using the same syntax as execute if score
  • chat <pattern> [<receivers>]: checks whether a chat message was sent in the past tick matching a regex pattern

Dummies

Fake players can be spawned using the /dummy command. Dummies won't save or load their data from disk, they will also not load their skin.

  • dummy <name> spawn: spawns a new dummy
  • dummy <name> respawn: respawns the dummy after it has been killed
  • dummy <name> leave: makes the dummy leave the server
  • dummy <name> jump: makes the dummy jump, if currently on ground
  • dummy <name> sneak [true|false]: makes the dummy hold shift or un-shift (not the same as currently crouching)
  • dummy <name> sprint [true|false]: makes the dummy sprint or un-sprint
  • dummy <name> drop [all]: makes the dummy drop the current mainhand, either one item or the entire stack
  • dummy <name> swap: makes the dummy swap its mainhand and offhand
  • dummy <name> selectslot: makes the dummy select a different hotbar slot
  • dummy <name> use item: makes the dummy use its hand item, either mainhand or offhand
  • dummy <name> use block <pos> [<direction>]: makes the dummy use its hand item on a block position
  • dummy <name> use entity <entity>: makes the dummy use its hand item on an entity
  • dummy <name> attack <entity>: makes the dummy attack an entity with its mainhand
  • dummy <name> mine <pos>: makes the dummy mine a block

Directives

Tests can be customized by placing certain directives as special comments at the start of the test function.

  • @template: the resource location of a structure template to use for the test, defaults to an empty 1x1x1 structure
  • @timeout: an integer specifying the timeout, defaults to 100
  • @optional: whether this test is allowed to fail, defaults to false, if there is no value after the directive it is considered as true
  • @dummy: whether to spawn a dummy at the start of the test and set @s to this dummy, taking a position which defaults to ~0.5 ~ ~0.5
  • @batch: the batch name for this test, defaults to packtestBatch
  • @beforebatch: a command to run before this batch, there can only be one per batch
  • @afterbatch: a command to run after this batch, there can only be one per batch

Verfügbare Versionen

PackTest 2.6.0release
MC 26.2fabric
15. August 2026
PackTest 2.5.0release
MC 26.1, 26.1.1, 26.1.2fabric
4. April 2026
PackTest 2.4.0release
MC 1.21.11fabric
5. Februar 2026
PackTest v2.3release
MC 1.21.9, 1.21.10fabric
5. Dezember 2025
PackTest v2.2release
MC 1.21.6, 1.21.7, 1.21.8fabric
1. Juli 2025

PackTest auf dem Server installieren

1

Server bestellen

Bestelle einen Minecraft Java Server mit mindestens 3 GB RAM (4 GB empfohlen).

2

fabric Loader setzen

Wähle im Panel unter "Egg" den fabric-Loader und die passende Minecraft-Version (26.2).

3

Mod installieren

Öffne den Mod-Browser im Dashboard und suche nach "PackTest". Klicke "Installieren" – fertig! Alternativ: Lade die .jar via SFTP in den /mods Ordner.

Kompatibilität

Mod-Loader

fabric

Minecraft-Versionen

26.2, 26.2-rc-2, 26.1.2 (+27 weitere)

Server-seitig

Erforderlich

Empfohlener RAM

4 GB(min. 3 GB)

Häufige Fragen

PackTest Server crasht beim Start – was tun?

Häufigste Ursache: falsche fabric-Version oder zu wenig RAM. Prüfe im Server-Log (latest.log), ob ein "OutOfMemoryError" oder "Mixin"-Fehler auftritt. Bei Mado Hosting: Stelle sicher, dass mindestens 3 GB RAM zugewiesen sind und der Loader zur Mod-Version passt (26.2). Über das Panel kannst du den Loader mit einem Klick wechseln.

Ist PackTest mit fabric kompatibel?

PackTest unterstützt offiziell fabric für Minecraft 26.2, 26.2-rc-2, 26.1.2. Im Mado Dashboard werden inkompatible Loader-Kombinationen automatisch erkannt.

Server laggt mit PackTest – wie optimiere ich die Performance?

Empfohlener RAM: 4 GB (+1 GB pro 8 Spieler). Prüfe mit /spark profiler, ob PackTest den meisten Tick-Time verbraucht. Häufige Fixes: Server-View-Distance auf 8-10 reduzieren, bei Forge "performant" oder "starlight" als Zusatz-Mod installieren. Bei Mado Hosting läuft dein Server auf NVMe-SSDs mit dedizierten CPU-Kernen für minimale Latenz.

Modded Server mieten

Installiere PackTest mit nur einem Klick auf deinem Server.

Empfohlener RAM
4 GBab €5.2/Monat
Min. 3 GB | +1 GB pro 8 Spieler
Jetzt Server erstellen
1-Klick Mod Installation
NVMe SSD Speicher
DDoS-Schutz inklusive

Details

Lizenz
MIT License
Server-seitig
Erforderlich

Unterstützte Versionen

26.226.2-rc-226.1.226.1.126.126.1-snapshot-61.21.111.21.11-rc21.21.101.21.9+20 mehr