3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 00:50:13 +01:00

Remap declare command parser types in 1.14 -> 1.13.2 (#2316)

Dieser Commit ist enthalten in:
RK_01 2021-02-05 12:18:28 +01:00 committet von GitHub
Ursprung 54488341bf
Commit bdfaf9a621
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
4 geänderte Dateien mit 82 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -19,6 +19,58 @@ public abstract class CommandRewriter {
protected CommandRewriter(Protocol protocol) {
this.protocol = protocol;
// Register default parsers
this.parserHandlers.put("brigadier:double", new CommandArgumentConsumer() {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.DOUBLE); // Min Value
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.DOUBLE); // Max Value
}
});
this.parserHandlers.put("brigadier:float", new CommandArgumentConsumer() {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.FLOAT); // Min Value
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.FLOAT); // Max Value
}
});
this.parserHandlers.put("brigadier:integer", new CommandArgumentConsumer() {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.INT); // Min Value
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.INT); // Max Value
}
});
this.parserHandlers.put("brigadier:long", new CommandArgumentConsumer() {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.LONG); // Min Value
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.LONG); // Max Value
}
});
this.parserHandlers.put("brigadier:string", new CommandArgumentConsumer() {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.VAR_INT); // Flags
}
});
this.parserHandlers.put("minecraft:entity", new CommandArgumentConsumer() {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.BYTE); // Flags
}
});
this.parserHandlers.put("minecraft:score_holder", new CommandArgumentConsumer() {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.BYTE); // Flags
}
});
}
public void handleArgument(PacketWrapper wrapper, String argumentType) throws Exception {

Datei anzeigen

@ -73,13 +73,12 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
public void write(PacketWrapper wrapper) {
wrapper.write(Type.VAR_INT, 2); // Size
// Write root node
wrapper.write(Type.VAR_INT, 0); // Mark as command
wrapper.write(Type.VAR_INT, 1); // 1 child
wrapper.write(Type.VAR_INT, 1); // Child is at 1
wrapper.write(Type.BYTE, (byte) 0); // Mark as command
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] {1}); // 1 child at index 1
// Write arg node
wrapper.write(Type.VAR_INT, 0x02 | 0x04 | 0x10); // Mark as command
wrapper.write(Type.VAR_INT, 0); // No children
wrapper.write(Type.BYTE, (byte) (0x02 | 0x04 | 0x10)); // Mark as command
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[0]); // No children
// Extra data
wrapper.write(Type.STRING, "args"); // Arg name
wrapper.write(Type.STRING, "brigadier:string");

Datei anzeigen

@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.CommandRewriter1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.ComponentRewriter1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.metadata.MetadataRewriter1_14To1_13_2;
@ -45,6 +46,9 @@ public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, Clien
ComponentRewriter componentRewriter = new ComponentRewriter1_14(this);
componentRewriter.registerChatMessage(ClientboundPackets1_13.CHAT_MESSAGE);
CommandRewriter1_14 commandRewriter = new CommandRewriter1_14(this);
commandRewriter.registerDeclareCommands(ClientboundPackets1_13.DECLARE_COMMANDS);
registerOutgoing(ClientboundPackets1_13.TAGS, new PacketRemapper() {
@Override
public void registerMap() {

Datei anzeigen

@ -0,0 +1,22 @@
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.rewriters.CommandRewriter;
public class CommandRewriter1_14 extends CommandRewriter {
public CommandRewriter1_14(Protocol protocol) {
super(protocol);
}
@Override
@Nullable
protected String handleArgumentType(String argumentType) {
if (argumentType.equals("minecraft:nbt")) {
return "minecraft:nbt_compound_tag";
}
return super.handleArgumentType(argumentType);
}
}