Fixed issue with inconsistent building speed

This commit is contained in:
Harry Zhou 2023-03-14 23:38:49 -05:00
parent e268118264
commit 6e469552c5
2 changed files with 8 additions and 6 deletions

View file

@ -16,7 +16,7 @@ public class MinecraftClientMixin {
@Inject(at = @At("HEAD"), method = "render(Z)V")
public void onRender(boolean tick, CallbackInfo ci) {
if (SongPlayer.MC.world != null && SongPlayer.MC.player != null && SongPlayer.MC.interactionManager != null) {
SongHandler.getInstance().onRenderIngame(tick);
SongHandler.getInstance().onUpdate(false);
} else {
SongHandler.getInstance().onNotIngame();
}
@ -24,6 +24,9 @@ public class MinecraftClientMixin {
@Inject(at = @At("HEAD"), method = "tick()V")
public void onTick(CallbackInfo ci) {
if (SongPlayer.MC.world != null && SongPlayer.MC.player != null && SongPlayer.MC.interactionManager != null) {
SongHandler.getInstance().onUpdate(true);
}
ProgressDisplay.getInstance().onTick();
}
}

View file

@ -38,7 +38,7 @@ public class SongHandler {
public Stage stage = null;
public boolean building = false;
public void onRenderIngame(boolean tick) {
public void onUpdate(boolean tick) {
if (currentSong == null && songQueue.size() > 0) {
setSong(songQueue.poll());
}
@ -85,7 +85,6 @@ public class SongHandler {
handleBuilding();
}
} else {
// Check if stage was broken
handlePlaying(tick);
}
}
@ -153,7 +152,7 @@ public class SongHandler {
BlockPos bp = stage.requiredBreaks.poll();
SongPlayer.MC.interactionManager.attackBlock(bp, Direction.UP);
}
buildEndDelay = 40;
buildEndDelay = 20;
return;
} else if (!stage.missingNotes.isEmpty()) {
int desiredNoteId = stage.missingNotes.pollFirst();
@ -170,8 +169,8 @@ public class SongHandler {
}
placeBlock(bp);
}
buildCooldown = 4;
buildEndDelay = 40;
buildCooldown = 0; // No cooldown, so it places a block every tick
buildEndDelay = 20;
} else {
building = false;
setSurvivalIfNeeded();