Skip to content

Commit 1deef60

Browse files
committed
added 1.21.6/7/8 version
1 parent f28c60a commit 1deef60

4 files changed

Lines changed: 74 additions & 49 deletions

File tree

gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G
33
org.gradle.parallel=true
44

55
# Fabric Properties
6-
minecraft_version=1.21.1
7-
yarn_mappings=1.21.1+build.3
8-
loader_version=0.16.7
6+
minecraft_version=1.21.8
7+
yarn_mappings=1.21.8+build.1
8+
loader_version=0.18.3
99

1010
# Mod Properties
11-
mod_version=1.6.0-Alpha+1.21.1
11+
mod_version=1.6.0-Alpha+1.21.8
1212
maven_group=pl.lordtricker
1313
archives_base_name=ltrynek
1414

1515
# Dependencies
16-
fabric_version=0.115.0+1.21.1
16+
fabric_version=0.136.1+1.21.8

src/client/java/pl/lordtricker/ltrynek/client/command/CommandUi.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.minecraft.text.Text;
1010
import pl.lordtricker.ltrynek.client.util.ColorUtils;
1111

12+
import java.net.URI;
1213
import java.util.concurrent.CompletableFuture;
1314

1415
public final class CommandUi {
@@ -22,11 +23,18 @@ public static MutableText colored(String text) {
2223

2324
public static MutableText clickable(String text, ClickEvent.Action action, String command, String hoverText) {
2425
MutableText out = colored(text);
25-
Style style = Style.EMPTY.withClickEvent(new ClickEvent(action, command));
26+
ClickEvent clickEvent = switch (action) {
27+
case RUN_COMMAND -> new ClickEvent.RunCommand(command);
28+
case SUGGEST_COMMAND -> new ClickEvent.SuggestCommand(command);
29+
case OPEN_URL -> new ClickEvent.OpenUrl(URI.create(command));
30+
case OPEN_FILE -> new ClickEvent.OpenFile(command);
31+
case COPY_TO_CLIPBOARD -> new ClickEvent.CopyToClipboard(command);
32+
case CHANGE_PAGE -> new ClickEvent.ChangePage(Integer.parseInt(command));
33+
default -> throw new IllegalArgumentException("Unsupported click action: " + action);
34+
};
35+
Style style = Style.EMPTY.withClickEvent(clickEvent);
2636
if (hoverText != null && !hoverText.isEmpty()) {
27-
style = style.withHoverEvent(new HoverEvent(
28-
HoverEvent.Action.SHOW_TEXT,
29-
Text.literal(hoverText)));
37+
style = style.withHoverEvent(new HoverEvent.ShowText(Text.literal(hoverText)));
3038
}
3139
out.setStyle(style);
3240
return out;

src/client/java/pl/lordtricker/ltrynek/client/mixin/HandledScreenMixin.java

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,55 @@ public abstract class HandledScreenMixin {
3838
@Shadow
3939
protected int y;
4040

41-
private int lastMatchedCount = 0;
42-
43-
@Inject(method = "render", at = @At("TAIL"))
44-
private void onRender(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
45-
ScreenHandler handler = ((ScreenHandlerProvider<?>) this).getScreenHandler();
46-
List<Slot> slots = ((ScreenHandlerAccessor) handler).getSlots();
47-
Text title = ((HandledScreen)(Object)this).getTitle();
48-
SearchAutomationController.onScreenRender(title, handler, slots);
49-
50-
if (!ToggleScanner.scanningEnabled) {
51-
return;
52-
}
53-
54-
int matchedCount = 0;
55-
for (Slot slot : slots) {
56-
if (processSlot(context, slot)) {
57-
matchedCount++;
58-
}
59-
}
60-
61-
if (LtrynekClient.serversConfig != null && LtrynekClient.serversConfig.soundsEnabled) {
62-
if (matchedCount != lastMatchedCount && matchedCount > 0) {
63-
AlarmSoundPlayer.playForMatchCount(
64-
LtrynekClient.serversConfig,
65-
ClientPriceListManager.getActiveProfile(),
66-
matchedCount
67-
);
68-
}
69-
}
70-
lastMatchedCount = matchedCount;
71-
72-
}
41+
private int lastMatchedCount = 0;
42+
private int currentMatchedCount = 0;
43+
44+
@Inject(method = "render", at = @At("HEAD"))
45+
private void onRenderHead(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
46+
currentMatchedCount = 0;
47+
}
48+
49+
@Inject(method = "render", at = @At("TAIL"))
50+
private void onRender(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
51+
ScreenHandler handler = ((ScreenHandlerProvider<?>) this).getScreenHandler();
52+
List<Slot> slots = ((ScreenHandlerAccessor) handler).getSlots();
53+
Text title = ((HandledScreen)(Object)this).getTitle();
54+
SearchAutomationController.onScreenRender(title, handler, slots);
55+
56+
if (!ToggleScanner.scanningEnabled) {
57+
return;
58+
}
59+
60+
if (LtrynekClient.serversConfig != null && LtrynekClient.serversConfig.soundsEnabled) {
61+
if (currentMatchedCount != lastMatchedCount && currentMatchedCount > 0) {
62+
AlarmSoundPlayer.playForMatchCount(
63+
LtrynekClient.serversConfig,
64+
ClientPriceListManager.getActiveProfile(),
65+
currentMatchedCount
66+
);
67+
}
68+
}
69+
lastMatchedCount = currentMatchedCount;
70+
71+
}
72+
73+
@Inject(
74+
method = "drawSlot",
75+
at = @At(
76+
value = "INVOKE",
77+
target = "Lnet/minecraft/client/gui/DrawContext;drawItem(Lnet/minecraft/item/ItemStack;III)V",
78+
shift = At.Shift.BEFORE
79+
)
80+
)
81+
private void onDrawSlotBeforeItem(DrawContext context, Slot slot, CallbackInfo ci) {
82+
if (!ToggleScanner.scanningEnabled) {
83+
return;
84+
}
85+
86+
if (processSlot(context, slot)) {
87+
currentMatchedCount++;
88+
}
89+
}
7390

7491
@Inject(method = "removed", at = @At("TAIL"))
7592
private void onRemoved(CallbackInfo ci) {
@@ -113,12 +130,12 @@ private boolean processSlot(DrawContext context, Slot slot) {
113130
slot.id
114131
);
115132
ScanResult result = ScanEvaluator.evaluate(input, LtrynekClient.serversConfig);
116-
if (result.highlight) {
117-
int realX = this.x + slot.x;
118-
int realY = this.y + slot.y;
119-
context.fill(realX, realY, realX + 16, realY + 16, result.color);
120-
return true;
121-
}
133+
if (result.highlight) {
134+
int realX = slot.x;
135+
int realY = slot.y;
136+
context.fill(realX, realY, realX + 16, realY + 16, result.color);
137+
return true;
138+
}
122139

123140
return false;
124141
}

src/main/resources/fabric.mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
],
2929

3030
"depends": {
31-
"fabricloader": ">=0.15.11",
32-
"minecraft": ">=1.21 <=1.21.1",
31+
"fabricloader": ">=0.16.14",
32+
"minecraft": ">=1.21.6 <=1.21.8",
3333
"java": ">=21",
3434
"fabric-api": "*"
3535
},

0 commit comments

Comments
 (0)