Skip to content

Commit f4e0893

Browse files
committed
Updated ItemHandler and KeyBinds
1 parent 33a64c8 commit f4e0893

File tree

4 files changed

+116
-11
lines changed

4 files changed

+116
-11
lines changed

src/main/java/net/wurstclient/hacks/itemhandler/ItemHandlerHack.java

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.wurstclient.settings.SliderSetting;
1313
import net.wurstclient.settings.SliderSetting.ValueDisplay;
1414
import net.wurstclient.settings.CheckboxSetting;
15+
import net.wurstclient.settings.ButtonSetting;
1516
import java.util.ArrayDeque;
1617
import java.util.ArrayList;
1718
import java.util.Collection;
@@ -27,6 +28,11 @@
2728
import net.minecraft.world.phys.Vec3;
2829
import net.wurstclient.Category;
2930
import net.wurstclient.events.UpdateListener;
31+
import net.wurstclient.events.RenderListener;
32+
import com.mojang.blaze3d.vertex.PoseStack;
33+
import net.minecraft.world.phys.AABB;
34+
import net.wurstclient.util.RenderUtils;
35+
import net.wurstclient.util.ChatUtils;
3036
import net.wurstclient.hack.Hack;
3137
import net.wurstclient.mixinterface.IKeyBinding;
3238
import net.wurstclient.settings.Setting;
@@ -39,7 +45,8 @@
3945
// no screen import needed; we embed ItemESP's editor component directly
4046
import net.wurstclient.util.InventoryUtils;
4147

42-
public class ItemHandlerHack extends Hack implements UpdateListener
48+
public class ItemHandlerHack extends Hack
49+
implements UpdateListener, RenderListener
4350
{
4451
private static final double SCAN_RADIUS = 2.5;
4552
// When the popup is set to "infinite", use this large but finite
@@ -83,7 +90,7 @@ public class ItemHandlerHack extends Hack implements UpdateListener
8390

8491
// Adjust popup/UI scale (affects text size and icon size heuristically)
8592
private final SliderSetting popupScale = new SliderSetting(
86-
"Popup font scale", 0.75, 0.5, 1.5, 0.05, ValueDisplay.DECIMAL);
93+
"Popup HUD font scale", 0.75, 0.5, 1.5, 0.05, ValueDisplay.DECIMAL);
8794

8895
// Respect ItemESP's ignored items list
8996
private final CheckboxSetting respectItemEspIgnores =
@@ -101,6 +108,8 @@ public ItemHandlerHack()
101108
setCategory(Category.ITEMS);
102109
addPossibleKeybind("itemhandler gui",
103110
"ItemHandler GUI (open manual pickup screen)");
111+
// Top-level button to open the ItemHandler GUI from settings
112+
addSetting(new ButtonSetting("Open ItemHandler GUI", this::openScreen));
104113
addSetting(rejectRadius);
105114
addSetting(rejectExpiry);
106115
addSetting(hudEnabled);
@@ -118,6 +127,7 @@ public ItemHandlerHack()
118127
protected void onEnable()
119128
{
120129
EVENTS.add(UpdateListener.class, this);
130+
EVENTS.add(RenderListener.class, this);
121131
trackedItems.clear();
122132
pickupWhitelist.clear();
123133
pickupQueue.clear();
@@ -127,6 +137,7 @@ protected void onEnable()
127137
protected void onDisable()
128138
{
129139
EVENTS.remove(UpdateListener.class, this);
140+
EVENTS.remove(RenderListener.class, this);
130141
trackedItems.clear();
131142
pickupWhitelist.clear();
132143
pickupQueue.clear();
@@ -202,6 +213,12 @@ private void processRejectedPickup()
202213
continue;
203214

204215
int gained = count - prev;
216+
// if player gained items of this id, unmark tracing for that id
217+
if(gained > 0 && tracedItems.contains(id))
218+
{
219+
tracedItems.remove(id);
220+
ChatUtils.message("Untraced " + id + " after pickup.");
221+
}
205222
// Total rejected amount for this id (sum across rules that match
206223
// player's position)
207224
int totalRejected = 0;
@@ -336,7 +353,7 @@ private void scanNearbyItems()
336353
{
337354
net.wurstclient.hacks.ItemEspHack esp =
338355
net.wurstclient.WurstClient.INSTANCE.getHax().itemEspHack;
339-
if(esp != null && esp.shouldUseIgnoredItems())
356+
if(esp != null)
340357
{
341358
String id =
342359
net.minecraft.core.registries.BuiltInRegistries.ITEM
@@ -565,6 +582,46 @@ public String distanceText()
565582
}
566583
}
567584

585+
@Override
586+
public void onRender(PoseStack matrixStack, float partialTicks)
587+
{
588+
if(tracedItems.isEmpty())
589+
return;
590+
// Avoid duplicate rendering if ItemESP is enabled
591+
net.wurstclient.hacks.ItemEspHack esp =
592+
net.wurstclient.WurstClient.INSTANCE.getHax().itemEspHack;
593+
if(esp != null && esp.isEnabled())
594+
return;
595+
596+
java.util.ArrayList<AABB> boxes = new java.util.ArrayList<>();
597+
java.util.ArrayList<Vec3> ends = new java.util.ArrayList<>();
598+
for(GroundItem gi : trackedItems)
599+
{
600+
String id = net.minecraft.core.registries.BuiltInRegistries.ITEM
601+
.getKey(gi.stack().getItem()).toString();
602+
if(!isTraced(id))
603+
continue;
604+
Vec3 p = gi.position();
605+
boxes.add(new AABB(p.x - 0.18, p.y - 0.18, p.z - 0.18, p.x + 0.18,
606+
p.y + 0.18, p.z + 0.18));
607+
ends.add(p);
608+
}
609+
if(boxes.isEmpty() && ends.isEmpty())
610+
return;
611+
float[] rf = RenderUtils.getRainbowColor();
612+
int traceLines = RenderUtils.toIntColor(rf, 0.5f);
613+
int traceQuads = RenderUtils.toIntColor(rf, 0.35f);
614+
if(!boxes.isEmpty())
615+
{
616+
RenderUtils.drawSolidBoxes(matrixStack, boxes, traceQuads, false);
617+
RenderUtils.drawOutlinedBoxes(matrixStack, boxes, traceLines,
618+
false);
619+
}
620+
if(!ends.isEmpty())
621+
RenderUtils.drawTracers(matrixStack, partialTicks, ends, traceLines,
622+
false);
623+
}
624+
568625
// Inline ItemESP ignored-items editor in ItemHandler settings
569626
private final Setting itemEspIgnoredListSetting =
570627
new Setting("Ignored items", WText.empty())

src/main/java/net/wurstclient/keybinds/KeybindList.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,29 @@ public void saveProfile(String fileName) throws IOException, JsonException
117117
private static Set<Keybind> createDefaultKeybinds()
118118
{
119119
Set<Keybind> set = new LinkedHashSet<>();
120+
addKB(set, "apostrophe", ".waypoints");
120121
addKB(set, "b", "fastplace;fastbreak");
121122
addKB(set, "c", "fullbright");
123+
addKB(set, "comma", ".autosort");
122124
addKB(set, "g", "flight");
123-
addKB(set, "semicolon", "speednuker");
124125
addKB(set, "h", "say /home");
125126
addKB(set, "j", "jesus");
126127
addKB(set, "k", "multiaura");
128+
addKB(set, "keypad.7", "Blink");
129+
addKB(set, "keypad.8", "SafeTP");
130+
addKB(set, "keypad.add", "Panic");
131+
addKB(set, "keypad.decimal", "panic restore");
132+
addKB(set, "left.bracket", "ChestSearch");
133+
addKB(set, "menu", "clickgui");
127134
addKB(set, "n", "nuker");
128-
addKB(set, "r", "killaura");
135+
addKB(set, "r", "multiaura");
136+
addKB(set, "right.alt", "WindChargeKey");
137+
addKB(set, "right.bracket", ".setcheckbox breadcrumbs paused toggle");
129138
addKB(set, "right.shift", "navigator");
130-
addKB(set, "right.control", "clickgui");
139+
addKB(set, "semicolon", "itemhandler gui");
131140
addKB(set, "u", "freecam");
132141
addKB(set, "x", "x-ray");
133-
addKB(set, "y", "sneak");
134-
// Default shortcut to open the Waypoints manager
142+
addKB(set, "y", "ChestESP");
135143
addKB(set, "apostrophe", ".waypoints");
136144
return Collections.unmodifiableSet(set);
137145
}

src/main/java/net/wurstclient/keybinds/KeybindProcessor.java

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package net.wurstclient.keybinds;
99

1010
import org.lwjgl.glfw.GLFW;
11+
import java.util.Locale;
1112
import com.mojang.blaze3d.platform.InputConstants;
1213
import net.minecraft.client.gui.screens.Screen;
1314
import net.minecraft.client.input.KeyEvent;
@@ -44,7 +45,12 @@ public void onKeyPress(KeyPressEvent event)
4445
return;
4546

4647
Screen screen = WurstClient.MC.screen;
47-
if(screen != null && !(screen instanceof ClickGuiScreen))
48+
// Allow processing when no screen is open, when the Click GUI is open,
49+
// or when Waypoints or ItemHandler screens are open so their keybinds
50+
// can toggle/close them with the same key.
51+
if(screen != null && !(screen instanceof ClickGuiScreen)
52+
&& !(screen instanceof net.wurstclient.clickgui.screens.WaypointsScreen)
53+
&& !(screen instanceof net.wurstclient.hacks.itemhandler.ItemHandlerScreen))
4854
return;
4955

5056
// if ClickGuiScreen is open and user typed a printable key, open
@@ -112,11 +118,45 @@ private void processCmds(String cmds)
112118

113119
private void processCmd(String cmd)
114120
{
121+
String trimmed = cmd.trim();
122+
// Special-case: toggle Waypoints manager when bound to ".waypoints"
123+
if(trimmed.equalsIgnoreCase(".waypoints"))
124+
{
125+
// If Waypoints screen is open, close it; otherwise open manager
126+
if(net.minecraft.client.Minecraft
127+
.getInstance().screen instanceof net.wurstclient.clickgui.screens.WaypointsScreen)
128+
{
129+
net.minecraft.client.Minecraft.getInstance().setScreen(null);
130+
return;
131+
}
132+
// open via hack utility
133+
WurstClient.INSTANCE.getHax().waypointsHack.openManager();
134+
return;
135+
}
136+
115137
if(cmd.startsWith("."))
116138
cmdProcessor.process(cmd.substring(1));
117139
else if(cmd.contains(" "))
140+
{
141+
// special-case: open/close ItemHandler GUI when key bound to
142+
// "itemhandler gui"
143+
String lower = cmd.toLowerCase(Locale.ROOT).trim();
144+
if(lower.equals("itemhandler gui"))
145+
{
146+
net.minecraft.client.gui.screens.Screen s =
147+
net.minecraft.client.Minecraft.getInstance().screen;
148+
if(s instanceof net.wurstclient.hacks.itemhandler.ItemHandlerScreen)
149+
{
150+
net.minecraft.client.Minecraft.getInstance()
151+
.setScreen(null);
152+
return;
153+
}
154+
// Open ItemHandler screen via hack utility when not open
155+
WurstClient.INSTANCE.getHax().itemHandlerHack.openScreen();
156+
return;
157+
}
118158
cmdProcessor.process(cmd);
119-
else
159+
}else
120160
{
121161
Hack hack = hax.getHackByName(cmd);
122162

src/main/java/net/wurstclient/nicewurst/NiceWurstModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public final class NiceWurstModule
100100

101101
ALLOWED_HACKS.put(Category.ITEMS,
102102
Set.of("AntiDrop", "AutoDisenchant", "AutoDrop", "AutoEat",
103-
"AutoSteal", "ChestSearch", "EnchantmentHandler",
103+
"AutoSteal", "ChestSearch", "EnchantmentHandler", "ItemHandler",
104104
"QuickShulker", "SignFramePT", "XCarry"));
105105
}
106106

0 commit comments

Comments
 (0)