This commit is contained in:
Nassim Jahnke 2022-05-04 19:15:23 +02:00
parent 5b9f775743
commit b9f80754e0
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
7 changed files with 156 additions and 15 deletions

View File

@ -80,7 +80,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_17_1 = register(756, "1.17.1");
public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new VersionRange("1.18", 0, 1));
public static final ProtocolVersion v1_18_2 = register(758, "1.18.2");
public static final ProtocolVersion v1_19 = register(759, 82, "1.19");
public static final ProtocolVersion v1_19 = register(759, 83, "1.19");
public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
public static ProtocolVersion register(int version, String name) {

View File

@ -51,7 +51,7 @@ import java.security.PublicKey;
import java.security.spec.EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPackets1_18, ClientboundPackets1_19, ServerboundPackets1_17, ServerboundPackets1_17> {
public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPackets1_18, ClientboundPackets1_19, ServerboundPackets1_17, ServerboundPackets1_19> {
public static final MappingData MAPPINGS = new MappingDataBase("1.18", "1.19", true);
private static final KeyFactory RSA_FACTORY;
@ -68,7 +68,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
private final InventoryPackets itemRewriter = new InventoryPackets(this);
public Protocol1_19To1_18_2() {
super(ClientboundPackets1_18.class, ClientboundPackets1_19.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
super(ClientboundPackets1_18.class, ClientboundPackets1_19.class, ServerboundPackets1_17.class, ServerboundPackets1_19.class);
}
@Override
@ -167,20 +167,38 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
@Override
public void registerMap() {
map(Type.COMPONENT); // Message
map(Type.BYTE); // Type
map(Type.BYTE, Type.VAR_INT); // Type
read(Type.UUID); // Sender
}
});
registerServerbound(ServerboundPackets1_17.CHAT_MESSAGE, new PacketRemapper() {
registerServerbound(ServerboundPackets1_19.CHAT_MESSAGE, new PacketRemapper() {
@Override
public void registerMap() {
read(Type.LONG); // Timestamp
map(Type.STRING); // Message
read(Type.LONG); // Timestamp
read(Type.LONG); // Salt
read(Type.BYTE_ARRAY_PRIMITIVE); // Signature
}
});
registerServerbound(ServerboundPackets1_19.CHAT_COMMAND, ServerboundPackets1_17.CHAT_MESSAGE, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.STRING); // Command
read(Type.LONG); // Timestamp
read(Type.LONG); // Salt
handler(wrapper -> {
final String command = wrapper.get(Type.STRING, 0);
wrapper.set(Type.STRING, 0, "/" + command);
final int signatures = wrapper.read(Type.VAR_INT);
for (int i = 0; i < signatures; i++) {
wrapper.read(Type.STRING); // Argument name
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); // Signature
}
});
}
});
// Login changes
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), new PacketRemapper() {

View File

@ -0,0 +1,83 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2022 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viaversion.protocols.protocol1_19to1_18_2;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
public enum ServerboundPackets1_19 implements ServerboundPacketType {
TELEPORT_CONFIRM, // 0x00
QUERY_BLOCK_NBT, // 0x01
SET_DIFFICULTY, // 0x02
CHAT_COMMAND, // 0x03
CHAT_MESSAGE, // 0x04
CLIENT_STATUS, // 0x05
CLIENT_SETTINGS, // 0x06
TAB_COMPLETE, // 0x07
CLICK_WINDOW_BUTTON, // 0x08
CLICK_WINDOW, // 0x09
CLOSE_WINDOW, // 0x0A
PLUGIN_MESSAGE, // 0x0B
EDIT_BOOK, // 0x0C
ENTITY_NBT_REQUEST, // 0x0D
INTERACT_ENTITY, // 0x0E
GENERATE_JIGSAW, // 0x0F
KEEP_ALIVE, // 0x10
LOCK_DIFFICULTY, // 0x11
PLAYER_POSITION, // 0x12
PLAYER_POSITION_AND_ROTATION, // 0x13
PLAYER_ROTATION, // 0x14
PLAYER_MOVEMENT, // 0x15
VEHICLE_MOVE, // 0x16
STEER_BOAT, // 0x17
PICK_ITEM, // 0x18
CRAFT_RECIPE_REQUEST, // 0x19
PLAYER_ABILITIES, // 0x1A
PLAYER_DIGGING, // 0x1B
ENTITY_ACTION, // 0x1C
STEER_VEHICLE, // 0x1D
PONG, // 0x1E
RECIPE_BOOK_DATA, // 0x1F
SEEN_RECIPE, // 0x20
RENAME_ITEM, // 0x21
RESOURCE_PACK_STATUS, // 0x22
ADVANCEMENT_TAB, // 0x23
SELECT_TRADE, // 0x24
SET_BEACON_EFFECT, // 0x25
HELD_ITEM_CHANGE, // 0x26
UPDATE_COMMAND_BLOCK, // 0x27
UPDATE_COMMAND_BLOCK_MINECART, // 0x28
CREATIVE_INVENTORY_ACTION, // 0x29
UPDATE_JIGSAW_BLOCK, // 0x2A
UPDATE_STRUCTURE_BLOCK, // 0x2B
UPDATE_SIGN, // 0x2C
ANIMATION, // 0x2D
SPECTATE, // 0x2E
PLAYER_BLOCK_PLACEMENT, // 0x2F
USE_ITEM; // 0x30
@Override
public int getId() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}

View File

@ -171,6 +171,46 @@ public final class EntityPackets extends EntityRewriter<Protocol1_19To1_18_2> {
handler(worldDataTrackerHandler(0));
}
});
protocol.registerClientbound(ClientboundPackets1_18.PLAYER_INFO, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
final int action = wrapper.passthrough(Type.VAR_INT);
final int entries = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < entries; i++) {
wrapper.passthrough(Type.UUID); // UUID
if (action == 0) { // Add player
wrapper.passthrough(Type.STRING); // Player Name
final int properties = wrapper.passthrough(Type.VAR_INT);
for (int j = 0; j < properties; j++) {
wrapper.passthrough(Type.STRING); // Name
wrapper.passthrough(Type.STRING); // Value
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.STRING); // Signature
}
}
wrapper.passthrough(Type.VAR_INT); // Gamemode
wrapper.passthrough(Type.VAR_INT); // Ping
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.COMPONENT); // Display name
}
// No public profile signature
wrapper.write(Type.BOOLEAN, false);
} else if (action == 1 || action == 2) { // Update gamemode/update latency
wrapper.passthrough(Type.VAR_INT);
} else if (action == 3) { // Update display name
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.COMPONENT);
}
}
}
});
}
});
}
private static int to3dId(final int id) {

View File

@ -21,9 +21,9 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage.SequenceStorage;
import com.viaversion.viaversion.rewriter.ItemRewriter;
@ -58,12 +58,12 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_19To1_18_2> {
}
});
registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
registerClickWindow1_17_1(ServerboundPackets1_19.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_19.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_18.WINDOW_PROPERTY);
protocol.registerServerbound(ServerboundPackets1_17.PLAYER_DIGGING, new PacketRemapper() {
protocol.registerServerbound(ServerboundPackets1_19.PLAYER_DIGGING, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Action
@ -72,7 +72,7 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_19To1_18_2> {
handler(sequenceHandler());
}
});
protocol.registerServerbound(ServerboundPackets1_17.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
protocol.registerServerbound(ServerboundPackets1_19.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Hand
@ -85,7 +85,7 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_19To1_18_2> {
handler(sequenceHandler());
}
});
protocol.registerServerbound(ServerboundPackets1_17.USE_ITEM, new PacketRemapper() {
protocol.registerServerbound(ServerboundPackets1_19.USE_ITEM, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Hand

View File

@ -24,11 +24,11 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage.SequenceStorage;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.util.MathUtil;
@ -73,7 +73,7 @@ public final class WorldPackets {
}
});
protocol.registerServerbound(ServerboundPackets1_17.SET_BEACON_EFFECT, new PacketRemapper() {
protocol.registerServerbound(ServerboundPackets1_19.SET_BEACON_EFFECT, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {

View File

@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=4.3.0-22w17a-SNAPSHOT
projectVersion=4.3.0-22w18a-SNAPSHOT
# Gradle properties
org.gradle.daemon=true