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

Advancement screenshot module (request by vico) #56

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.github.protonmc.proton.mixin.client;

import io.github.protonmc.proton.Proton;
import io.github.protonmc.proton.base.annotation.FromModule;
import io.github.protonmc.proton.base.module.ModuleManager;
import io.github.protonmc.proton.module.client.AdvancementScreenshot;
import net.minecraft.advancement.Advancement;
import net.minecraft.advancement.PlayerAdvancementTracker;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.ScreenshotUtils;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(PlayerAdvancementTracker.class)
public abstract class PlayerAdvancementTrackerMixin {
@Inject(method = "grantCriterion(Lnet/minecraft/advancement/Advancement;Ljava/lang/String;)Z",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/advancement/PlayerAdvancementTracker;updateDisplay(Lnet/minecraft/advancement/Advancement;)V",
shift = At.Shift.AFTER))
@FromModule(AdvancementScreenshot.class)
private void screenshot(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> cir) {
if (ModuleManager.getInstance().isModuleEnabled(AdvancementScreenshot.class)) {
MinecraftClient client = MinecraftClient.getInstance();
ScreenshotUtils.saveScreenshot(
client.runDirectory,
client.getWindow().getFramebufferWidth(),
client.getWindow().getFramebufferHeight(),
client.getFramebuffer(),
text -> {
}
);
Proton.LOGGER.debug("Screenshot taken");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.github.protonmc.proton.module.client;

import io.github.protonmc.proton.Proton;
import io.github.protonmc.proton.base.module.ProtonModule;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

@Environment(EnvType.CLIENT)
public class AdvancementScreenshot extends ProtonModule {
public AdvancementScreenshot() {
super(Proton.identifier("advancement_screenshot"));
}
}
2 changes: 2 additions & 0 deletions src/main/resources/proton.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"client.entities.ChickenRendererMixin",
"client.entities.CowRendererMixin",
"client.entities.LivingEntityRendererMixin",
"client.entities.PigRendererMixin",
"client.PlayerAdvancementTrackerMixin"
"client.entities.LlamaRendererMixin",
"client.entities.PigRendererMixin",
"client.entities.RabbitRendererMixin"
Expand Down