Skip to content

Commit

Permalink
Run tests only inside the worldborder (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiome authored Sep 27, 2024
1 parent 9b7b8d5 commit cefd92f
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import io.github.misode.packtest.LoadDiagnostics;
import io.github.misode.packtest.PackTest;
import net.minecraft.core.BlockPos;
import net.minecraft.gametest.framework.*;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.border.WorldBorder;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final;
Expand Down Expand Up @@ -70,4 +73,12 @@ private int onServerExit(int original) {
}
return original + LoadDiagnostics.loadErrors().size();
}

@ModifyExpressionValue(method = "startTests", at = @At(value = "NEW", target = "(III)Lnet/minecraft/core/BlockPos;"))
private BlockPos startTests(BlockPos original, ServerLevel level) {
WorldBorder border = level.getWorldBorder();
int x = level.random.nextIntBetweenInclusive((int) border.getMinX(), (int) border.getMaxX());
int z = level.random.nextIntBetweenInclusive((int) border.getMinZ(), (int) border.getMaxZ());
return new BlockPos(x, original.getY(), z);
}
}

0 comments on commit cefd92f

Please sign in to comment.