Skip to content

Commit

Permalink
force minecraft to update renderchunk immediatley
Browse files Browse the repository at this point in the history
allows tests to run as fast as the game can update and render, without waiting on async operations
  • Loading branch information
RogueLogix committed Mar 2, 2024
1 parent 5f55ca2 commit ff40153
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void runSpecificTest(String testName) {
}

private static void onTestingStatusEvent(QuartzInternalEvent.TestingStatus testingStatus) {
final var suiteName = "Quartz " + QuartzCore.INSTANCE.getClass().getSimpleName();
final var suiteName = QuartzCore.INSTANCE.getClass().getSimpleName();
if (testingStatus.running) {
failedTests.clear();
savePlayerState();
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/net/roguelogix/quartz/testing/tests/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.blaze3d.platform.NativeImage;
import net.minecraft.client.Minecraft;
import net.minecraft.client.PrioritizeChunkUpdates;
import net.minecraft.client.Screenshot;
import net.minecraft.commands.arguments.EntityAnchorArgument;
import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -57,6 +58,8 @@ public static void savePlayerState() {
windowWidth = minecraft.getWindow().getWidth();
windowHeight = minecraft.getWindow().getHeight();
minecraft.getWindow().updateVsync(false);
minecraft.getWindow().setFramerateLimit(300);
minecraft.options.prioritizeChunkUpdates().set(PrioritizeChunkUpdates.NEARBY);
}

public static void restorePlayerState() {
Expand Down Expand Up @@ -163,7 +166,8 @@ public static void setBlock(int x, int y, int z, BlockState blockState) {
public static void setBlock(BlockPos pos, BlockState blockState) {
var player = minecraft.player;
assert player != null;
player.level().setBlockAndUpdate(pos, blockState);
// normal flags and modified by player, makes double sure that the renderchunk will get updated ASAP
player.level().setBlock(pos, blockState, 11);
}

public static void setVolume(BlockPos starting, BlockPos ending, Block block) {
Expand Down

0 comments on commit ff40153

Please sign in to comment.