Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 4587902

Browse files
committed
port to the other versions
1 parent 67a05e9 commit 4587902

File tree

50 files changed

+4232
-1504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4232
-1504
lines changed

1.16_combat-6/src/main/java/io/github/axolotlclient/mixin/ScreenshotRecorderMixin.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,20 @@
2323
package io.github.axolotlclient.mixin;
2424

2525
import java.io.File;
26-
import java.util.function.Consumer;
2726

27+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
28+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
29+
import com.llamalad7.mixinextras.sugar.Local;
2830
import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils;
29-
import net.minecraft.client.texture.NativeImage;
3031
import net.minecraft.text.MutableText;
31-
import net.minecraft.text.Text;
3232
import org.spongepowered.asm.mixin.Mixin;
3333
import org.spongepowered.asm.mixin.injection.At;
34-
import org.spongepowered.asm.mixin.injection.Inject;
35-
import org.spongepowered.asm.mixin.injection.ModifyArg;
36-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3734

3835
@Mixin(net.minecraft.client.util.ScreenshotUtils.class)
3936
public abstract class ScreenshotRecorderMixin {
4037

41-
private static File currentFile;
42-
43-
@SuppressWarnings("unresolvable-target")
44-
@Inject(method = "method_1661", at = @At("HEAD"))
45-
private static void axolotlclient$getFile(NativeImage nativeImage, File file, Consumer<Text> consumer, CallbackInfo ci) {
46-
currentFile = file;
47-
}
48-
49-
@SuppressWarnings({"unchecked", "unresolvable-target"})
50-
@ModifyArg(method = "method_1661", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V"))
51-
private static <T> T axolotlclient$onScreenShotTaken(T t) {
52-
return (T) ScreenshotUtils.getInstance().onScreenshotTaken((MutableText) t, currentFile);
38+
@WrapOperation(method = "method_1661", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/TranslatableText;<init>(Ljava/lang/String;[Ljava/lang/Object;)V", ordinal = 0))
39+
private static MutableText axolotlclient$onScreenshotSaveSuccess(String s, Object[] objects, Operation<MutableText> original, @Local(argsOnly = true) File target) {
40+
return ScreenshotUtils.getInstance().onScreenshotTaken(original.call(s, objects), target);
5341
}
5442
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright © 2024 moehreag <[email protected]> & Contributors
3+
*
4+
* This file is part of AxolotlClient.
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*
20+
* For more information, see the LICENSE file.
21+
*/
22+
23+
package io.github.axolotlclient.modules.screenshotUtils;
24+
25+
import net.minecraft.client.gui.screen.Screen;
26+
import net.minecraft.client.gui.screen.ScreenTexts;
27+
import net.minecraft.client.gui.widget.ButtonWidget;
28+
import net.minecraft.client.gui.widget.TextFieldWidget;
29+
import net.minecraft.client.resource.language.I18n;
30+
import net.minecraft.client.util.math.MatrixStack;
31+
import net.minecraft.text.LiteralText;
32+
import net.minecraft.text.Text;
33+
import net.minecraft.text.TranslatableText;
34+
import net.minecraft.util.Identifier;
35+
36+
public class DownloadImageScreen extends Screen {
37+
private static final Identifier SPRITE = new Identifier("axolotlclient", "textures/gui/sprites/go.png");
38+
39+
private final Screen parent;
40+
41+
public DownloadImageScreen(Screen parent) {
42+
super(new TranslatableText("viewScreenshot"));
43+
this.parent = parent;
44+
}
45+
46+
@Override
47+
public void render(MatrixStack graphics, int mouseX, int mouseY, float delta) {
48+
renderBackground(graphics);
49+
super.render(graphics, mouseX, mouseY, delta);
50+
drawCenteredText(graphics, textRenderer, getTitle(), width / 2, 33 / 2 - textRenderer.fontHeight / 2, -1);
51+
}
52+
53+
@Override
54+
protected void init() {
55+
var urlBox = new TextFieldWidget(textRenderer, width / 2 - 100, height / 2 - 10, 200, 20, new TranslatableText("urlBox"));
56+
urlBox.setSuggestion(I18n.translate("pasteURL"));
57+
urlBox.setChangedListener(s -> {
58+
if (s.isEmpty()) {
59+
urlBox.setSuggestion(I18n.translate("pasteURL"));
60+
} else {
61+
urlBox.setSuggestion("");
62+
}
63+
});
64+
urlBox.setMaxLength(52);
65+
addButton(urlBox);
66+
addButton(new ButtonWidget(width / 2 + 100 + 4, height / 2 - 10, 20, 20, new TranslatableText("download"), b -> {
67+
String url = urlBox.getText().trim();
68+
if (url.isEmpty()) {
69+
return;
70+
}
71+
client.openScreen(ImageScreen.create(this, ImageShare.getInstance().downloadImage(url), true));
72+
}) {
73+
@Override
74+
public void renderButton(MatrixStack graphics, int mouseX, int mouseY, float delta) {
75+
Text message = getMessage();
76+
setMessage(LiteralText.EMPTY);
77+
super.renderButton(graphics, mouseX, mouseY, delta);
78+
setMessage(message);
79+
client.getTextureManager().bindTexture(SPRITE);
80+
drawTexture(graphics, x, y, 0, 0, getWidth(), getHeight(), getWidth(), getHeight());
81+
}
82+
});
83+
84+
addButton(new ButtonWidget(width / 2 - 75, height - 33 / 2, 150, 20, ScreenTexts.BACK, b -> onClose()));
85+
86+
87+
setInitialFocus(urlBox);
88+
}
89+
90+
@Override
91+
public void onClose() {
92+
client.openScreen(parent);
93+
}
94+
}

0 commit comments

Comments
 (0)