Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 42
[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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
f3757f665751e3a35ffa081a0c63ea972bec6328ca7f35a621bba65406aba2d68b24da12e20457cbfd14a130c8cbbd705f4b96556895a069ca72b9a0644c69de3bb6eb40b1aedcf244dc97a29c8e9c89c1cf9550fc91a2d52483d37fce97c48a180faf6a2c9e93d9ca82c931e09fcdc614caf939eba76adbbe522b4761489ba5a7aa51606050a66c883880f49ba36c943cd5a8393c5d60fdcd76ed41aae2f333c3de0424a10cbcb6bdd7453779becacd9818c7cccfbb1cc25ebae7bd1f2d0e9b7378283e0271784ca5066f4d1823df15eff57fd8b99d227203a030ec7e645ef231b24f180d41e3bc30ebcd24db098a10a94625ad4d519b96d0f8e2e4a79cf40b2841eea2c699346bc2d93884652f915e46179d03ee58c0d260907be071d2382abd06a2aa65432e3a8831b856ec26f72e9b52727d083a62e752bb585a1d6c19350f061c68158bbee3b9a5333d70f6f0a34f4c374662dd8bf3549992c7c377876d902a30f5751445c38a0189f74bce875218aa2d31157fc081b677de2490cb513bafa30839d150f4198b555a18d3fa997730f6f57a351b195086d7591b93a63d0a16c25f50bb7ff6b1fa3d04645bc2b803e63087ecb9c20c4aacf483efbdb2166a3b558200083d0e644e3148cb2c81f1924cfFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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(); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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