3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-11-20 06:50:10 +01:00

Fix component length read

Dieser Commit ist enthalten in:
KennyTV 2020-06-23 19:20:39 +02:00
Ursprung 8294f6af4f
Commit b506060e48
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
5 geänderte Dateien mit 16 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -50,7 +50,7 @@ public class TranslatableRewriter {
protocol.registerOutgoing(State.LOGIN, 0x00, 0x00, new PacketRemapper() { protocol.registerOutgoing(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)))); handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING))));
} }
}); });
} }
@ -59,7 +59,7 @@ public class TranslatableRewriter {
protocol.registerOutgoing(packetType, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)))); handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING))));
} }
}); });
} }
@ -68,7 +68,7 @@ public class TranslatableRewriter {
protocol.registerOutgoing(packetType, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)))); handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING))));
} }
}); });
} }
@ -82,7 +82,7 @@ public class TranslatableRewriter {
handler(wrapper -> { handler(wrapper -> {
int action = wrapper.get(Type.VAR_INT, 0); int action = wrapper.get(Type.VAR_INT, 0);
if (action == 0 || action == 3) { if (action == 0 || action == 3) {
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))); wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)));
} }
}); });
} }
@ -95,7 +95,7 @@ public class TranslatableRewriter {
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // Id map(Type.UNSIGNED_BYTE); // Id
map(Type.STRING); // Window Type map(Type.STRING); // Window Type
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)))); handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING))));
} }
}); });
} }
@ -106,7 +106,7 @@ public class TranslatableRewriter {
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // Id map(Type.VAR_INT); // Id
map(Type.VAR_INT); // Window Type map(Type.VAR_INT); // Window Type
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)))); handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING))));
} }
}); });
} }
@ -119,7 +119,7 @@ public class TranslatableRewriter {
if (wrapper.passthrough(Type.VAR_INT) == 2) { if (wrapper.passthrough(Type.VAR_INT) == 2) {
wrapper.passthrough(Type.VAR_INT); wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.INT); wrapper.passthrough(Type.INT);
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))); wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)));
} }
}); });
} }
@ -133,7 +133,7 @@ public class TranslatableRewriter {
handler(wrapper -> { handler(wrapper -> {
int action = wrapper.passthrough(Type.VAR_INT); int action = wrapper.passthrough(Type.VAR_INT);
if (action >= 0 && action <= 2) { if (action >= 0 && action <= 2) {
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))); wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)));
} }
}); });
} }
@ -145,8 +145,8 @@ public class TranslatableRewriter {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))); wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)));
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))); wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)));
}); });
} }
}); });

Datei anzeigen

@ -137,7 +137,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
wrapper.write(Type.STRING, stringType); wrapper.write(Type.STRING, stringType);
String title = wrapper.read(Type.STRING); String title = wrapper.read(Type.COMPONENT_STRING);
if (containerTitle != null) { if (containerTitle != null) {
// Don't rewrite renamed, only translatable titles // Don't rewrite renamed, only translatable titles
JsonObject object = GsonUtil.getGson().fromJson(title, JsonObject.class); JsonObject object = GsonUtil.getGson().fromJson(title, JsonObject.class);
@ -148,7 +148,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
} }
} }
} }
wrapper.write(Type.STRING, title); wrapper.write(Type.COMPONENT_STRING, title);
wrapper.write(Type.UNSIGNED_BYTE, (short) slotSize); wrapper.write(Type.UNSIGNED_BYTE, (short) slotSize);
} }

Datei anzeigen

@ -103,7 +103,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
int action = wrapper.get(Type.VAR_INT, 0); int action = wrapper.get(Type.VAR_INT, 0);
if (action == 0 || action == 3) { if (action == 0 || action == 3) {
wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING))); wrapper.write(Type.COMPONENT_STRING, translatableRewriter.processText(wrapper.read(Type.COMPONENT_STRING)));
if (action == 0) { if (action == 0) {
wrapper.passthrough(Type.FLOAT); wrapper.passthrough(Type.FLOAT);
wrapper.passthrough(Type.VAR_INT); wrapper.passthrough(Type.VAR_INT);

Datei anzeigen

@ -53,7 +53,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
registerOutgoing(ClientboundPackets1_16.CHAT_MESSAGE, new PacketRemapper() { registerOutgoing(ClientboundPackets1_16.CHAT_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING)))); handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, translatableRewriter.processText(wrapper.read(Type.COMPONENT_STRING))));
map(Type.BYTE); map(Type.BYTE);
map(Type.UUID, Type.NOTHING); // Sender map(Type.UUID, Type.NOTHING); // Sender
} }
@ -64,7 +64,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // Window Id map(Type.VAR_INT); // Window Id
map(Type.VAR_INT); // Window Type map(Type.VAR_INT); // Window Type
handler(wrapper -> wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING)))); handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, translatableRewriter.processText(wrapper.read(Type.COMPONENT_STRING))));
handler(wrapper -> { handler(wrapper -> {
int windowType = wrapper.get(Type.VAR_INT, 1); int windowType = wrapper.get(Type.VAR_INT, 1);
if (windowType == 20) { // Smithing table if (windowType == 20) { // Smithing table

Datei anzeigen

@ -65,7 +65,7 @@
<dependency> <dependency>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<artifactId>viaversion</artifactId> <artifactId>viaversion</artifactId>
<version>3.0.0-SNAPSHOT</version> <version>3.0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>