Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-26 16:12:43 +01:00
Add CommandRewriters for all protocols (#325)
Dieser Commit ist enthalten in:
Ursprung
d2bd9679da
Commit
600c843747
@ -4,6 +4,7 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
|||||||
import nl.matsv.viabackwards.api.data.BackwardsMappings;
|
import nl.matsv.viabackwards.api.data.BackwardsMappings;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.CommandRewriter1_14;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.BlockItemPackets1_14;
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.BlockItemPackets1_14;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.EntityPackets1_14;
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.EntityPackets1_14;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.PlayerPackets1_14;
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.PlayerPackets1_14;
|
||||||
@ -45,6 +46,8 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
translatableRewriter.registerTitle(ClientboundPackets1_14.TITLE);
|
translatableRewriter.registerTitle(ClientboundPackets1_14.TITLE);
|
||||||
translatableRewriter.registerPing();
|
translatableRewriter.registerPing();
|
||||||
|
|
||||||
|
new CommandRewriter1_14(this).registerDeclareCommands(ClientboundPackets1_14.DECLARE_COMMANDS);
|
||||||
|
|
||||||
blockItemPackets = new BlockItemPackets1_14(this, translatableRewriter);
|
blockItemPackets = new BlockItemPackets1_14(this, translatableRewriter);
|
||||||
blockItemPackets.register();
|
blockItemPackets.register();
|
||||||
entityPackets = new EntityPackets1_14(this);
|
entityPackets = new EntityPackets1_14(this);
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
|
import us.myles.ViaVersion.api.rewriters.CommandRewriter;
|
||||||
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
|
||||||
|
public class CommandRewriter1_14 extends CommandRewriter {
|
||||||
|
|
||||||
|
public CommandRewriter1_14(Protocol protocol) {
|
||||||
|
super(protocol);
|
||||||
|
|
||||||
|
this.parserHandlers.put("minecraft:nbt_tag", wrapper -> {
|
||||||
|
wrapper.write(Type.VAR_INT, 2); // Greedy phrase
|
||||||
|
});
|
||||||
|
this.parserHandlers.put("minecraft:time", wrapper -> {
|
||||||
|
wrapper.write(Type.BYTE, (byte) (0x01)); // Flags
|
||||||
|
wrapper.write(Type.INT, 0); // Min value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected String handleArgumentType(String argumentType) {
|
||||||
|
switch (argumentType) {
|
||||||
|
case "minecraft:nbt_compound_tag":
|
||||||
|
return "minecraft:nbt";
|
||||||
|
case "minecraft:nbt_tag":
|
||||||
|
return "brigadier:string";
|
||||||
|
case "minecraft:time":
|
||||||
|
return "brigadier:integer";
|
||||||
|
}
|
||||||
|
return super.handleArgumentType(argumentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
|||||||
import nl.matsv.viabackwards.api.data.BackwardsMappings;
|
import nl.matsv.viabackwards.api.data.BackwardsMappings;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.data.CommandRewriter1_13_1;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityPackets1_13_1;
|
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityPackets1_13_1;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets1_13_1;
|
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets1_13_1;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1;
|
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1;
|
||||||
@ -47,6 +48,8 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE);
|
translatableRewriter.registerTitle(ClientboundPackets1_13.TITLE);
|
||||||
translatableRewriter.registerPing();
|
translatableRewriter.registerPing();
|
||||||
|
|
||||||
|
new CommandRewriter1_13_1(this).registerDeclareCommands(ClientboundPackets1_13.DECLARE_COMMANDS);
|
||||||
|
|
||||||
registerIncoming(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
registerIncoming(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.data;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
|
import us.myles.ViaVersion.api.rewriters.CommandRewriter;
|
||||||
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
|
||||||
|
public class CommandRewriter1_13_1 extends CommandRewriter {
|
||||||
|
|
||||||
|
public CommandRewriter1_13_1(Protocol protocol) {
|
||||||
|
super(protocol);
|
||||||
|
|
||||||
|
this.parserHandlers.put("minecraft:dimension", wrapper -> {
|
||||||
|
wrapper.write(Type.VAR_INT, 0); // Single word
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected String handleArgumentType(String argumentType) {
|
||||||
|
if (argumentType.equals("minecraft:column_pos")) {
|
||||||
|
return "minecraft:vec2";
|
||||||
|
} else if (argumentType.equals("minecraft:dimension")) {
|
||||||
|
return "brigadier:string";
|
||||||
|
}
|
||||||
|
return super.handleArgumentType(argumentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,6 +6,7 @@ import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
|||||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.chat.TranslatableRewriter1_16;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.chat.TranslatableRewriter1_16;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.BackwardsMappings;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.BackwardsMappings;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.CommandRewriter1_16;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.WorldNameTracker;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.WorldNameTracker;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.BlockItemPackets1_16;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.BlockItemPackets1_16;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.EntityPackets1_16;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.EntityPackets1_16;
|
||||||
@ -51,6 +52,8 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
translatableRewriter.registerTitle(ClientboundPackets1_16.TITLE);
|
translatableRewriter.registerTitle(ClientboundPackets1_16.TITLE);
|
||||||
translatableRewriter.registerPing();
|
translatableRewriter.registerPing();
|
||||||
|
|
||||||
|
new CommandRewriter1_16(this).registerDeclareCommands(ClientboundPackets1_16.DECLARE_COMMANDS);
|
||||||
|
|
||||||
(blockItemPackets = new BlockItemPackets1_16(this, translatableRewriter)).register();
|
(blockItemPackets = new BlockItemPackets1_16(this, translatableRewriter)).register();
|
||||||
EntityPackets1_16 entityPackets = new EntityPackets1_16(this);
|
EntityPackets1_16 entityPackets = new EntityPackets1_16(this);
|
||||||
entityPackets.register();
|
entityPackets.register();
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
|
import us.myles.ViaVersion.api.rewriters.CommandRewriter;
|
||||||
|
|
||||||
|
public class CommandRewriter1_16 extends CommandRewriter {
|
||||||
|
|
||||||
|
public CommandRewriter1_16(Protocol protocol) {
|
||||||
|
super(protocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected String handleArgumentType(String argumentType) {
|
||||||
|
if (argumentType.equals("minecraft:uuid")) {
|
||||||
|
return "minecraft:game_profile";
|
||||||
|
}
|
||||||
|
return super.handleArgumentType(argumentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ import nl.matsv.viabackwards.api.data.BackwardsMappings;
|
|||||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
||||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data.CommandRewriter1_16_2;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.BlockItemPackets1_16_2;
|
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.BlockItemPackets1_16_2;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.EntityPackets1_16_2;
|
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.EntityPackets1_16_2;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
@ -45,6 +46,8 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
|||||||
translatableRewriter.registerOpenWindow(ClientboundPackets1_16_2.OPEN_WINDOW);
|
translatableRewriter.registerOpenWindow(ClientboundPackets1_16_2.OPEN_WINDOW);
|
||||||
translatableRewriter.registerPing();
|
translatableRewriter.registerPing();
|
||||||
|
|
||||||
|
new CommandRewriter1_16_2(this).registerDeclareCommands(ClientboundPackets1_16_2.DECLARE_COMMANDS);
|
||||||
|
|
||||||
(blockItemPackets = new BlockItemPackets1_16_2(this, translatableRewriter)).register();
|
(blockItemPackets = new BlockItemPackets1_16_2(this, translatableRewriter)).register();
|
||||||
EntityPackets1_16_2 entityPackets = new EntityPackets1_16_2(this);
|
EntityPackets1_16_2 entityPackets = new EntityPackets1_16_2(this);
|
||||||
entityPackets.register();
|
entityPackets.register();
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
|
import us.myles.ViaVersion.api.rewriters.CommandRewriter;
|
||||||
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
|
||||||
|
public class CommandRewriter1_16_2 extends CommandRewriter {
|
||||||
|
|
||||||
|
public CommandRewriter1_16_2(Protocol protocol) {
|
||||||
|
super(protocol);
|
||||||
|
|
||||||
|
this.parserHandlers.put("minecraft:angle", wrapper -> {
|
||||||
|
wrapper.write(Type.VAR_INT, 0); // Single word
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected String handleArgumentType(String argumentType) {
|
||||||
|
if (argumentType.equals("minecraft:angle")) {
|
||||||
|
return "brigadier:string";
|
||||||
|
}
|
||||||
|
return super.handleArgumentType(argumentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren