-
Notifications
You must be signed in to change notification settings - Fork 18
[1.20.4] Feat: New gui, texture api and buffer api #98
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
Changes from all commits
f3757f6
65751e3
a35ffa0
81a0c63
ea972be
c6328ca
7f35a62
1bba654
06aba2d
68b24da
12e2045
7cbfd14
a130c8c
bbd705f
4b96556
895a069
ca72b9a
0644c69
de3bb6e
b40b1ae
dcf244d
c97a29c
8e9c89c
1cf9550
fc91a2d
52483d3
7fce97c
48a180f
af6a2c9
e93d9ca
82c931e
09fcdc6
14caf93
9eba76a
dbbe522
b476148
9ba5a7a
a516060
50a66c8
83880f4
9ba36c9
43cd5a8
393c5d6
0fdcd76
ed41aae
2f333c3
de0424a
10cbcb6
bdd7453
779beca
cd9818c
7cccfbb
1cc25eb
ae7bd1f
2d0e9b7
378283e
0271784
ca5066f
4d1823d
f15eff5
7fd8b99
d227203
a030ec7
e645ef2
31b24f1
80d41e3
bc30ebc
d24db09
8a10a94
625ad4d
519b96d
0f8e2e4
a79cf40
b2841ee
a2c6993
46bc2d9
3884652
f915e46
179d03e
e58c0d2
60907be
071d238
2abd06a
2aa6543
2e3a883
1b856ec
26f72e9
b52727d
083a62e
752bb58
5a1d6c1
9350f06
1c68158
bbee3b9
a5333d7
0f6f0a3
4f4c374
662dd8b
f354999
2c7c377
876d902
a30f575
1445c38
a0189f7
4bce875
218aa2d
31157fc
081b677
de2490c
b513baf
a30839d
150f419
8b555a1
8d3fa99
7730f6f
57a351b
195086d
7591b93
a63d0a1
6c25f50
bb7ff6b
1fa3d04
645bc2b
803e630
87ecb9c
20c4aac
f483efb
db2166a
3b55820
0083d0e
644e314
8cb2c81
f1924cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * Copyright 2025 Lambda | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.lambda.mixin.render; | ||
|
|
||
| import com.lambda.module.modules.client.LambdaMoji; | ||
| import net.minecraft.client.font.TextRenderer; | ||
| import net.minecraft.client.gui.DrawContext; | ||
| import net.minecraft.client.gui.hud.ChatHud; | ||
| import net.minecraft.text.OrderedText; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
|
||
| @Mixin(ChatHud.class) | ||
| public class ChatHudMixin { | ||
| @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTextWithShadow(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/OrderedText;III)I")) | ||
| int redirectRenderCall(DrawContext instance, TextRenderer textRenderer, OrderedText text, int x, int y, int color) { | ||
| return instance.drawTextWithShadow(textRenderer, LambdaMoji.INSTANCE.parse(text, x, y, color), 0, y, 16777215 + (color << 24)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,64 @@ | ||||||||||||||||||||||
| /* | ||||||||||||||||||||||
| * Copyright 2025 Lambda | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||
| * it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||
| * the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||
| * (at your option) any later version. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||
| * GNU General Public License for more details. | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * You should have received a copy of the GNU General Public License | ||||||||||||||||||||||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| package com.lambda.mixin.render; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import com.lambda.Lambda; | ||||||||||||||||||||||
| import com.lambda.module.modules.render.MapPreview; | ||||||||||||||||||||||
| import net.minecraft.client.MinecraftClient; | ||||||||||||||||||||||
| import net.minecraft.client.font.TextRenderer; | ||||||||||||||||||||||
| import net.minecraft.client.gui.DrawContext; | ||||||||||||||||||||||
| import net.minecraft.client.gui.screen.Screen; | ||||||||||||||||||||||
| import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||||||||||||||||||||||
| import net.minecraft.client.gui.tooltip.HoveredTooltipPositioner; | ||||||||||||||||||||||
| import net.minecraft.client.gui.tooltip.TooltipBackgroundRenderer; | ||||||||||||||||||||||
| import net.minecraft.client.gui.tooltip.TooltipComponent; | ||||||||||||||||||||||
| import net.minecraft.client.gui.tooltip.TooltipPositioner; | ||||||||||||||||||||||
| import net.minecraft.client.item.TooltipData; | ||||||||||||||||||||||
| import net.minecraft.item.ItemStack; | ||||||||||||||||||||||
| import net.minecraft.item.Items; | ||||||||||||||||||||||
| import net.minecraft.text.Text; | ||||||||||||||||||||||
| import org.spongepowered.asm.mixin.Final; | ||||||||||||||||||||||
| import org.spongepowered.asm.mixin.Mixin; | ||||||||||||||||||||||
| import org.spongepowered.asm.mixin.Shadow; | ||||||||||||||||||||||
| import org.spongepowered.asm.mixin.injection.At; | ||||||||||||||||||||||
| import org.spongepowered.asm.mixin.injection.Inject; | ||||||||||||||||||||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||
| import java.util.Optional; | ||||||||||||||||||||||
| import java.util.stream.Collectors; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Mixin(DrawContext.class) | ||||||||||||||||||||||
| public abstract class DrawContextMixin { | ||||||||||||||||||||||
| @Shadow protected abstract void drawTooltip(TextRenderer textRenderer, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Inject(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;Ljava/util/Optional;II)V", at = @At("HEAD"), cancellable = true) | ||||||||||||||||||||||
| void drawItemTooltip(TextRenderer textRenderer, List<Text> text, Optional<TooltipData> data, int x, int y, CallbackInfo ci) { | ||||||||||||||||||||||
| List<TooltipComponent> list = text.stream().map(Text::asOrderedText).map(TooltipComponent::of).collect(Collectors.toList()); | ||||||||||||||||||||||
| data.ifPresent(datax -> list.add(1, TooltipComponent.of(datax))); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var screen = (HandledScreen) Lambda.getMc().currentScreen; | ||||||||||||||||||||||
| if (screen.focusedSlot != null) { | ||||||||||||||||||||||
| var stack = screen.focusedSlot.getStack(); | ||||||||||||||||||||||
| if (stack.isOf(Items.FILLED_MAP)) list.add(1, new MapPreview.MapComponent(stack)); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+55
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null check before casting screen. The current implementation assumes the current screen is always a HandledScreen, which could lead to ClassCastException. - var screen = (HandledScreen) Lambda.getMc().currentScreen;
- if (screen.focusedSlot != null) {
+ Screen currentScreen = Lambda.getMc().currentScreen;
+ if (currentScreen instanceof HandledScreen screen && screen.focusedSlot != null) {
var stack = screen.focusedSlot.getStack();
if (stack.isOf(Items.FILLED_MAP)) list.add(1, new MapPreview.MapComponent(stack));
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| drawTooltip(textRenderer, list, x, y, HoveredTooltipPositioner.INSTANCE); | ||||||||||||||||||||||
| ci.cancel(); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add safeguards for async suggestion handling.
The current implementation has a potential race condition where pendingSuggestions might be modified between the check and usage.
📝 Committable suggestion