Files
CatServer/patches/net/minecraft/util/TabCompleter.java.patch
2019-02-24 22:29:41 +08:00

40 lines
1.7 KiB
Diff

--- ../src-base/minecraft/net/minecraft/util/TabCompleter.java
+++ ../src-work/minecraft/net/minecraft/util/TabCompleter.java
@@ -55,13 +55,14 @@
this.textField.deleteFromCursor(i - this.textField.getCursorPosition());
}
- this.textField.writeText(this.completions.get(this.completionIdx++));
+ this.textField.writeText(net.minecraft.util.text.TextFormatting.getTextWithoutFormattingCodes(this.completions.get(this.completionIdx++)));
}
private void requestCompletions(String prefix)
{
if (prefix.length() >= 1)
{
+ net.minecraftforge.client.ClientCommandHandler.instance.autoComplete(prefix);
Minecraft.getMinecraft().player.connection.sendPacket(new CPacketTabComplete(prefix, this.getTargetBlockPos(), this.hasTargetBlock));
this.requestedCompletions = true;
}
@@ -77,6 +78,12 @@
this.didComplete = false;
this.completions.clear();
+ String[] complete = net.minecraftforge.client.ClientCommandHandler.instance.latestAutoComplete;
+ if (complete != null)
+ {
+ newCompl = com.google.common.collect.ObjectArrays.concat(complete, newCompl, String.class);
+ }
+
for (String s : newCompl)
{
if (!s.isEmpty())
@@ -87,6 +94,7 @@
String s1 = this.textField.getText().substring(this.textField.getNthWordFromPosWS(-1, this.textField.getCursorPosition(), false));
String s2 = org.apache.commons.lang3.StringUtils.getCommonPrefix(newCompl);
+ s2 = net.minecraft.util.text.TextFormatting.getTextWithoutFormattingCodes(s2);
if (!s2.isEmpty() && !s1.equalsIgnoreCase(s2))
{