Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Safety checks, packet type constants for 1.12->1.13 protocol
Dieser Commit ist enthalten in:
Ursprung
d7d4e58106
Commit
9f80553749
@ -76,9 +76,14 @@ public abstract class Protocol {
|
||||
|
||||
for (ClientboundPacketType packet : oldClientboundPacketEnum.getEnumConstants()) {
|
||||
ClientboundPacketType mappedPacket = newClientboundPackets.get(packet.name());
|
||||
if (mappedPacket == null) continue; // Packet doesn't exist on new client
|
||||
|
||||
int oldId = packet.ordinal();
|
||||
if (mappedPacket == null) {
|
||||
// Packet doesn't exist on new client
|
||||
Preconditions.checkArgument(hasRegisteredOutgoing(State.PLAY, oldId),
|
||||
"Packet " + mappedPacket + " in " + getClass().getSimpleName() + " has no mapping - it needs to be manually cancelled or remapped!");
|
||||
continue;
|
||||
}
|
||||
|
||||
int newId = mappedPacket.ordinal();
|
||||
if (!hasRegisteredOutgoing(State.PLAY, oldId)) {
|
||||
registerOutgoing(State.PLAY, oldId, newId);
|
||||
@ -95,10 +100,15 @@ public abstract class Protocol {
|
||||
|
||||
for (ServerboundPacketType packet : newServerboundPacketEnum.getEnumConstants()) {
|
||||
ServerboundPacketType mappedPacket = oldServerboundConstants.get(packet.name());
|
||||
if (mappedPacket == null) continue; // Packet doesn't exist on old server
|
||||
int newId = packet.ordinal();
|
||||
if (mappedPacket == null) {
|
||||
// Packet doesn't exist on old server
|
||||
Preconditions.checkArgument(hasRegisteredIncoming(State.PLAY, newId),
|
||||
"Packet " + mappedPacket + " in " + getClass().getSimpleName() + " has no mapping - it needs to be manually cancelled or remapped!");
|
||||
continue;
|
||||
}
|
||||
|
||||
int oldId = mappedPacket.ordinal();
|
||||
int newId = packet.ordinal();
|
||||
if (!hasRegisteredIncoming(State.PLAY, newId)) {
|
||||
registerIncoming(State.PLAY, oldId, newId);
|
||||
}
|
||||
@ -276,14 +286,14 @@ public abstract class Protocol {
|
||||
/**
|
||||
* Registers an outgoing protocol.
|
||||
*
|
||||
* @param oldPacketType packet type the server sends
|
||||
* @param newPacketType new packet type
|
||||
* @param packetType packet type the server initially sends
|
||||
* @param mappedPacketType packet type after transforming for the client
|
||||
* @param packetRemapper remapper
|
||||
*/
|
||||
public void registerOutgoing(ClientboundPacketType oldPacketType, ClientboundPacketType newPacketType, PacketRemapper packetRemapper) {
|
||||
Preconditions.checkArgument(oldPacketType.getClass() == oldClientboundPacketEnum);
|
||||
Preconditions.checkArgument(newPacketType == null || newPacketType.getClass() == newClientboundPacketEnum);
|
||||
registerOutgoing(State.PLAY, oldPacketType.ordinal(), newPacketType != null ? newPacketType.ordinal() : -1, packetRemapper);
|
||||
public void registerOutgoing(ClientboundPacketType packetType, ClientboundPacketType mappedPacketType, PacketRemapper packetRemapper) {
|
||||
Preconditions.checkArgument(packetType.getClass() == oldClientboundPacketEnum);
|
||||
Preconditions.checkArgument(mappedPacketType == null || mappedPacketType.getClass() == newClientboundPacketEnum);
|
||||
registerOutgoing(State.PLAY, packetType.ordinal(), mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetRemapper);
|
||||
}
|
||||
|
||||
public void registerOutgoing(ClientboundPacketType oldPacketType, ClientboundPacketType newPacketType) {
|
||||
@ -316,14 +326,14 @@ public abstract class Protocol {
|
||||
/**
|
||||
* Registers an incoming protocol.
|
||||
*
|
||||
* @param oldPacketType packet type for the server
|
||||
* @param newPacketType packet type the client sends
|
||||
* @param packetType packet type initially sent by the client
|
||||
* @param mappedPacketType packet type after transforming for the server
|
||||
* @param packetRemapper remapper
|
||||
*/
|
||||
public void registerIncoming(ServerboundPacketType oldPacketType, ServerboundPacketType newPacketType, PacketRemapper packetRemapper) {
|
||||
Preconditions.checkArgument(oldPacketType == null || oldPacketType.getClass() == oldServerboundPacketEnum);
|
||||
Preconditions.checkArgument(newPacketType.getClass() == newServerboundPacketEnum);
|
||||
registerIncoming(State.PLAY, oldPacketType != null ? oldPacketType.ordinal() : -1, newPacketType.ordinal(), packetRemapper);
|
||||
public void registerIncoming(ServerboundPacketType packetType, ServerboundPacketType mappedPacketType, PacketRemapper packetRemapper) {
|
||||
Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum);
|
||||
Preconditions.checkArgument(mappedPacketType == null || mappedPacketType.getClass() == oldServerboundPacketEnum);
|
||||
registerIncoming(State.PLAY, mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetType.ordinal(), packetRemapper);
|
||||
}
|
||||
|
||||
public void cancelIncoming(ServerboundPacketType packetType) {
|
||||
|
@ -0,0 +1,87 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_12_1to1_12;
|
||||
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
|
||||
public enum ClientboundPackets1_12_1 implements ClientboundPacketType {
|
||||
|
||||
SPAWN_ENTITY, // 0x00
|
||||
SPAWN_EXPERIENCE_ORB, // 0x01
|
||||
SPAWN_GLOBAL_ENTITY, // 0x02
|
||||
SPAWN_MOB, // 0x03
|
||||
SPAWN_PAINTING, // 0x04
|
||||
SPAWN_PLAYER, // 0x05
|
||||
ENTITY_ANIMATION, // 0x06
|
||||
STATISTICS, // 0x07
|
||||
BLOCK_BREAK_ANIMATION, // 0x08
|
||||
BLOCK_ENTITY_DATA, // 0x09
|
||||
BLOCK_ACTION, // 0x0A
|
||||
BLOCK_CHANGE, // 0x0B
|
||||
BOSSBAR, // 0x0C
|
||||
SERVER_DIFFICULTY, // 0x0D
|
||||
TAB_COMPLETE, // 0x0E
|
||||
CHAT_MESSAGE, // 0x0F
|
||||
MULTI_BLOCK_CHANGE, // 0x10
|
||||
WINDOW_CONFIRMATION, // 0x11
|
||||
CLOSE_WINDOW, // 0x12
|
||||
OPEN_WINDOW, // 0x13
|
||||
WINDOW_ITEMS, // 0x14
|
||||
WINDOW_PROPERTY, // 0x15
|
||||
SET_SLOT, // 0x16
|
||||
COOLDOWN, // 0x17
|
||||
PLUGIN_MESSAGE, // 0x18
|
||||
NAMED_SOUND, // 0x19
|
||||
DISCONNECT, // 0x1A
|
||||
ENTITY_STATUS, // 0x1B
|
||||
EXPLOSION, // 0x1C
|
||||
UNLOAD_CHUNK, // 0x1D
|
||||
GAME_EVENT, // 0x1E
|
||||
KEEP_ALIVE, // 0x1F
|
||||
CHUNK_DATA, // 0x20
|
||||
EFFECT, // 0x21
|
||||
SPAWN_PARTICLE, // 0x22
|
||||
JOIN_GAME, // 0x23
|
||||
MAP_DATA, // 0x24
|
||||
ENTITY_MOVEMENT, // 0x25
|
||||
ENTITY_POSITION, // 0x26
|
||||
ENTITY_POSITION_AND_ROTATION, // 0x27
|
||||
ENTITY_ROTATION, // 0x28
|
||||
VEHICLE_MOVE, // 0x29
|
||||
OPEN_SIGN_EDITOR, // 0x2A
|
||||
CRAFT_RECIPE_RESPONSE, // 0x2B
|
||||
PLAYER_ABILITIES, // 0x2C
|
||||
COMBAT_EVENT, // 0x2D
|
||||
PLAYER_INFO, // 0x2E
|
||||
PLAYER_POSITION, // 0x2F
|
||||
USE_BED, // 0x30
|
||||
UNLOCK_RECIPES, // 0x31
|
||||
DESTROY_ENTITIES, // 0x32
|
||||
REMOVE_ENTITY_EFFECT, // 0x33
|
||||
RESOURCE_PACK, // 0x34
|
||||
RESPAWN, // 0x35
|
||||
ENTITY_HEAD_LOOK, // 0x36
|
||||
SELECT_ADVANCEMENTS_TAB, // 0x37
|
||||
WORLD_BORDER, // 0x38
|
||||
CAMERA, // 0x39
|
||||
HELD_ITEM_CHANGE, // 0x3A
|
||||
DISPLAY_SCOREBOARD, // 0x3B
|
||||
ENTITY_METADATA, // 0x3C
|
||||
ATTACH_ENTITY, // 0x3D
|
||||
ENTITY_VELOCITY, // 0x3E
|
||||
ENTITY_EQUIPMENT, // 0x3F
|
||||
SET_EXPERIENCE, // 0x40
|
||||
UPDATE_HEALTH, // 0x41
|
||||
SCOREBOARD_OBJECTIVE, // 0x42
|
||||
SET_PASSENGERS, // 0x43
|
||||
TEAMS, // 0x44
|
||||
UPDATE_SCORE, // 0x45
|
||||
SPAWN_POSITION, // 0x46
|
||||
TIME_UPDATE, // 0x47
|
||||
TITLE, // 0x48
|
||||
SOUND, // 0x49
|
||||
TAB_LIST, // 0x4A
|
||||
COLLECT_ITEM, // 0x4B
|
||||
ENTITY_TELEPORT, // 0x4C
|
||||
ADVANCEMENTS, // 0x4D
|
||||
ENTITY_PROPERTIES, // 0x4E
|
||||
ENTITY_EFFECT, // 0x4F
|
||||
}
|
@ -1,90 +1,17 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_12_1to1_12;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
|
||||
public class Protocol1_12_1To1_12 extends Protocol {
|
||||
|
||||
public Protocol1_12_1To1_12() {
|
||||
super(ClientboundPackets1_12.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12.class, ServerboundPackets1_12_1.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerOutgoing(State.PLAY, -1, 0x2B); // TODO new packet?
|
||||
registerOutgoing(State.PLAY, 0x2b, 0x2c); // Player Abilities (clientbound)
|
||||
registerOutgoing(State.PLAY, 0x2c, 0x2d); // Combat Event
|
||||
registerOutgoing(State.PLAY, 0x2d, 0x2e); // Player List Item
|
||||
registerOutgoing(State.PLAY, 0x2e, 0x2f); // Player Position And Look (clientbound)
|
||||
registerOutgoing(State.PLAY, 0x2f, 0x30); // Use Bed
|
||||
registerOutgoing(State.PLAY, 0x30, 0x31); // Unlock Recipes
|
||||
registerOutgoing(State.PLAY, 0x31, 0x32); // Destroy Entities
|
||||
registerOutgoing(State.PLAY, 0x32, 0x33); // Remove Entity Effect
|
||||
registerOutgoing(State.PLAY, 0x33, 0x34); // Resource Pack Send
|
||||
registerOutgoing(State.PLAY, 0x34, 0x35); // Respawn
|
||||
registerOutgoing(State.PLAY, 0x35, 0x36); // Entity Head Look
|
||||
registerOutgoing(State.PLAY, 0x36, 0x37); // Select Advancement Tab
|
||||
registerOutgoing(State.PLAY, 0x37, 0x38); // World Border
|
||||
registerOutgoing(State.PLAY, 0x38, 0x39); // Camera
|
||||
registerOutgoing(State.PLAY, 0x39, 0x3a); // Held Item Change (clientbound)
|
||||
registerOutgoing(State.PLAY, 0x3a, 0x3b); // Display Scoreboard
|
||||
registerOutgoing(State.PLAY, 0x3b, 0x3c); // Entity Metadata
|
||||
registerOutgoing(State.PLAY, 0x3c, 0x3d); // Attach Entity
|
||||
registerOutgoing(State.PLAY, 0x3d, 0x3e); // Entity Velocity
|
||||
registerOutgoing(State.PLAY, 0x3e, 0x3f); // Entity Equipment
|
||||
registerOutgoing(State.PLAY, 0x3f, 0x40); // Set Experience
|
||||
registerOutgoing(State.PLAY, 0x40, 0x41); // Update Health
|
||||
registerOutgoing(State.PLAY, 0x41, 0x42); // Scoreboard Objective
|
||||
registerOutgoing(State.PLAY, 0x42, 0x43); // Set Passengers
|
||||
registerOutgoing(State.PLAY, 0x43, 0x44); // Teams
|
||||
registerOutgoing(State.PLAY, 0x44, 0x45); // Update Sc
|
||||
registerOutgoing(State.PLAY, 0x45, 0x46); // Spawn Position
|
||||
registerOutgoing(State.PLAY, 0x46, 0x47); // Time Update
|
||||
registerOutgoing(State.PLAY, 0x47, 0x48); // Title
|
||||
registerOutgoing(State.PLAY, 0x48, 0x49); // Sound Effect
|
||||
registerOutgoing(State.PLAY, 0x49, 0x4a); // Player List Header And Footer
|
||||
registerOutgoing(State.PLAY, 0x4a, 0x4b); // Collect Item
|
||||
registerOutgoing(State.PLAY, 0x4b, 0x4c); // Entity Teleport
|
||||
registerOutgoing(State.PLAY, 0x4c, 0x4d); // Advancements
|
||||
registerOutgoing(State.PLAY, 0x4d, 0x4e); // Entity Properties
|
||||
registerOutgoing(State.PLAY, 0x4e, 0x4f); // Entity Effect
|
||||
|
||||
// TODO Where did the Prepare Crafting Grid packet go to?
|
||||
registerIncoming(State.PLAY, 0x01, -1); // Prepare Crafting Grid (removed)
|
||||
|
||||
registerIncoming(State.PLAY, 0x02, 0x01); // Tab-Complete (serverbound)
|
||||
registerIncoming(State.PLAY, 0x03, 0x02); // Chat Message (serverbound)
|
||||
registerIncoming(State.PLAY, 0x04, 0x03); // Client Status
|
||||
registerIncoming(State.PLAY, 0x05, 0x04); // Client Settings
|
||||
registerIncoming(State.PLAY, 0x06, 0x05); // Confirm Transaction (serverbound)
|
||||
registerIncoming(State.PLAY, 0x07, 0x06); // Enchant Item
|
||||
registerIncoming(State.PLAY, 0x08, 0x07); // Click Window
|
||||
registerIncoming(State.PLAY, 0x09, 0x08); // Close Window (serverbound)
|
||||
registerIncoming(State.PLAY, 0x0a, 0x09); // Plugin Message (serverbound)
|
||||
registerIncoming(State.PLAY, 0x0b, 0x0a); // Use Entity
|
||||
registerIncoming(State.PLAY, 0x0c, 0x0b); // Keep Alive (serverbound)
|
||||
registerIncoming(State.PLAY, 0x0d, 0x0c); // Player
|
||||
registerIncoming(State.PLAY, 0x0e, 0x0d); // Player Position
|
||||
registerIncoming(State.PLAY, 0x0f, 0x0e); // Player Position And Look (serverbound)
|
||||
registerIncoming(State.PLAY, 0x10, 0x0f); // Player Look
|
||||
registerIncoming(State.PLAY, 0x11, 0x10); // Vehicle Move (serverbound)
|
||||
registerIncoming(State.PLAY, 0x12, 0x11); // Steer Boat
|
||||
|
||||
// TODO hello new packet
|
||||
registerIncoming(State.PLAY, -1, 0x12, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Unknown
|
||||
map(Type.VAR_INT); // 1 - Unknown
|
||||
map(Type.BOOLEAN); // 2 - Unknown
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
cancelIncoming(ServerboundPackets1_12_1.CRAFT_RECIPE_REQUEST);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_12_1to1_12;
|
||||
|
||||
import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
|
||||
|
||||
public enum ServerboundPackets1_12_1 implements ServerboundPacketType {
|
||||
|
||||
TELEPORT_CONFIRM, // 0x00
|
||||
TAB_COMPLETE, // 0x01
|
||||
CHAT_MESSAGE, // 0x02
|
||||
CLIENT_STATUS, // 0x03
|
||||
CLIENT_SETTINGS, // 0x04
|
||||
WINDOW_CONFIRMATION, // 0x05
|
||||
CLICK_WINDOW_BUTTON, // 0x06
|
||||
CLICK_WINDOW, // 0x07
|
||||
CLOSE_WINDOW, // 0x08
|
||||
PLUGIN_MESSAGE, // 0x09
|
||||
INTERACT_ENTITY, // 0x0A
|
||||
KEEP_ALIVE, // 0x0B
|
||||
PLAYER_MOVEMENT, // 0x0C
|
||||
PLAYER_POSITION, // 0x0D
|
||||
PLAYER_POSITION_AND_ROTATION, // 0x0E
|
||||
PLAYER_ROTATION, // 0x0F
|
||||
VEHICLE_MOVE, // 0x10
|
||||
STEER_BOAT, // 0x11
|
||||
CRAFT_RECIPE_REQUEST, // 0x12
|
||||
PLAYER_ABILITIES, // 0x13
|
||||
PLAYER_DIGGING, // 0x14
|
||||
ENTITY_ACTION, // 0x15
|
||||
STEER_VEHICLE, // 0x16
|
||||
RECIPE_BOOK_DATA, // 0x17
|
||||
RESOURCE_PACK_STATUS, // 0x18
|
||||
ADVANCEMENT_TAB, // 0x19
|
||||
HELD_ITEM_CHANGE, // 0x1A
|
||||
CREATIVE_INVENTORY_ACTION, // 0x1B
|
||||
UPDATE_SIGN, // 0x1C
|
||||
ANIMATION, // 0x1D
|
||||
SPECTATE, // 0x1E
|
||||
PLAYER_BLOCK_PLACEMENT, // 0x1F
|
||||
USE_ITEM, // 0x20
|
||||
}
|
@ -3,23 +3,25 @@ package us.myles.ViaVersion.protocols.protocol1_12_2to1_12_1;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
|
||||
public class Protocol1_12_2To1_12_1 extends Protocol {
|
||||
|
||||
public Protocol1_12_2To1_12_1() {
|
||||
super(ClientboundPackets1_12_1.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12_1.class, ServerboundPackets1_12_1.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Outgoing
|
||||
// 0x1f - Keep alive
|
||||
registerOutgoing(State.PLAY, 0x1f, 0x1f, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT, Type.LONG);
|
||||
}
|
||||
}); // Keep alive
|
||||
// Incoming
|
||||
// 0xb - Keep alive
|
||||
registerIncoming(State.PLAY, 0xb, 0xb, new PacketRemapper() {
|
||||
});
|
||||
|
||||
registerIncoming(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.LONG, Type.VAR_INT);
|
||||
|
@ -0,0 +1,86 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1;
|
||||
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
|
||||
public enum ClientboundPackets1_12 implements ClientboundPacketType {
|
||||
|
||||
SPAWN_ENTITY, // 0x00
|
||||
SPAWN_EXPERIENCE_ORB, // 0x01
|
||||
SPAWN_GLOBAL_ENTITY, // 0x02
|
||||
SPAWN_MOB, // 0x03
|
||||
SPAWN_PAINTING, // 0x04
|
||||
SPAWN_PLAYER, // 0x05
|
||||
ENTITY_ANIMATION, // 0x06
|
||||
STATISTICS, // 0x07
|
||||
BLOCK_BREAK_ANIMATION, // 0x08
|
||||
BLOCK_ENTITY_DATA, // 0x09
|
||||
BLOCK_ACTION, // 0x0A
|
||||
BLOCK_CHANGE, // 0x0B
|
||||
BOSSBAR, // 0x0C
|
||||
SERVER_DIFFICULTY, // 0x0D
|
||||
TAB_COMPLETE, // 0x0E
|
||||
CHAT_MESSAGE, // 0x0F
|
||||
MULTI_BLOCK_CHANGE, // 0x10
|
||||
WINDOW_CONFIRMATION, // 0x11
|
||||
CLOSE_WINDOW, // 0x12
|
||||
OPEN_WINDOW, // 0x13
|
||||
WINDOW_ITEMS, // 0x14
|
||||
WINDOW_PROPERTY, // 0x15
|
||||
SET_SLOT, // 0x16
|
||||
COOLDOWN, // 0x17
|
||||
PLUGIN_MESSAGE, // 0x18
|
||||
NAMED_SOUND, // 0x19
|
||||
DISCONNECT, // 0x1A
|
||||
ENTITY_STATUS, // 0x1B
|
||||
EXPLOSION, // 0x1C
|
||||
UNLOAD_CHUNK, // 0x1D
|
||||
GAME_EVENT, // 0x1E
|
||||
KEEP_ALIVE, // 0x1F
|
||||
CHUNK_DATA, // 0x20
|
||||
EFFECT, // 0x21
|
||||
SPAWN_PARTICLE, // 0x22
|
||||
JOIN_GAME, // 0x23
|
||||
MAP_DATA, // 0x24
|
||||
ENTITY_MOVEMENT, // 0x25
|
||||
ENTITY_POSITION, // 0x26
|
||||
ENTITY_POSITION_AND_ROTATION, // 0x27
|
||||
ENTITY_ROTATION, // 0x28
|
||||
VEHICLE_MOVE, // 0x29
|
||||
OPEN_SIGN_EDITOR, // 0x2A
|
||||
PLAYER_ABILITIES, // 0x2B
|
||||
COMBAT_EVENT, // 0x2C
|
||||
PLAYER_INFO, // 0x2D
|
||||
PLAYER_POSITION, // 0x2E
|
||||
USE_BED, // 0x2F
|
||||
UNLOCK_RECIPES, // 0x30
|
||||
DESTROY_ENTITIES, // 0x31
|
||||
REMOVE_ENTITY_EFFECT, // 0x32
|
||||
RESOURCE_PACK, // 0x33
|
||||
RESPAWN, // 0x34
|
||||
ENTITY_HEAD_LOOK, // 0x35
|
||||
SELECT_ADVANCEMENTS_TAB, // 0x36
|
||||
WORLD_BORDER, // 0x37
|
||||
CAMERA, // 0x38
|
||||
HELD_ITEM_CHANGE, // 0x39
|
||||
DISPLAY_SCOREBOARD, // 0x3A
|
||||
ENTITY_METADATA, // 0x3B
|
||||
ATTACH_ENTITY, // 0x3C
|
||||
ENTITY_VELOCITY, // 0x3D
|
||||
ENTITY_EQUIPMENT, // 0x3E
|
||||
SET_EXPERIENCE, // 0x3F
|
||||
UPDATE_HEALTH, // 0x40
|
||||
SCOREBOARD_OBJECTIVE, // 0x41
|
||||
SET_PASSENGERS, // 0x42
|
||||
TEAMS, // 0x43
|
||||
UPDATE_SCORE, // 0x44
|
||||
SPAWN_POSITION, // 0x45
|
||||
TIME_UPDATE, // 0x46
|
||||
TITLE, // 0x47
|
||||
SOUND, // 0x48
|
||||
TAB_LIST, // 0x49
|
||||
COLLECT_ITEM, // 0x4A
|
||||
ENTITY_TELEPORT, // 0x4B
|
||||
ADVANCEMENTS, // 0x4C
|
||||
ENTITY_PROPERTIES, // 0x4D
|
||||
ENTITY_EFFECT, // 0x4E
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1;
|
||||
|
||||
import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
|
||||
|
||||
public enum ServerboundPackets1_12 implements ServerboundPacketType {
|
||||
|
||||
TELEPORT_CONFIRM, // 0x00
|
||||
PREPARE_CRAFTING_GRID, // 0x01
|
||||
TAB_COMPLETE, // 0x02
|
||||
CHAT_MESSAGE, // 0x03
|
||||
CLIENT_STATUS, // 0x04
|
||||
CLIENT_SETTINGS, // 0x05
|
||||
WINDOW_CONFIRMATION, // 0x06
|
||||
CLICK_WINDOW_BUTTON, // 0x07
|
||||
CLICK_WINDOW, // 0x08
|
||||
CLOSE_WINDOW, // 0x09
|
||||
PLUGIN_MESSAGE, // 0x0A
|
||||
INTERACT_ENTITY, // 0x0B
|
||||
KEEP_ALIVE, // 0x0C
|
||||
PLAYER_MOVEMENT, // 0x0D
|
||||
PLAYER_POSITION, // 0x0E
|
||||
PLAYER_POSITION_AND_ROTATION, // 0x0F
|
||||
PLAYER_ROTATION, // 0x10
|
||||
VEHICLE_MOVE, // 0x11
|
||||
STEER_BOAT, // 0x12
|
||||
PLAYER_ABILITIES, // 0x13
|
||||
PLAYER_DIGGING, // 0x14
|
||||
ENTITY_ACTION, // 0x15
|
||||
STEER_VEHICLE, // 0x16
|
||||
RECIPE_BOOK_DATA, // 0x17
|
||||
RESOURCE_PACK_STATUS, // 0x18
|
||||
ADVANCEMENT_TAB, // 0x19
|
||||
HELD_ITEM_CHANGE, // 0x1A
|
||||
CREATIVE_INVENTORY_ACTION, // 0x1B
|
||||
UPDATE_SIGN, // 0x1C
|
||||
ANIMATION, // 0x1D
|
||||
SPECTATE, // 0x1E
|
||||
PLAYER_BLOCK_PLACEMENT, // 0x1F
|
||||
USE_ITEM, // 0x20
|
||||
}
|
@ -11,7 +11,6 @@ import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.platform.providers.ViaProviders;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
@ -19,6 +18,8 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.rewriters.SoundRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider;
|
||||
@ -45,7 +46,7 @@ import java.util.Map;
|
||||
public class Protocol1_13To1_12_2 extends Protocol {
|
||||
|
||||
public Protocol1_13To1_12_2() {
|
||||
super(true);
|
||||
super(ClientboundPackets1_12_1.class, ClientboundPackets1_13.class, ServerboundPackets1_12_1.class, ServerboundPackets1_13.class, true);
|
||||
}
|
||||
|
||||
public static final PacketHandler POS_TO_3_INT = wrapper -> {
|
||||
@ -146,8 +147,6 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
WorldPackets.register(this);
|
||||
InventoryPackets.register(this);
|
||||
|
||||
// Outgoing packets
|
||||
|
||||
registerOutgoing(State.LOGIN, 0x0, 0x0, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -186,7 +185,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
// New packet 0x04 - Login Plugin Message
|
||||
|
||||
// Statistics
|
||||
registerOutgoing(State.PLAY, 0x07, 0x07, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.STATISTICS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -245,8 +244,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Boss bar
|
||||
registerOutgoing(State.PLAY, 0xC, 0xC, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.BOSSBAR, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UUID);
|
||||
@ -262,8 +260,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
// Chat message
|
||||
registerOutgoing(State.PLAY, 0xF, 0xE, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
@ -275,10 +272,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
// WorldPackets 0x10 -> 0x0F
|
||||
|
||||
// Tab-Complete
|
||||
registerOutgoing(State.PLAY, 0xE, 0x10, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
create(new ValueCreator() {
|
||||
@ -319,31 +313,17 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
// New packet 0x11, declare commands
|
||||
registerOutgoing(State.PLAY, 0x11, 0x12);
|
||||
registerOutgoing(State.PLAY, 0x12, 0x13);
|
||||
// Open window
|
||||
registerOutgoing(State.PLAY, 0x13, 0x14, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.OPEN_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
map(Type.STRING); // Window type
|
||||
map(Type.STRING); // Title
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.set(Type.STRING, 1, ChatRewriter.processTranslate(wrapper.get(Type.STRING, 1)));
|
||||
}
|
||||
});
|
||||
handler(wrapper -> wrapper.set(Type.STRING, 1, ChatRewriter.processTranslate(wrapper.get(Type.STRING, 1))));
|
||||
}
|
||||
});
|
||||
|
||||
// InventoryPackets 0x14 -> 0x15
|
||||
// InventoryPackets 0x15 -> 0x16
|
||||
// InventoryPackets 0x16 -> 0x17
|
||||
|
||||
// Set cooldown
|
||||
registerOutgoing(State.PLAY, 0x17, 0x18, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.COOLDOWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -381,29 +361,16 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
// WorldPackets 0x18 -> 0x19
|
||||
// Disconnect
|
||||
registerOutgoing(State.PLAY, 0x1A, 0x1B, new PacketRemapper() {
|
||||
|
||||
registerOutgoing(ClientboundPackets1_12_1.DISCONNECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.set(Type.STRING, 0, ChatRewriter.processTranslate(wrapper.get(Type.STRING, 0)));
|
||||
handler(wrapper -> wrapper.set(Type.STRING, 0, ChatRewriter.processTranslate(wrapper.get(Type.STRING, 0))));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
registerOutgoing(State.PLAY, 0x1B, 0x1C);
|
||||
// New packet 0x1D - NBT Query
|
||||
// WorldPackets 0x1C -> 0x1E
|
||||
registerOutgoing(State.PLAY, 0x1E, 0x20);
|
||||
registerOutgoing(State.PLAY, 0x1F, 0x21);
|
||||
// WorldPackets 0x20 -> 0x22
|
||||
|
||||
// Effect packet
|
||||
registerOutgoing(State.PLAY, 0x21, 0x23, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Effect Id
|
||||
@ -426,9 +393,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
// WorldPackets 0x22 -> 0x24
|
||||
// Join (save dimension id)
|
||||
registerOutgoing(State.PLAY, 0x23, 0x25, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
@ -451,8 +416,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Map packet
|
||||
registerOutgoing(State.PLAY, 0x24, 0x26, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Map id
|
||||
@ -476,28 +440,15 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
registerOutgoing(State.PLAY, 0x25, 0x27);
|
||||
registerOutgoing(State.PLAY, 0x26, 0x28);
|
||||
registerOutgoing(State.PLAY, 0x27, 0x29);
|
||||
registerOutgoing(State.PLAY, 0x28, 0x2A);
|
||||
registerOutgoing(State.PLAY, 0x29, 0x2B);
|
||||
registerOutgoing(State.PLAY, 0x2A, 0x2C);
|
||||
// Craft recipe response
|
||||
registerOutgoing(State.PLAY, 0x2B, 0x2D, new PacketRemapper() {
|
||||
|
||||
registerOutgoing(ClientboundPackets1_12_1.CRAFT_RECIPE_RESPONSE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.STRING, "viaversion:legacy/" + wrapper.read(Type.VAR_INT));
|
||||
handler(wrapper -> wrapper.write(Type.STRING, "viaversion:legacy/" + wrapper.read(Type.VAR_INT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
registerOutgoing(State.PLAY, 0x2C, 0x2E);
|
||||
// Combat event
|
||||
registerOutgoing(State.PLAY, 0x2D, 0x2F, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.COMBAT_EVENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Event
|
||||
@ -513,12 +464,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
registerOutgoing(State.PLAY, 0x2E, 0x30);
|
||||
// New 0x31 - Face Player
|
||||
registerOutgoing(State.PLAY, 0x2F, 0x32);
|
||||
registerOutgoing(State.PLAY, 0x30, 0x33);
|
||||
// Unlock recipes
|
||||
registerOutgoing(State.PLAY, 0x31, 0x34, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.UNLOCK_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // action
|
||||
@ -604,12 +550,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
// EntityPackets 0x32 -> 0x35
|
||||
registerOutgoing(State.PLAY, 0x33, 0x36);
|
||||
registerOutgoing(State.PLAY, 0x34, 0x37);
|
||||
|
||||
// Respawn (save dimension id)
|
||||
registerOutgoing(State.PLAY, 0x35, 0x38, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
@ -629,20 +570,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(State.PLAY, 0x36, 0x39);
|
||||
registerOutgoing(State.PLAY, 0x37, 0x3A);
|
||||
registerOutgoing(State.PLAY, 0x38, 0x3B);
|
||||
registerOutgoing(State.PLAY, 0x39, 0x3C);
|
||||
registerOutgoing(State.PLAY, 0x3A, 0x3D);
|
||||
registerOutgoing(State.PLAY, 0x3B, 0x3E);
|
||||
// EntityPackets 0x3C -> 0x3F
|
||||
registerOutgoing(State.PLAY, 0x3D, 0x40);
|
||||
registerOutgoing(State.PLAY, 0x3E, 0x41);
|
||||
// InventoryPackets 0x3F -> 0x42
|
||||
registerOutgoing(State.PLAY, 0x40, 0x43);
|
||||
registerOutgoing(State.PLAY, 0x41, 0x44);
|
||||
// Scoreboard Objective
|
||||
registerOutgoing(State.PLAY, 0x42, 0x45, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.SCOREBOARD_OBJECTIVE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Objective name
|
||||
@ -666,9 +594,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(State.PLAY, 0x43, 0x46);
|
||||
// Team packet
|
||||
registerOutgoing(State.PLAY, 0x44, 0x47, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.TEAMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Team Name
|
||||
@ -721,7 +647,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
|
||||
}
|
||||
});
|
||||
registerOutgoing(State.PLAY, 0x45, 0x48, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.UPDATE_SCORE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -741,10 +667,8 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
registerOutgoing(State.PLAY, 0x46, 0x49);
|
||||
registerOutgoing(State.PLAY, 0x47, 0x4A);
|
||||
// Title
|
||||
registerOutgoing(State.PLAY, 0x48, 0x4B, new PacketRemapper() {
|
||||
|
||||
registerOutgoing(ClientboundPackets1_12_1.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Action
|
||||
@ -761,10 +685,9 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
// New 0x4C - Stop Sound
|
||||
|
||||
new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)).registerSound(0x49, 0x4D);
|
||||
new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)).registerSound(ClientboundPackets1_12_1.SOUND);
|
||||
|
||||
// Player list header and footer
|
||||
registerOutgoing(State.PLAY, 0x4A, 0x4E, new PacketRemapper() {
|
||||
registerOutgoing(ClientboundPackets1_12_1.TAB_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
@ -778,10 +701,8 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
registerOutgoing(State.PLAY, 0x4B, 0x4F);
|
||||
registerOutgoing(State.PLAY, 0x4C, 0x50);
|
||||
// Advancements
|
||||
registerOutgoing(State.PLAY, 0x4D, 0x51, new PacketRemapper() {
|
||||
|
||||
registerOutgoing(ClientboundPackets1_12_1.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -823,21 +744,17 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
registerOutgoing(State.PLAY, 0x4E, 0x52);
|
||||
registerOutgoing(State.PLAY, 0x4F, 0x53);
|
||||
// New packet 0x54 - Declare Recipes
|
||||
// New packet 0x55 - Tags
|
||||
|
||||
|
||||
// Incoming packets
|
||||
|
||||
// New packet 0x02 - Login Plugin Message
|
||||
cancelIncoming(State.LOGIN, 0x02);
|
||||
|
||||
// New 0x01 - Query Block NBT
|
||||
cancelIncoming(State.PLAY, 0x01);
|
||||
cancelIncoming(ServerboundPackets1_13.QUERY_BLOCK_NBT);
|
||||
|
||||
// Tab-Complete
|
||||
registerIncoming(State.PLAY, 0x1, 0x5, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -869,7 +786,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
if (!wrapper.isCancelled() && Via.getConfig().get1_13TabCompleteDelay() > 0) {
|
||||
TabCompleteTracker tracker = wrapper.user().get(TabCompleteTracker.class);
|
||||
wrapper.cancel();
|
||||
tracker.setTimeToSend(System.currentTimeMillis() + Via.getConfig().get1_13TabCompleteDelay() * 50);
|
||||
tracker.setTimeToSend(System.currentTimeMillis() + Via.getConfig().get1_13TabCompleteDelay() * 50L);
|
||||
tracker.setLastTabComplete(wrapper.get(Type.STRING, 0));
|
||||
}
|
||||
}
|
||||
@ -877,14 +794,8 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
registerIncoming(State.PLAY, 0x05, 0x06);
|
||||
registerIncoming(State.PLAY, 0x06, 0x07);
|
||||
// InventoryPackets 0x07, 0x08
|
||||
registerIncoming(State.PLAY, 0x08, 0x09);
|
||||
// InventoryPackets 0x09 -> 0x0A
|
||||
|
||||
// New 0x0A - Edit book -> Plugin Message
|
||||
registerIncoming(State.PLAY, 0x09, 0x0B, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.EDIT_BOOK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -901,19 +812,12 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
// New 0x0C - Query Entity NBT
|
||||
cancelIncoming(State.PLAY, 0x0C);
|
||||
|
||||
registerIncoming(State.PLAY, 0x0A, 0x0D);
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0E);
|
||||
registerIncoming(State.PLAY, 0x0C, 0x0F);
|
||||
registerIncoming(State.PLAY, 0x0D, 0x10);
|
||||
registerIncoming(State.PLAY, 0x0E, 0x11);
|
||||
registerIncoming(State.PLAY, 0x0F, 0x12);
|
||||
registerIncoming(State.PLAY, 0x10, 0x13);
|
||||
registerIncoming(State.PLAY, 0x11, 0x14);
|
||||
// New 0x0C - Query Entity NBT
|
||||
cancelIncoming(ServerboundPackets1_13.ENTITY_NBT_REQUEST);
|
||||
|
||||
// New 0x15 - Pick Item -> Plugin Message
|
||||
registerIncoming(State.PLAY, 0x09, 0x15, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.PICK_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
create(new ValueCreator() {
|
||||
@ -925,26 +829,15 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Craft recipe request
|
||||
registerIncoming(State.PLAY, 0x12, 0x16, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.CRAFT_RECIPE_REQUEST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // Window id
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.VAR_INT, Integer.parseInt(wrapper.read(Type.STRING).substring(18)));
|
||||
}
|
||||
});
|
||||
handler(wrapper -> wrapper.write(Type.VAR_INT, Integer.parseInt(wrapper.read(Type.STRING).substring(18))));
|
||||
}
|
||||
});
|
||||
|
||||
registerIncoming(State.PLAY, 0x13, 0x17);
|
||||
registerIncoming(State.PLAY, 0x14, 0x18);
|
||||
registerIncoming(State.PLAY, 0x15, 0x19);
|
||||
registerIncoming(State.PLAY, 0x16, 0x1A);
|
||||
// Recipe Book Data
|
||||
registerIncoming(State.PLAY, 0x17, 0x1B, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.RECIPE_BOOK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Type
|
||||
@ -969,53 +862,40 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
|
||||
// New 0x1C - Name Item -> Plugin Message
|
||||
registerIncoming(State.PLAY, 0x09, 0x1C, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.RENAME_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
create(new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
create(wrapper -> {
|
||||
wrapper.write(Type.STRING, "MC|ItemName"); // Channel
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerIncoming(State.PLAY, 0x18, 0x1D);
|
||||
registerIncoming(State.PLAY, 0x19, 0x1E);
|
||||
|
||||
// New 0x1F - Select Trade -> Plugin Message
|
||||
registerIncoming(State.PLAY, 0x09, 0x1F, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.SELECT_TRADE, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
create(new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
create(wrapper -> {
|
||||
wrapper.write(Type.STRING, "MC|TrSel"); // Channel
|
||||
}
|
||||
});
|
||||
map(Type.VAR_INT, Type.INT); // Slot
|
||||
}
|
||||
});
|
||||
|
||||
// New 0x20 - Set Beacon Effect -> Plugin Message
|
||||
registerIncoming(State.PLAY, 0x09, 0x20, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.SET_BEACON_EFFECT, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
create(new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
create(wrapper -> {
|
||||
wrapper.write(Type.STRING, "MC|Beacon"); // Channel
|
||||
}
|
||||
});
|
||||
map(Type.VAR_INT, Type.INT); // Primary Effect
|
||||
map(Type.VAR_INT, Type.INT); // Secondary Effect
|
||||
}
|
||||
});
|
||||
|
||||
registerIncoming(State.PLAY, 0x1A, 0x21);
|
||||
|
||||
// New 0x22 - Update Command Block -> Plugin Message
|
||||
registerIncoming(State.PLAY, 0x09, 0x22, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
create(new ValueCreator() {
|
||||
@ -1044,8 +924,9 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// New 0x23 - Update Command Block Minecart -> Plugin Message
|
||||
registerIncoming(State.PLAY, 0x09, 0x23, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK_MINECART, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
create(new ValueCreator() {
|
||||
@ -1062,14 +943,11 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
// 0x1B -> 0x24 in InventoryPackets
|
||||
|
||||
// New 0x25 - Update Structure Block -> Message Channel
|
||||
registerIncoming(State.PLAY, 0x09, 0x25, new PacketRemapper() {
|
||||
registerIncoming(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
create(new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
create(wrapper -> {
|
||||
wrapper.write(Type.STRING, "MC|Struct"); // Channel
|
||||
}
|
||||
});
|
||||
handler(POS_TO_3_INT);
|
||||
map(Type.VAR_INT, new ValueTransformer<Integer, Byte>(Type.BYTE) { // Action
|
||||
@ -1128,12 +1006,6 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerIncoming(State.PLAY, 0x1C, 0x26);
|
||||
registerIncoming(State.PLAY, 0x1D, 0x27);
|
||||
registerIncoming(State.PLAY, 0x1E, 0x28);
|
||||
registerIncoming(State.PLAY, 0x1F, 0x29);
|
||||
registerIncoming(State.PLAY, 0x20, 0x2A);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,7 +7,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_12;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1_13;
|
||||
@ -17,8 +17,7 @@ public class EntityPackets {
|
||||
public static void register(Protocol1_13To1_12_2 protocol) {
|
||||
MetadataRewriter1_13To1_12_2 metadataRewriter = protocol.get(MetadataRewriter1_13To1_12_2.class);
|
||||
|
||||
// Spawn Object
|
||||
protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.SPAWN_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
@ -77,8 +76,7 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn mob packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -99,8 +97,7 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn player packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.SPAWN_PLAYER, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -116,10 +113,7 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy entities
|
||||
metadataRewriter.registerEntityDestroy(0x32, 0x35);
|
||||
|
||||
// Metadata packet
|
||||
metadataRewriter.registerMetadataRewriter(0x3C, 0x3F, Types1_12.METADATA_LIST, Types1_13.METADATA_LIST);
|
||||
metadataRewriter.registerEntityDestroy(ClientboundPackets1_12_1.DESTROY_ENTITIES);
|
||||
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_12_1.ENTITY_METADATA, Types1_12.METADATA_LIST, Types1_13.METADATA_LIST);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets;
|
||||
|
||||
import com.github.steveice10.opennbt.conversion.ConverterRegistry;
|
||||
import com.github.steveice10.opennbt.tag.builtin.*;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ShortTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.primitives.Ints;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
@ -12,9 +17,10 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.BlockIdData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SoundSource;
|
||||
@ -32,8 +38,7 @@ public class InventoryPackets {
|
||||
public static void register(Protocol protocol) {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
|
||||
|
||||
// Set slot packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x16, 0x17, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
@ -43,9 +48,7 @@ public class InventoryPackets {
|
||||
handler(itemRewriter.itemToClientHandler(Type.FLAT_ITEM));
|
||||
}
|
||||
});
|
||||
|
||||
// Window items packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x14, 0x15, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.WINDOW_ITEMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
@ -54,9 +57,7 @@ public class InventoryPackets {
|
||||
handler(itemRewriter.itemArrayHandler(Type.FLAT_ITEM_ARRAY));
|
||||
}
|
||||
});
|
||||
|
||||
// Window property
|
||||
protocol.registerOutgoing(State.PLAY, 0x15, 0x16, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.WINDOW_PROPERTY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Window id
|
||||
@ -76,7 +77,7 @@ public class InventoryPackets {
|
||||
});
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerOutgoing(State.PLAY, 0x18, 0x19, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
@ -178,8 +179,7 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3F, 0x42, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -191,8 +191,7 @@ public class InventoryPackets {
|
||||
});
|
||||
|
||||
|
||||
// Click window packet
|
||||
protocol.registerIncoming(State.PLAY, 0x07, 0x08, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_13.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
@ -206,8 +205,7 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Plugin message
|
||||
protocol.registerIncoming(State.PLAY, 0x09, 0x0A, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // Channel
|
||||
@ -242,8 +240,7 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Creative Inventory Action
|
||||
protocol.registerIncoming(State.PLAY, 0x1B, 0x24, new PacketRemapper() {
|
||||
protocol.registerIncoming(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.SHORT); // 0 - Slot
|
||||
|
@ -13,7 +13,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.Particle;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionHandler;
|
||||
@ -57,9 +57,7 @@ public class WorldPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
// Outgoing packets
|
||||
|
||||
// Spawn Painting
|
||||
protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.SPAWN_PAINTING, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
@ -82,8 +80,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Update Block Entity
|
||||
protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Location
|
||||
@ -113,8 +110,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Block action
|
||||
protocol.registerOutgoing(State.PLAY, 0xA, 0xA, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.BLOCK_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // Location
|
||||
@ -162,8 +158,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Block Change
|
||||
protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION);
|
||||
@ -193,8 +188,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Multi Block Change
|
||||
protocol.registerOutgoing(State.PLAY, 0x10, 0xF, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
@ -254,8 +248,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Explosion
|
||||
protocol.registerOutgoing(State.PLAY, 0x1C, 0x1E, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.EXPLOSION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
if (!Via.getConfig().isServersideBlockConnections())
|
||||
@ -300,8 +293,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Unload Chunk
|
||||
protocol.registerOutgoing(State.PLAY, 0x1D, 0x1F, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.UNLOAD_CHUNK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
if (Via.getConfig().isServersideBlockConnections()) {
|
||||
@ -317,8 +309,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Named Sound Effect TODO String -> Identifier? Check if identifier is present?
|
||||
protocol.registerOutgoing(State.PLAY, 0x19, 0x1A, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING);
|
||||
@ -332,8 +323,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Chunk Data
|
||||
protocol.registerOutgoing(State.PLAY, 0x20, 0x22, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@ -464,8 +454,7 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Particle
|
||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x24, new PacketRemapper() {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12_1.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren