Fix component length read

This commit is contained in:
KennyTV 2020-06-23 19:20:39 +02:00
parent 8294f6af4f
commit b506060e48
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
5 changed files with 16 additions and 16 deletions

View File

@ -50,7 +50,7 @@ public class TranslatableRewriter {
protocol.registerOutgoing(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
@Override
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() {
@Override
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() {
@Override
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 -> {
int action = wrapper.get(Type.VAR_INT, 0);
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() {
map(Type.UNSIGNED_BYTE); // Id
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() {
map(Type.VAR_INT); // Id
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) {
wrapper.passthrough(Type.VAR_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 -> {
int action = wrapper.passthrough(Type.VAR_INT);
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
public void registerMap() {
handler(wrapper -> {
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)));
wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)));
});
}
});

View File

@ -137,7 +137,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
wrapper.write(Type.STRING, stringType);
String title = wrapper.read(Type.STRING);
String title = wrapper.read(Type.COMPONENT_STRING);
if (containerTitle != null) {
// Don't rewrite renamed, only translatable titles
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);
}

View File

@ -103,7 +103,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
public void handle(PacketWrapper wrapper) throws Exception {
int action = wrapper.get(Type.VAR_INT, 0);
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) {
wrapper.passthrough(Type.FLOAT);
wrapper.passthrough(Type.VAR_INT);

View File

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

View File

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