3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20: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.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; 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.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13_1_pre2to1_13.packets.EntityPackets; 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 @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
handler(new PacketHandler() { map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public String transform(PacketWrapper wrapper, String inputValue) {
String s = wrapper.passthrough(Type.STRING); // 1.13 starts sending slash at start, so we remove it for compatibility
if (s.length() > 256) { return inputValue.startsWith("/") ? inputValue.substring(1) : inputValue;
wrapper.cancel();
}
} }
}); });
} }
@ -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 //boss bar
registerOutgoing(State.PLAY, 0x0C, 0x0C, new PacketRemapper() { registerOutgoing(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
@Override @Override
@ -124,7 +150,6 @@ public class Protocol13_1_PRE2TO1_13 extends Protocol {
}); });
//Tags //Tags
registerOutgoing(State.PLAY, 0x55, 0x55, new PacketRemapper() { registerOutgoing(State.PLAY, 0x55, 0x55, new PacketRemapper() {
@Override @Override