mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-22 16:38:20 +01:00
24w38a
This commit is contained in:
parent
2a2afa3821
commit
db20bc0ae4
@ -86,7 +86,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
|
||||
public static final ProtocolVersion v1_20_3 = register(765, "1.20.3-1.20.4", new SubVersionRange("1.20", 3, 4));
|
||||
public static final ProtocolVersion v1_20_5 = register(766, "1.20.5-1.20.6", new SubVersionRange("1.20", 5, 6));
|
||||
public static final ProtocolVersion v1_21 = register(767, "1.21-1.21.1", new SubVersionRange("1.21", 0, 1));
|
||||
public static final ProtocolVersion v1_21_2 = register(768, 209, "1.21.2");
|
||||
public static final ProtocolVersion v1_21_2 = register(768, 210, "1.21.2");
|
||||
public static final ProtocolVersion unknown = new ProtocolVersion(VersionType.SPECIAL, -1, -1, "UNKNOWN", null);
|
||||
|
||||
public static ProtocolVersion register(int version, String name) {
|
||||
|
@ -23,11 +23,14 @@ import com.viaversion.viaversion.protocols.base.packet.BaseClientboundPacket;
|
||||
public enum ClientboundLoginPackets implements BaseClientboundPacket {
|
||||
LOGIN_DISCONNECT, // 0x00
|
||||
HELLO, // 0x01
|
||||
GAME_PROFILE, // 0x02
|
||||
LOGIN_FINISHED, // 0x02
|
||||
LOGIN_COMPRESSION, // 0x03
|
||||
CUSTOM_QUERY, // 0x04
|
||||
COOKIE_REQUEST; // 0x05
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static final ClientboundLoginPackets GAME_PROFILE = LOGIN_FINISHED;
|
||||
|
||||
@Override
|
||||
public final int getId() {
|
||||
return ordinal();
|
||||
|
@ -128,7 +128,7 @@ public class ClientboundBaseProtocol1_7 extends AbstractProtocol<BaseClientbound
|
||||
});
|
||||
|
||||
// Track player name/uuid and setup connection + track state
|
||||
registerClientbound(ClientboundLoginPackets.GAME_PROFILE, wrapper -> {
|
||||
registerClientbound(ClientboundLoginPackets.LOGIN_FINISHED, wrapper -> {
|
||||
final ProtocolInfo info = wrapper.user().getProtocolInfo();
|
||||
|
||||
if (info.serverProtocolVersion().olderThan(ProtocolVersion.v1_16)) {
|
||||
|
@ -81,7 +81,7 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol<ClientboundPackets1_1
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_15.AWARD_STATS);
|
||||
|
||||
// Login Success
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, wrapper -> {
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_FINISHED, wrapper -> {
|
||||
// Transform string to a uuid
|
||||
UUID uuid = UUID.fromString(wrapper.read(Types.STRING));
|
||||
wrapper.write(Types.UUID, uuid);
|
||||
|
@ -232,7 +232,7 @@ public final class Protocol1_18_2To1_19 extends AbstractProtocol<ClientboundPack
|
||||
cancelServerbound(ServerboundPackets1_19.CHAT_PREVIEW);
|
||||
|
||||
// Login changes
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, new PacketHandlers() {
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_FINISHED, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.UUID); // UUID
|
||||
|
@ -211,7 +211,7 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol<ClientboundPa
|
||||
|
||||
new CommandRewriter1_19_4<>(this).registerDeclareCommands1_19(ClientboundPackets1_20_3.COMMANDS);
|
||||
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, wrapper -> {
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_FINISHED, wrapper -> {
|
||||
wrapper.passthrough(Types.UUID); // UUID
|
||||
wrapper.passthrough(Types.STRING); // Name
|
||||
|
||||
|
@ -144,7 +144,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
|
||||
// We need to wait for it send the login ack before actually sending the play login,
|
||||
// hence packets are added to a queue. With the data from the login packet, we sent what is needed
|
||||
// during the configuration phase before finally transitioning to the play state with the client as well.
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE, wrapper -> {
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_FINISHED, wrapper -> {
|
||||
wrapper.user().get(ConfigurationState.class).setBridgePhase(BridgePhase.PROFILE_SENT);
|
||||
wrapper.user().getProtocolInfo().setServerState(State.PLAY);
|
||||
});
|
||||
|
@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.rewriter.ComponentRewriter;
|
||||
@ -31,6 +32,7 @@ import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
||||
@ -94,6 +96,20 @@ public final class Protocol1_21To1_21_2 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
cancelServerbound(ServerboundPackets1_21_2.BUNDLE_ITEM_SELECTED);
|
||||
cancelServerbound(ServerboundPackets1_21_2.CLIENT_TICK_END);
|
||||
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_FINISHED, wrapper -> {
|
||||
wrapper.passthrough(Types.UUID); // UUID
|
||||
wrapper.passthrough(Types.STRING); // Name
|
||||
|
||||
final int properties = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int i = 0; i < properties; i++) {
|
||||
wrapper.passthrough(Types.STRING); // Name
|
||||
wrapper.passthrough(Types.STRING); // Value
|
||||
wrapper.passthrough(Types.OPTIONAL_STRING); // Signature
|
||||
}
|
||||
|
||||
wrapper.read(Types.BOOLEAN); // Strict error handling
|
||||
});
|
||||
}
|
||||
|
||||
private void clientInformation(final PacketWrapper wrapper) {
|
||||
|
@ -228,7 +228,7 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter<
|
||||
|
||||
@Override
|
||||
public void handleRecipeType(final PacketWrapper wrapper, final String type) {
|
||||
if (type.equals("crafting_special_suspiciousstew")) {
|
||||
if (type.equals("crafting_special_suspiciousstew") || type.equals("crafting_special_shulkerboxcoloring")) {
|
||||
wrapper.read(Types.VAR_INT); // Crafting book category
|
||||
} else {
|
||||
super.handleRecipeType(wrapper, type);
|
||||
|
@ -54,6 +54,9 @@ public class RecipeRewriter<C extends ClientboundPacketType> {
|
||||
recipeHandlers.put("smithing_transform", this::handleSmithingTransform);
|
||||
recipeHandlers.put("smithing_trim", this::handleSmithingTrim);
|
||||
recipeHandlers.put("crafting_decorated_pot", this::handleSimpleRecipe);
|
||||
|
||||
// Added in 1.21.2
|
||||
recipeHandlers.put("crafting_transmute", this::handleTransmute);
|
||||
}
|
||||
|
||||
public void handleRecipeType(PacketWrapper wrapper, String type) {
|
||||
@ -160,6 +163,22 @@ public class RecipeRewriter<C extends ClientboundPacketType> {
|
||||
handleIngredient(wrapper); // Additions
|
||||
}
|
||||
|
||||
private void handleTransmute(final PacketWrapper wrapper) {
|
||||
wrapper.passthrough(Types.STRING); // Group
|
||||
wrapper.passthrough(Types.VAR_INT); // Crafting book category
|
||||
handleIngredient(wrapper); // Input
|
||||
handleIngredient(wrapper); // Material
|
||||
final int resultItemId = wrapper.read(Types.VAR_INT);
|
||||
wrapper.write(Types.VAR_INT, rewrite(resultItemId));
|
||||
}
|
||||
|
||||
protected int rewrite(final int itemId) {
|
||||
if (protocol.getMappingData() != null && protocol.getItemRewriter() != null) {
|
||||
return protocol.getMappingData().getNewItemId(itemId);
|
||||
}
|
||||
return itemId;
|
||||
}
|
||||
|
||||
protected @Nullable Item rewrite(UserConnection connection, @Nullable Item item) {
|
||||
if (protocol.getItemRewriter() != null) {
|
||||
return protocol.getItemRewriter().handleItemToClient(connection, item);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user