3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-04 23:30:24 +01:00

Fix tab complete support for 1.13.1-pre2

Dieser Commit ist enthalten in:
Myles 2018-08-21 16:07:24 +01:00
Ursprung 41ab131a4d
Commit 83e94dbf4a

Datei anzeigen

@ -6,6 +6,7 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13_1_pre2to1_13.packets.EntityPackets;
@ -27,13 +28,11 @@ public class Protocol13_1_PRE2TO1_13 extends Protocol {
@Override
public void registerMap() {
map(Type.VAR_INT);
handler(new PacketHandler() {
map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
String s = wrapper.passthrough(Type.STRING);
if (s.length() > 256) {
wrapper.cancel();
}
public String transform(PacketWrapper wrapper, String inputValue) {
// 1.13 starts sending slash at start, so we remove it for compatibility
return inputValue.startsWith("/") ? inputValue.substring(1) : inputValue;
}
});
}
@ -57,6 +56,33 @@ public class Protocol13_1_PRE2TO1_13 extends Protocol {
}
});
// Tab complete
registerOutgoing(State.PLAY, 0x10, 0x10, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Transaction id
map(Type.VAR_INT); // Start
map(Type.VAR_INT); // Length
map(Type.VAR_INT); // Count
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int start = wrapper.get(Type.VAR_INT, 1);
wrapper.set(Type.VAR_INT, 1, start + 1); // Offset by +1 to take into account / at beginning
// Passthrough suggestions
int count = wrapper.get(Type.VAR_INT, 3);
for (int i = 0; i < count; i++) {
wrapper.passthrough(Type.STRING);
boolean hasTooltip = wrapper.passthrough(Type.BOOLEAN);
if (hasTooltip) {
wrapper.passthrough(Type.STRING); // JSON Tooltip
}
}
}
});
}
});
//boss bar
registerOutgoing(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
@Override
@ -124,7 +150,6 @@ public class Protocol13_1_PRE2TO1_13 extends Protocol {
});
//Tags
registerOutgoing(State.PLAY, 0x55, 0x55, new PacketRemapper() {
@Override