Skip to content

Commit 6687982

Browse files
committed
Fix Text Field Input & WurstTranslator
1 parent ad87193 commit 6687982

File tree

8 files changed

+62
-37
lines changed

8 files changed

+62
-37
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ I’m pleased to note that many of the features and improvements below are compl
5555
- AntiBlast
5656
- [NiceWurst](https://github.com/cev-api/NiceWurst)
5757
- SeedMapperHelper
58+
- SpearAssist
5859
- LootSearch
5960
- OfflineSettings
6061
- TargetPlace
@@ -377,9 +378,9 @@ I did not, nor could I copy their code directly as most are Meteor based mods. S
377378
- Hold - While charging you are constantly boosting forward whenever you press the left click
378379
- Your player can optionally stay grounded when boosting as to avoid flying off into the distance on each attack
379380
- Highlighting: You can highlight near and far entities within your attack range. Near meaning the distance you can jab at them and far the distance you can charge at them. Set to 7 for near and 8.5 blocks for far.
380-
- Your charge is automatically and constantly resumed so you can forever hold right click. It will be noisy but even if the spear is pointed down you will still be able to attack.
381+
- Your charge is automatically and constantly resumed (no cooldown) so you can forever hold right click. It will be noisy but even if the spear is pointed down you will still be able to attack.
381382
- You can optionally allow aim assist to work whilst holding right click.
382-
- Your jab attack will auto hit once the timeout has expired so long as you're hitting an entity.
383+
- Your jab attack will continue to auto hit once the cooldown has expired so long as you're hitting an entity.
383384

384385
## What’s changed or improved in this fork?
385386

src/main/java/net/wurstclient/WurstTranslator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import net.minecraft.server.packs.resources.Resource;
3131
import net.minecraft.server.packs.resources.ResourceManager;
3232
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
33-
import com.google.common.collect.Lists;
3433

3534
public class WurstTranslator implements ResourceManagerReloadListener
3635
{
@@ -235,7 +234,8 @@ private boolean isBuiltInWurstResourcePack(Resource resource)
235234
if(knownPack == null)
236235
return false;
237236

238-
if(!"fabric".equals(knownPack.namespace()))
237+
String namespace = knownPack.namespace();
238+
if(!"fabric".equals(namespace) && !"vanilla".equals(namespace))
239239
return false;
240240

241241
String id = knownPack.id();

src/main/java/net/wurstclient/clickgui/components/TextFieldEditButton.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,18 @@ else if(hBox && !editing)
151151
int txtColor = GUI.getTxtColor();
152152
context.guiRenderState.up();
153153
context.drawString(TR, setting.getName(), x1, y1 + 2, txtColor, false);
154-
String value = setting.getValue();
155-
int maxWidth = getWidth() - TR.width("...") - 2;
156-
int maxLength =
157-
TR.getSplitter().plainIndexAtWidth(value, maxWidth, Style.EMPTY);
158-
if(maxLength < value.length())
159-
value = value.substring(0, maxLength) + "...";
160-
context.drawString(TR, value, x1 + 2, boxY1 + 2, txtColor, false);
154+
if(editing)
155+
inlineField.render(context, mouseX, mouseY, partialTicks);
156+
else
157+
{
158+
String value = setting.getValue();
159+
int maxWidth = getWidth() - TR.width("...") - 2;
160+
int maxLength = TR.getSplitter().plainIndexAtWidth(value, maxWidth,
161+
Style.EMPTY);
162+
if(maxLength < value.length())
163+
value = value.substring(0, maxLength) + "...";
164+
context.drawString(TR, value, x1 + 2, boxY1 + 2, txtColor, false);
165+
}
161166
}
162167

163168
@Override

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ public final class SpearAssistHack extends Hack
5454
"Extra distance to travel each time you start holding attack.", 4,
5555
0, 10, 0.1, ValueDisplay.DECIMAL.withSuffix(" blocks"));
5656

57-
private final SliderSetting nearHighlightRange =
58-
new SliderSetting("Near highlight range",
59-
"Distance where targets switch to the near color.", 7, 4, 10, 0.5,
60-
ValueDisplay.DECIMAL.withSuffix(" blocks"));
61-
private final SliderSetting farHighlightRange =
62-
new SliderSetting("Far highlight range",
63-
"Distance where targets switch to the far color.", 8.5, 5, 20, 0.5,
64-
ValueDisplay.DECIMAL.withSuffix(" blocks"));
57+
private final SliderSetting nearHighlightRange =
58+
new SliderSetting("Near highlight range",
59+
"Distance where targets switch to the near color.", 7, 4, 10, 0.5,
60+
ValueDisplay.DECIMAL.withSuffix(" blocks"));
61+
private final SliderSetting farHighlightRange =
62+
new SliderSetting("Far highlight range",
63+
"Distance where targets switch to the far color.", 8.5, 5, 20, 0.5,
64+
ValueDisplay.DECIMAL.withSuffix(" blocks"));
6565

6666
private final ColorSetting nearHighlightColor =
6767
new ColorSetting("Near highlight color",
6868
"Color used when targets are nearby.", Color.YELLOW);
69-
private final ColorSetting farHighlightColor =
70-
new ColorSetting("Far highlight color",
71-
"Color used when targets are far away.", new Color(0, 255, 0));
69+
private final ColorSetting farHighlightColor =
70+
new ColorSetting("Far highlight color",
71+
"Color used when targets are far away.", new Color(0, 255, 0));
7272

7373
private final CheckboxSetting stayGrounded = new CheckboxSetting(
7474
"Stay grounded",

src/main/java/net/wurstclient/mixin/OfflineSettingsNetworkMixin.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,14 @@
1212
import org.spongepowered.asm.mixin.injection.Inject;
1313
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1414

15-
import net.minecraft.client.Minecraft;
1615
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
17-
import net.minecraft.client.multiplayer.CommonListenerCookie;
18-
import net.minecraft.network.Connection;
19-
import net.minecraft.network.TickablePacketListener;
20-
import net.minecraft.network.protocol.game.ClientGamePacketListener;
2116
import net.wurstclient.WurstClient;
2217
import net.wurstclient.hacks.OfflineSettingsHack;
2318
import net.minecraft.network.DisconnectionDetails;
2419

2520
@Mixin(value = ClientCommonPacketListenerImpl.class, remap = false)
2621
public abstract class OfflineSettingsNetworkMixin
27-
extends ClientCommonPacketListenerImpl
28-
implements TickablePacketListener, ClientGamePacketListener
2922
{
30-
private OfflineSettingsNetworkMixin(Minecraft client, Connection connection,
31-
CommonListenerCookie connectionState)
32-
{
33-
super(client, connection, connectionState);
34-
}
35-
3623
@Inject(at = @At("TAIL"),
3724
method = "onDisconnect(Lnet/minecraft/network/DisconnectionDetails;)V",
3825
remap = false)

src/main/java/net/wurstclient/mixin/ScreenRenderMixin.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,28 @@
1616
import net.minecraft.client.Minecraft;
1717
import net.minecraft.client.gui.Font;
1818
import net.minecraft.client.gui.GuiGraphics;
19+
import net.minecraft.client.gui.components.Renderable;
20+
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
1921
import net.minecraft.client.gui.screens.DisconnectedScreen;
2022
import net.minecraft.client.gui.screens.Screen;
2123
import net.minecraft.network.chat.Component;
2224
import net.minecraft.util.FormattedCharSequence;
2325
import net.wurstclient.mixinterface.LoginOverlayAccessor;
2426

2527
@Mixin(value = Screen.class, remap = false)
26-
public abstract class ScreenRenderMixin extends Screen
28+
public abstract class ScreenRenderMixin extends AbstractContainerEventHandler
29+
implements Renderable
2730
{
2831
@Shadow
2932
protected Minecraft minecraft;
33+
@Shadow
34+
protected int width;
35+
@Shadow
36+
protected int height;
3037

3138
protected ScreenRenderMixin(Component title)
3239
{
33-
super(title);
40+
3441
}
3542

3643
@Inject(at = @At("TAIL"),

src/main/java/net/wurstclient/navigator/NavigatorMainScreen.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.minecraft.client.gui.GuiGraphics;
1616
import net.minecraft.client.gui.components.EditBox;
1717
import net.minecraft.client.gui.screens.Screen;
18+
import net.minecraft.client.input.CharacterEvent;
1819
import net.minecraft.client.input.KeyEvent;
1920
import net.minecraft.client.input.MouseButtonEvent;
2021
import net.minecraft.network.chat.Component;
@@ -420,4 +421,13 @@ protected void onMouseRelease(double x, double y, int button)
420421
{
421422

422423
}
424+
425+
@Override
426+
public boolean charTyped(CharacterEvent event)
427+
{
428+
if(searchBar != null && searchBar.charTyped(event))
429+
return true;
430+
431+
return super.charTyped(event);
432+
}
423433
}

src/main/java/net/wurstclient/navigator/NavigatorScreen.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.awt.Rectangle;
1111
import net.minecraft.client.gui.GuiGraphics;
1212
import net.minecraft.client.gui.screens.Screen;
13+
import net.minecraft.client.input.CharacterEvent;
1314
import net.minecraft.client.input.KeyEvent;
1415
import net.minecraft.client.input.MouseButtonEvent;
1516
import net.minecraft.network.chat.Component;
@@ -44,10 +45,24 @@ protected final void init()
4445
@Override
4546
public final boolean keyPressed(KeyEvent context)
4647
{
48+
ClickGui gui = WurstClient.INSTANCE.getGui();
49+
if(gui.handleKeyPressed(context))
50+
return true;
51+
4752
onKeyPress(context);
4853
return super.keyPressed(context);
4954
}
5055

56+
@Override
57+
public boolean charTyped(CharacterEvent event)
58+
{
59+
ClickGui gui = WurstClient.INSTANCE.getGui();
60+
if(gui.handleCharTyped(event))
61+
return true;
62+
63+
return super.charTyped(event);
64+
}
65+
5166
@Override
5267
public final boolean mouseClicked(MouseButtonEvent context,
5368
boolean doubleClick)

0 commit comments

Comments
 (0)