Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests only inside the worldborder #7

Open
wants to merge 1 commit into
base: 1.20
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "Lnet/minecraft/core/BlockPos;Z"))
private BlockPos startTests(BlockPos blockpos, 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, -59, z);
}
}