Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
f3757f6
Global toggle sounds
bladekt Aug 8, 2024
65751e3
Tickshift improvements
bladekt Aug 10, 2024
a35ffa0
Merge branch 'master' into feature/renderer
emyfops Aug 20, 2024
81a0c63
various performance tweaks (3x faster load time)
emyfops Aug 21, 2024
ea972be
todo: pixel buffer object
emyfops Aug 22, 2024
c6328ca
pixel n-buffer object
emyfops Aug 22, 2024
7f35a62
handle empty pbos
emyfops Aug 22, 2024
1bba654
test: streaming to pbo
emyfops Aug 23, 2024
06aba2d
added upload record time
emyfops Aug 24, 2024
68b24da
added debug gremedy labels
emyfops Aug 24, 2024
12e2045
better pbo
emyfops Aug 24, 2024
7cbfd14
better handling
emyfops Aug 24, 2024
a130c8c
removed videos
emyfops Aug 24, 2024
bbd705f
added documentation for pbo
emyfops Aug 24, 2024
4b96556
moved the fbo down one level
emyfops Aug 24, 2024
895a069
removed loader phase time measure
emyfops Aug 24, 2024
ca72b9a
Merge branch 'master' into feature/renderer
emyfops Aug 24, 2024
0644c69
Update build.gradle.kts
emyfops Aug 24, 2024
de3bb6e
TickEvent KDocs
Avanatiker Aug 25, 2024
b40b1ae
Smol refac
Avanatiker Aug 25, 2024
dcf244d
Better logging and remove texture settings
Avanatiker Aug 25, 2024
c97a29c
Introduce constants for texture options
Avanatiker Aug 25, 2024
8e9c89c
Layouts, dsl builders
bladekt Sep 14, 2024
1cf9550
Simple window, text fields
bladekt Sep 15, 2024
fc91a2d
Interaction passthrough changes
bladekt Sep 15, 2024
52483d3
UI Alignment
bladekt Sep 22, 2024
7fce97c
Merge branch 'master' into refactor/ui
emyfops Sep 22, 2024
48a180f
Window content layout
bladekt Sep 29, 2024
af6a2c9
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Sep 29, 2024
e93d9ca
Window resizing
bladekt Sep 29, 2024
82c931e
Cursor system
bladekt Sep 29, 2024
09fcdc6
Window minimization, api changes
bladekt Sep 30, 2024
14caf93
Corrected scissor usage
bladekt Sep 30, 2024
9eba76a
Titlebar changes, shadow under it
bladekt Sep 30, 2024
dbbe522
Windows design
bladekt Oct 1, 2024
b476148
Massive gc troll fix, rect/outline/font layouts, simple module buttons
bladekt Oct 1, 2024
9ba5a7a
Nullsafety on tag sets
Avanatiker Oct 2, 2024
a516060
many misc things
bladekt Oct 7, 2024
50a66c8
null safety
bladekt Oct 7, 2024
83880f4
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Oct 7, 2024
9ba36c9
Re-added tag null safety
bladekt Oct 7, 2024
43cd5a8
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Oct 7, 2024
393c5d6
misc changes
bladekt Oct 19, 2024
0fdcd76
added text alignment, simple boolean button
bladekt Nov 5, 2024
ed41aae
Abstract setting layout
bladekt Nov 6, 2024
2f333c3
fix: wrong refied type input
emyfops Nov 6, 2024
de0424a
Merge branch 'master' into refactor/ui
emyfops Nov 6, 2024
10cbcb6
copyright
emyfops Nov 6, 2024
bdd7453
copyright
emyfops Nov 6, 2024
779beca
Boolean button
bladekt Nov 12, 2024
cd9818c
feat: lambdamoji
emyfops Nov 15, 2024
7cccfbb
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Nov 27, 2024
1cc25eb
Merge branch 'master' into refactor/ui
emyfops Nov 27, 2024
ae7bd1f
fixed mouse utils
emyfops Nov 27, 2024
2d0e9b7
refactor: global texture atlas
emyfops Dec 6, 2024
378283e
example
emyfops Dec 6, 2024
0271784
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Dec 7, 2024
ca5066f
fixed wrong example
emyfops Dec 7, 2024
4d1823d
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Dec 8, 2024
f15eff5
better texture handlers and fixed slots
emyfops Dec 14, 2024
7fd8b99
renamed to TextureOwner
emyfops Dec 14, 2024
d227203
fix: order of execution
emyfops Dec 14, 2024
a030ec7
removed useless bind
emyfops Dec 14, 2024
e645ef2
ref: typealias LambdaResource
emyfops Dec 14, 2024
31b24f1
feat: gif renderer
emyfops Dec 15, 2024
80d41e3
ref: common buffer class
emyfops Dec 15, 2024
bc30ebc
fix: immutable storage GL_DYNAMIC_STORAGE_BIT bit
emyfops Dec 15, 2024
d24db09
IBuffer -> Buffer
emyfops Dec 15, 2024
8a10a94
Merge branch 'master' into refactor/ui
emyfops Dec 15, 2024
625ad4d
Update LambdaMoji.kt
emyfops Dec 15, 2024
519b96d
Update LambdaScreen.kt
emyfops Dec 15, 2024
0f8e2e4
RenderPipeline(raw)
blade1234567 Dec 20, 2024
a79cf40
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
blade1234567 Dec 20, 2024
b2841ee
refactored animated texture
emyfops Dec 21, 2024
a2c6993
consistency flag and better texture documentation
emyfops Dec 21, 2024
46bc2d9
don't force texture consistency in gif
emyfops Dec 21, 2024
3884652
fixed incomplete merge conflicts
emyfops Dec 21, 2024
f915e46
support return lines
emyfops Dec 22, 2024
179d03e
make emojis fade with the text box
emyfops Dec 23, 2024
e58c0d2
quick fix
blade1234567 Dec 23, 2024
60907be
added checks and dimension properties
emyfops Dec 28, 2024
071d238
fixed the checks
emyfops Dec 28, 2024
2abd06a
make the pbo use the texture correctly
emyfops Dec 28, 2024
2aa6543
font sdf and shit (in progress)
blade1234567 Dec 30, 2024
2e3a883
ref: textures
emyfops Dec 31, 2024
1b856ec
better mipmap handling
emyfops Dec 31, 2024
26f72e9
pbo doc
emyfops Dec 31, 2024
b52727d
moved the texture options before the tex call
emyfops Dec 31, 2024
083a62e
removed bytearray upload to buffers
emyfops Jan 10, 2025
752bb58
ref: texture api
emyfops Jan 10, 2025
5a1d6c1
feat: map preview
emyfops Jan 10, 2025
9350f06
removed test pbo call
emyfops Jan 10, 2025
1c68158
map gl format to native format
emyfops Jan 10, 2025
bbee3b9
add luminance mapping
emyfops Jan 10, 2025
a5333d7
internal format texture api
emyfops Jan 11, 2025
0f6f0a3
removed handled screen mixin
emyfops Jan 11, 2025
4f4c374
feat: map preview
emyfops Jan 11, 2025
662dd8b
fixed map scale
emyfops Jan 11, 2025
f354999
ref: texture class
emyfops Jan 11, 2025
2c7c377
centered the map tooltip
emyfops Jan 11, 2025
876d902
Merge branch 'master' into refactor/ui
Avanatiker Jan 16, 2025
a30f575
Resolve merge conflicts
Avanatiker Jan 16, 2025
1445c38
Merge branch 'master' into refactor/ui
emyfops Jan 25, 2025
a0189f7
MapDownloader module
emyfops Jan 25, 2025
4bce875
Working immediate mode ui
blade1234567 Feb 11, 2025
218aa2d
Frogor to enable scissors back
blade1234567 Feb 11, 2025
31157fc
Fixed styled minecraft texts being blank
emyfops Feb 14, 2025
081b677
misc ui changes
Blade-kt Feb 18, 2025
de2490c
Fix: font renderer width issue
Blade-kt Feb 19, 2025
b513baf
Fancy design
Blade-kt Feb 21, 2025
a30839d
Various opengl related comments
emyfops Feb 22, 2025
150f419
opengl spam fix
Blade-kt Feb 22, 2025
8b555a1
Animatio & Refactio
Blade-kt Feb 28, 2025
8d3fa99
Enum setting
Blade-kt Feb 28, 2025
7730f6f
Optimized layout positioning
Blade-kt Feb 28, 2025
57a351b
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
Blade-kt Feb 28, 2025
195086d
Removed texture compression
emyfops Mar 7, 2025
7591b93
Added function button
emyfops Mar 9, 2025
a63d0a1
Sliders & much stuff
Blade-kt Mar 9, 2025
6c25f50
Fix floating point errors for float settings
Avanatiker Mar 9, 2025
bb7ff6b
Remove unused functions
Avanatiker Mar 9, 2025
1fa3d04
SDF settings
Blade-kt Mar 10, 2025
645bc2b
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
Blade-kt Mar 10, 2025
803e630
Show units for numeric settings
Avanatiker Mar 11, 2025
87ecb9c
Module List
Avanatiker Mar 11, 2025
20c4aac
Fixed sdf for emojis
Blade-kt Mar 11, 2025
f483efb
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
Blade-kt Mar 11, 2025
db2166a
Merge remote-tracking branch 'origin/master' into refactor/ui
Avanatiker Mar 11, 2025
3b55820
Remove unused access widener
Avanatiker Mar 11, 2025
0083d0e
Disable chat verification toast
Avanatiker Mar 11, 2025
644e314
Close UI on keybind
Avanatiker Mar 11, 2025
8cb2c81
Add KeybindPicker
Avanatiker Mar 11, 2025
f1924cf
Keybind setting picker
Blade-kt Mar 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@

import com.lambda.event.EventFlow;
import com.lambda.event.events.InventoryEvent;
import com.lambda.module.modules.render.NoRender;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
import net.minecraft.network.packet.s2c.play.UpdateSelectedSlotS2CPacket;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientPlayNetworkHandler.class)
Expand All @@ -38,4 +40,9 @@ private void onUpdateSelectedSlot(UpdateSelectedSlotS2CPacket packet, CallbackIn
private void onScreenHandlerSlotUpdate(ScreenHandlerSlotUpdateS2CPacket packet, CallbackInfo ci) {
EventFlow.post(new InventoryEvent.SlotUpdate(packet.getSyncId(), packet.getRevision(), packet.getSlot(), packet.getStack()));
}

@Redirect(method = "onServerMetadata", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;displayedUnsecureChatWarning:Z", ordinal = 0))
public boolean onServerMetadata(ClientPlayNetworkHandler clientPlayNetworkHandler) {
return NoRender.getNoChatVerificationToast();
}
}
35 changes: 35 additions & 0 deletions common/src/main/java/com/lambda/mixin/render/ChatHudMixin.java
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
Expand Up @@ -17,26 +17,47 @@

package com.lambda.mixin.render;

import com.google.common.base.Strings;
import com.lambda.command.CommandManager;
import com.lambda.graphics.renderer.gui.font.core.LambdaAtlas;
import com.lambda.module.modules.client.LambdaMoji;
import com.lambda.module.modules.client.RenderSettings;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.client.gui.screen.ChatInputSuggestor;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.command.CommandSource;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.concurrent.CompletableFuture;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

@Mixin(ChatInputSuggestor.class)
public class ChatInputSuggestorMixin {
public abstract class ChatInputSuggestorMixin {

@Shadow
@Final
TextFieldWidget textField;

@Shadow
private @Nullable CompletableFuture<Suggestions> pendingSuggestions;

@Shadow
public abstract void show(boolean narrateFirstSuggestion);

@ModifyVariable(method = "refresh", at = @At(value = "STORE"), index = 3)
private boolean refreshModify(boolean showCompletions) {
return CommandManager.INSTANCE.isCommand(textField.getText());
Expand All @@ -46,4 +67,55 @@ private boolean refreshModify(boolean showCompletions) {
private CommandDispatcher<CommandSource> refreshRedirect(ClientPlayNetworkHandler instance) {
return CommandManager.INSTANCE.currentDispatcher(textField.getText());
}

@Inject(method = "refresh", at = @At("TAIL"))
private void refreshEmojiSuggestion(CallbackInfo ci) {
if (!LambdaMoji.INSTANCE.isEnabled() ||
!LambdaMoji.INSTANCE.getSuggestions()) return;

String typing = textField.getText();

// Don't suggest emojis in commands
if (CommandManager.INSTANCE.isCommand(typing) ||
CommandManager.INSTANCE.isLambdaCommand(typing)) return;

int cursor = textField.getCursor();
String textToCursor = typing.substring(0, cursor);
if (textToCursor.isEmpty()) return;

// Most right index at the left of the regex expression
int start = neoLambda$getLastColon(textToCursor);
if (start == -1) return;

String emojiString = typing.substring(start + 1);

Stream<String> results = LambdaAtlas.INSTANCE.getKeys(RenderSettings.INSTANCE.getEmojiFont())
.keySet().stream()
.filter(s -> s.startsWith(emojiString))
.map(s -> s + ":");

pendingSuggestions = CommandSource.suggestMatching(results, new SuggestionsBuilder(textToCursor, start + 1));
pendingSuggestions.thenRun(() -> {
if (!pendingSuggestions.isDone()) return;

show(false);
});
Comment on lines +98 to +102
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add safeguards for async suggestion handling.

The current implementation has a potential race condition where pendingSuggestions might be modified between the check and usage.

-        pendingSuggestions.thenRun(() -> {
-            if (!pendingSuggestions.isDone()) return;
-
-            show(false);
-        });
+        CompletableFuture<Suggestions> currentSuggestions = pendingSuggestions;
+        pendingSuggestions.thenRun(() -> {
+            if (currentSuggestions != pendingSuggestions || !currentSuggestions.isDone()) return;
+            show(false);
+        });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pendingSuggestions.thenRun(() -> {
if (!pendingSuggestions.isDone()) return;
show(false);
});
CompletableFuture<Suggestions> currentSuggestions = pendingSuggestions;
pendingSuggestions.thenRun(() -> {
if (currentSuggestions != pendingSuggestions || !currentSuggestions.isDone()) return;
show(false);
});

}

@Unique
private static final Pattern COLON_PATTERN = Pattern.compile("(:[a-zA-Z0-9_]+)");

@Unique
private int neoLambda$getLastColon(String input) {
if (Strings.isNullOrEmpty(input)) return -1;

int i = -1;
Matcher matcher = COLON_PATTERN.matcher(input);

while (matcher.find()) {
i = matcher.start();
}

return i;
}
}
50 changes: 0 additions & 50 deletions common/src/main/java/com/lambda/mixin/render/ChatScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,65 +17,15 @@

package com.lambda.mixin.render;

import com.lambda.Lambda;
import com.lambda.command.CommandManager;
import com.lambda.graphics.renderer.gui.font.FontRenderer;
import com.lambda.graphics.renderer.gui.font.LambdaEmoji;
import com.lambda.graphics.renderer.gui.font.glyph.GlyphInfo;
import com.lambda.module.modules.client.LambdaMoji;
import com.lambda.util.math.Vec2d;
import kotlin.Pair;
import kotlin.ranges.IntRange;
import net.minecraft.client.gui.screen.ChatScreen;
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Mixin(ChatScreen.class)
public abstract class ChatScreenMixin {
@ModifyArg(method = "sendMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendChatMessage(Ljava/lang/String;)V"), index = 0)
private String modifyChatText(String chatText) {
if (LambdaMoji.INSTANCE.isDisabled()) return chatText;

List<Pair<GlyphInfo, IntRange>> emojis = FontRenderer.Companion.parseEmojis(chatText, LambdaEmoji.Twemoji);
Collections.reverse(emojis);

List<String> pushEmojis = new ArrayList<>();
List<Vec2d> pushPositions = new ArrayList<>();

for (Pair<GlyphInfo, IntRange> emoji : emojis) {
String emojiString = chatText.substring(emoji.getSecond().getStart() + 1, emoji.getSecond().getEndInclusive());
if (LambdaEmoji.Twemoji.get(emojiString) == null)
continue;

// Because the width of a char is bigger than an emoji
// we can simply replace the matches string by a space
// and render it after the text
chatText = chatText.substring(0, emoji.getSecond().getStart()) + " " + chatText.substring(emoji.getSecond().getEndInclusive() + 1);

// We cannot retain the position in the future, but we can
// assume that every time you send a message the height of
// the position will change by the height of the glyph
// The positions are from the top left corner of the screen
int x = Lambda.getMc().textRenderer.getWidth(chatText.substring(0, emoji.getSecond().getStart()));
int y = Lambda.getMc().textRenderer.fontHeight;

pushEmojis.add(String.format(":%s:", emojiString));
pushPositions.add(new Vec2d(x, y));
}

// Not optimal because it has to parse the emoji again but who cares
LambdaMoji.INSTANCE.add(pushEmojis, pushPositions);

return chatText;
}

@Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true)
void sendMessageInject(String chatText, boolean addToHistory, CallbackInfoReturnable<Boolean> cir) {
if (!CommandManager.INSTANCE.isLambdaCommand(chatText)) return;
Expand Down
64 changes: 64 additions & 0 deletions common/src/main/java/com/lambda/mixin/render/DrawContextMixin.java
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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));
}
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));
}


drawTooltip(textRenderer, list, x, y, HoveredTooltipPositioner.INSTANCE);
ci.cancel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.lambda.mixin.render;

import com.lambda.util.LambdaResource;
import com.lambda.util.LambdaResourceKt;
import net.minecraft.client.gui.screen.SplashOverlay;
import net.minecraft.client.texture.ResourceTexture;
import net.minecraft.resource.DefaultResourcePack;
Expand Down Expand Up @@ -62,7 +62,7 @@ public LogoTextureMixin(Identifier location) {

@Redirect(method = "loadTextureData", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/DefaultResourcePack;open(Lnet/minecraft/resource/ResourceType;Lnet/minecraft/util/Identifier;)Lnet/minecraft/resource/InputSupplier;"))
InputSupplier<InputStream> loadTextureData(DefaultResourcePack instance, ResourceType type, Identifier id) {
return () -> new LambdaResource("textures/lambda_banner.png").getStream();
return () -> LambdaResourceKt.getStream("textures/lambda_banner.png");
}
}
}
8 changes: 0 additions & 8 deletions common/src/main/kotlin/com/lambda/Lambda.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ package com.lambda
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.lambda.config.serializer.*
import com.lambda.config.serializer.gui.CustomModuleWindowSerializer
import com.lambda.config.serializer.gui.ModuleTagSerializer
import com.lambda.config.serializer.gui.TagWindowSerializer
import com.lambda.core.Loader
import com.lambda.gui.impl.clickgui.windows.tag.CustomModuleWindow
import com.lambda.gui.impl.clickgui.windows.tag.TagWindow
import com.lambda.module.tag.ModuleTag
import com.lambda.util.KeyCode
import com.mojang.authlib.GameProfile
Expand Down Expand Up @@ -54,9 +49,6 @@ object Lambda {

val gson: Gson = GsonBuilder()
.setPrettyPrinting()
.registerTypeAdapter(ModuleTag::class.java, ModuleTagSerializer)
.registerTypeAdapter(CustomModuleWindow::class.java, CustomModuleWindowSerializer)
.registerTypeAdapter(TagWindow::class.java, TagWindowSerializer)
.registerTypeAdapter(KeyCode::class.java, KeyCodeSerializer)
.registerTypeAdapter(Color::class.java, ColorSerializer)
.registerTypeAdapter(BlockPos::class.java, BlockPosSerializer)
Expand Down
15 changes: 9 additions & 6 deletions common/src/main/kotlin/com/lambda/config/Configurable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ import com.google.gson.reflect.TypeToken
import com.lambda.Lambda
import com.lambda.Lambda.LOG
import com.lambda.config.settings.CharSetting
import com.lambda.config.settings.FunctionSetting
import com.lambda.config.settings.StringSetting
import com.lambda.config.settings.collections.ListSetting
import com.lambda.config.settings.collections.MapSetting
import com.lambda.config.settings.collections.SetSetting
import com.lambda.config.settings.comparable.BooleanSetting
import com.lambda.config.settings.comparable.EnumSetting
import com.lambda.config.settings.complex.BlockPosSetting
import com.lambda.config.settings.complex.BlockSetting
import com.lambda.config.settings.complex.ColorSetting
import com.lambda.config.settings.complex.KeyBindSetting
import com.lambda.config.settings.complex.*
import com.lambda.config.settings.numeric.*
import com.lambda.util.Communication.logError
import com.lambda.util.KeyCode
Expand Down Expand Up @@ -173,7 +171,6 @@ abstract class Configurable(
* @param name The unique identifier for the setting.
* @param defaultValue The default [List] value of type [T] for the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param hackDelegates A flag that determines whether the setting should be serialized with the default value.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* ```kotlin
Expand Down Expand Up @@ -204,7 +201,6 @@ abstract class Configurable(
* @param name The unique identifier for the setting.
* @param defaultValue The default [Map] value of type [K] and [V] for the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param hackDelegates A flag that determines whether the setting should be serialized with the default value.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* ```kotlin
Expand Down Expand Up @@ -424,4 +420,11 @@ abstract class Configurable(
description: String = "",
visibility: () -> Boolean = { true },
) = BlockSetting(name, defaultValue, description, visibility).register()

fun setting(
name: String,
defaultValue: () -> Unit,
description: String = "",
visibility: () -> Boolean = { true }
) = FunctionSetting(name, defaultValue, description, visibility).register()
}
Loading