Skip to content

Commit c138fbe

Browse files
committed
Updated AutoDisenchant, Waypoint Manager, Bug fix Waypoints, Gradle v5
1 parent 9f3bda6 commit c138fbe

File tree

7 files changed

+59
-10
lines changed

7 files changed

+59
-10
lines changed

.github/workflows/auto_snapshot_update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
run: chmod +x gradlew
5252

5353
- name: Setup Gradle
54-
uses: gradle/actions/setup-gradle@v4
54+
uses: gradle/actions/setup-gradle@v5
5555
with:
5656
build-scan-publish: true
5757
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"

.github/workflows/dependency_graph.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: chmod +x gradlew
3535

3636
- name: Generate and submit dependency graph
37-
uses: gradle/actions/dependency-submission@v4
37+
uses: gradle/actions/dependency-submission@v5
3838
with:
3939
build-scan-publish: true
4040
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
run: chmod +x gradlew
4848

4949
- name: Setup Gradle
50-
uses: gradle/actions/setup-gradle@v4
50+
uses: gradle/actions/setup-gradle@v5
5151
with:
5252
build-scan-publish: true
5353
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
run: chmod +x gradlew
5858

5959
- name: Setup Gradle
60-
uses: gradle/actions/setup-gradle@v4
60+
uses: gradle/actions/setup-gradle@v5
6161
with:
6262
build-scan-publish: true
6363
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"

src/main/java/net/wurstclient/clickgui/screens/WaypointsScreen.java

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
package net.wurstclient.clickgui.screens;
99

1010
import java.util.ArrayList;
11+
import java.util.HashMap;
12+
import java.util.Map;
1113

1214
import net.minecraft.client.gui.DrawContext;
1315
import net.minecraft.client.gui.screen.Screen;
@@ -47,6 +49,21 @@ private static final class RowWidgets
4749

4850
private final ArrayList<RowWidgets> rows = new ArrayList<>();
4951

52+
// Persisted scroll per-world+dimension so returning keeps the same
53+
// position even if a new screen instance was created.
54+
private static final Map<String, Integer> savedScrolls = new HashMap<>();
55+
56+
private void saveScrollState()
57+
{
58+
try
59+
{
60+
String key = resolveWorldId() + ":"
61+
+ (filterDim == null ? "ALL" : filterDim.name());
62+
savedScrolls.put(key, scroll);
63+
}catch(Exception ignored)
64+
{}
65+
}
66+
5067
public WaypointsScreen(Screen prev, WaypointsManager manager)
5168
{
5269
super(Text.literal("Waypoints"));
@@ -61,7 +78,9 @@ protected void init()
6178
int x = this.width / 2 - 150;
6279

6380
rows.clear();
64-
scroll = 0;
81+
// preserve scroll so returning to this screen or refreshing doesn't
82+
// jump the list back to the top
83+
// scroll = 0;
6584

6685
// Initialize default filter to current world if not set
6786
if(filterDim == null)
@@ -149,6 +168,17 @@ protected void init()
149168
viewportTop = listStartY;
150169
viewportBottom = this.height - 36; // a bit above back button
151170

171+
// Try to restore a previously saved scroll position for this world+dim
172+
try
173+
{
174+
String key = resolveWorldId() + ":"
175+
+ (filterDim == null ? "ALL" : filterDim.name());
176+
Integer s = savedScrolls.get(key);
177+
if(s != null)
178+
scroll = s;
179+
}catch(Exception ignored)
180+
{}
181+
152182
for(int i = 0; i < cachedList.size(); i++)
153183
{
154184
Waypoint w = cachedList.get(i);
@@ -193,6 +223,14 @@ protected void init()
193223
rows.add(rw);
194224
}
195225

226+
// Clamp scroll so it stays within valid bounds after rebuilding the
227+
// list
228+
int contentHeight = rows.size() * ROW_HEIGHT;
229+
int maxScroll =
230+
Math.max(0, contentHeight - (viewportBottom - viewportTop));
231+
scroll = Math.max(0, Math.min(scroll, maxScroll));
232+
// Persist the (possibly adjusted) scroll position
233+
saveScrollState();
196234
// Scroll buttons (▲ / ▼) positioned just to the right of the 300px list
197235
// area
198236
int arrowX = x + 305; // a little to the right of the list
@@ -225,6 +263,7 @@ private void scrollBy(int dy)
225263
int maxScroll =
226264
Math.max(0, contentHeight - (viewportBottom - viewportTop));
227265
scroll = Math.max(0, Math.min(scroll + dy, maxScroll));
266+
saveScrollState();
228267
}
229268

230269
@Override
@@ -420,6 +459,7 @@ void saveNow()
420459
private void scrollToTop()
421460
{
422461
scroll = 0;
462+
saveScrollState();
423463
}
424464

425465
private void scrollToBottom()
@@ -428,5 +468,6 @@ private void scrollToBottom()
428468
int maxScroll =
429469
Math.max(0, contentHeight - (viewportBottom - viewportTop));
430470
scroll = maxScroll;
471+
saveScrollState();
431472
}
432473
}

src/main/java/net/wurstclient/hacks/AutoDisenchantHack.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,11 @@ private void disenchantSlot(GrindstoneScreen screen, int slotIndex)
168168

169169
private boolean canDisenchant(ItemStack stack)
170170
{
171-
if(!stack.hasEnchantments())
172-
return false;
171+
// if(!stack.hasEnchantments())
172+
// return false;
173+
174+
// Use EnchantmentHelper instead of ItemStack::hasEnchantments
175+
// because the latter returns false for enchanted books.
173176

174177
var enchantments =
175178
EnchantmentHelper.getEnchantments(stack).getEnchantmentEntries();

src/main/java/net/wurstclient/hacks/WaypointsHack.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,10 @@ public void onReceivedMessage(ChatInputEvent event)
311311
|| lower.contains("earned the advancement")
312312
|| lower.contains("has made the advancement")
313313
|| lower.contains("has made the achievement")
314-
|| (lower.contains("advancement") && lower.contains("completed")))
314+
|| (lower.contains("advancement") && lower.contains("completed"))
315+
|| (lower.contains("completed")
316+
&& (lower.contains("challenge") || lower.contains("advancement")
317+
|| lower.contains("achievement"))))
315318
return;
316319

317320
long now = System.currentTimeMillis();
@@ -910,8 +913,10 @@ private int getBossBarBottom(DrawContext context)
910913
{
911914
if(y >= maxY)
912915
return maxY;
913-
y += 10; // default 19px height, but use 10px as it looks better (at
914-
// least for me)
916+
y += 10; // default is 19px height, but using 10px as it looks nicer, however,
917+
// when there's two boss bars it will overlap
918+
919+
915920
}
916921
return Math.min(y, maxY);
917922
}

0 commit comments

Comments
 (0)