1.7 packet enum

This commit is contained in:
creeper123123321 2021-07-24 10:56:05 -03:00
parent 6d7d49fa7b
commit dec7a9039c
6 changed files with 81 additions and 139 deletions

View File

@ -61,7 +61,7 @@ dependencies {
val vvVer = "4.0.2-SNAPSHOT" val vvVer = "4.0.2-SNAPSHOT"
val vbVer = "4.0.2-SNAPSHOT" val vbVer = "4.0.2-SNAPSHOT"
val vrVer = "1785aad508" val vrVer = "1f477d6b37"
implementation("com.viaversion:viaversion:$vvVer") { isTransitive = false } implementation("com.viaversion:viaversion:$vvVer") { isTransitive = false }
implementation("com.viaversion:viabackwards:$vbVer") { isTransitive = false } implementation("com.viaversion:viabackwards:$vbVer") { isTransitive = false }
implementation("com.github.ViaVersion.ViaRewind:viarewind-all:$vrVer") { isTransitive = false } implementation("com.github.ViaVersion.ViaRewind:viarewind-all:$vrVer") { isTransitive = false }

View File

@ -3,10 +3,15 @@ package com.viaversion.aas.protocol.id47toid5
import com.viaversion.aas.protocol.id47toid5.packets.* import com.viaversion.aas.protocol.id47toid5.packets.*
import com.viaversion.aas.protocol.id47toid5.storage.* import com.viaversion.aas.protocol.id47toid5.storage.*
import com.viaversion.viaversion.api.connection.UserConnection import com.viaversion.viaversion.api.connection.UserConnection
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol import com.viaversion.viaversion.api.protocol.AbstractProtocol
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ServerboundPackets1_7
// Based on https://github.com/Gerrygames/ClientViaVersion // Based on https://github.com/Gerrygames/ClientViaVersion
object Protocol1_8To1_7_6 : AbstractSimpleProtocol() { object Protocol1_8To1_7_6 : AbstractProtocol<ClientboundPackets1_7, ClientboundPackets1_8,
ServerboundPackets1_7, ServerboundPackets1_8>() {
private val placeable = hashSetOf<Int>() private val placeable = hashSetOf<Int>()
init { init {
@ -97,7 +102,6 @@ object Protocol1_8To1_7_6 : AbstractSimpleProtocol() {
fun getInventoryString(b: Int): String { fun getInventoryString(b: Int): String {
return when (b) { return when (b) {
0 -> "minecraft:chest"
1 -> "minecraft:crafting_table" 1 -> "minecraft:crafting_table"
2 -> "minecraft:furnace" 2 -> "minecraft:furnace"
3 -> "minecraft:dispenser" 3 -> "minecraft:dispenser"
@ -109,8 +113,7 @@ object Protocol1_8To1_7_6 : AbstractSimpleProtocol() {
9 -> "minecraft:hopper" 9 -> "minecraft:hopper"
10 -> "minecraft:dropper" 10 -> "minecraft:dropper"
11 -> "EntityHorse" 11 -> "EntityHorse"
else -> throw IllegalArgumentException("Unknown type $b") else -> "minecraft:chest"
} }
} }
} }

View File

@ -6,17 +6,17 @@ import com.viaversion.aas.protocol.id47toid5.storage.EntityTracker
import com.viaversion.aas.protocol.id47toid5.type.CustomIntType import com.viaversion.aas.protocol.id47toid5.type.CustomIntType
import com.viaversion.aas.protocol.xyzToPosition import com.viaversion.aas.protocol.xyzToPosition
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper
import com.viaversion.viaversion.api.protocol.remapper.TypeRemapper import com.viaversion.viaversion.api.protocol.remapper.TypeRemapper
import com.viaversion.viaversion.api.type.Type import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.type.types.version.Types1_8 import com.viaversion.viaversion.api.type.types.version.Types1_8
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10 import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
import kotlin.experimental.and import kotlin.experimental.and
fun Protocol1_8To1_7_6.registerEntityPackets() { fun Protocol1_8To1_7_6.registerEntityPackets() {
//Entity Equipment this.registerClientbound(ClientboundPackets1_7.ENTITY_EQUIPMENT, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x04, 0x04, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(Type.SHORT) //Slot map(Type.SHORT) //Slot
@ -24,8 +24,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Animation this.registerClientbound(ClientboundPackets1_7.ENTITY_ANIMATION, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x0B, 0x0B, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> handler { packetWrapper ->
val entityId = packetWrapper.read(Type.VAR_INT) //Entity Id val entityId = packetWrapper.read(Type.VAR_INT) //Entity Id
@ -49,8 +48,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Collect Item this.registerClientbound(ClientboundPackets1_7.COLLECT_ITEM, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x0D, 0x0D, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Collected Entity ID map(Type.INT, Type.VAR_INT) //Collected Entity ID
map(Type.INT, Type.VAR_INT) //Collector Entity ID map(Type.INT, Type.VAR_INT) //Collector Entity ID
@ -58,8 +56,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
}) })
//Spawn Object this.registerClientbound(ClientboundPackets1_7.SPAWN_ENTITY, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x0E, 0x0E, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.VAR_INT) map(Type.VAR_INT)
map(Type.BYTE) map(Type.BYTE)
@ -119,8 +116,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Spawn Mob this.registerClientbound(ClientboundPackets1_7.SPAWN_MOB, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x0F, 0x0F, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.VAR_INT) map(Type.VAR_INT)
map(Type.UNSIGNED_BYTE) map(Type.UNSIGNED_BYTE)
@ -154,8 +150,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Spawn Painting this.registerClientbound(ClientboundPackets1_7.SPAWN_PAINTING, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x10, 0x10, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.VAR_INT) //Entity Id map(Type.VAR_INT) //Entity Id
map(Type.STRING) //Title map(Type.STRING) //Title
@ -170,8 +165,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Spawn Experience Orb this.registerClientbound(ClientboundPackets1_7.SPAWN_EXPERIENCE_ORB, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x11, 0x11, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.VAR_INT) map(Type.VAR_INT)
map(Type.INT) map(Type.INT)
@ -187,8 +181,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Entity Velocity this.registerClientbound(ClientboundPackets1_7.ENTITY_VELOCITY, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x12, 0x12, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(Type.SHORT) //velX map(Type.SHORT) //velX
@ -197,8 +190,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Destroy Entities this.registerClientbound(ClientboundPackets1_7.DESTROY_ENTITIES, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x13, 0x13, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> handler { packetWrapper ->
val amount = packetWrapper.read(Type.BYTE).toInt() val amount = packetWrapper.read(Type.BYTE).toInt()
@ -213,15 +205,13 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Entity this.registerClientbound(ClientboundPackets1_7.ENTITY_MOVEMENT, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x14, 0x14, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
} }
}) })
//Entity Relative Move this.registerClientbound(ClientboundPackets1_7.ENTITY_POSITION, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x15, 0x15, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(Type.BYTE) //x map(Type.BYTE) //x
@ -231,8 +221,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Entity Look this.registerClientbound(ClientboundPackets1_7.ENTITY_HEAD_LOOK, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x16, 0x16, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(Type.BYTE) //yaw map(Type.BYTE) //yaw
@ -241,8 +230,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Entity Look and Relative Move this.registerClientbound(ClientboundPackets1_7.ENTITY_POSITION_AND_ROTATION, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x17, 0x17, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(Type.BYTE) //x map(Type.BYTE) //x
@ -254,8 +242,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Entity Teleport this.registerClientbound(ClientboundPackets1_7.ENTITY_TELEPORT, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x18, 0x18, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(Type.INT) //x map(Type.INT) //x
@ -267,16 +254,14 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Entity Head Look this.registerClientbound(ClientboundPackets1_7.ENTITY_ROTATION, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x19, 0x19, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(Type.BYTE) //Head yaw map(Type.BYTE) //Head yaw
} }
}) })
//Entity MetadataType this.registerClientbound(ClientboundPackets1_7.ENTITY_METADATA, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x1C, 0x1C, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(Types1_7_6_10.METADATA_LIST, Types1_8.METADATA_LIST) //MetadataType map(Types1_7_6_10.METADATA_LIST, Types1_8.METADATA_LIST) //MetadataType
@ -295,8 +280,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Entity Effect this.registerClientbound(ClientboundPackets1_7.ENTITY_EFFECT, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x1D, 0x1D, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(Type.BYTE) //Effect Id map(Type.BYTE) //Effect Id
@ -306,16 +290,14 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Remove Entity Effect this.registerClientbound(ClientboundPackets1_7.REMOVE_ENTITY_EFFECT, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x1E, 0x1E, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(Type.BYTE) //Effect Id map(Type.BYTE) //Effect Id
} }
}) })
//Entity Properties this.registerClientbound(ClientboundPackets1_7.ENTITY_PROPERTIES, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x20, 0x20, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
handler { packetWrapper -> handler { packetWrapper ->
@ -337,8 +319,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
}) })
//Spawn Global Entity this.registerClientbound(ClientboundPackets1_7.SPAWN_GLOBAL_ENTITY, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x2C, 0x2C, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.VAR_INT) map(Type.VAR_INT)
map(Type.BYTE) map(Type.BYTE)
@ -354,8 +335,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Use Entity this.registerServerbound(ServerboundPackets1_8.INTERACT_ENTITY, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x02, 0x02, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.VAR_INT, Type.INT) map(Type.VAR_INT, Type.INT)
handler { packetWrapper -> handler { packetWrapper ->
@ -372,8 +352,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Entity Action this.registerServerbound(ServerboundPackets1_8.ENTITY_ACTION, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x0B, 0x0B, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.VAR_INT, Type.INT) //Entity Id map(Type.VAR_INT, Type.INT) //Entity Id
handler { packetWrapper -> handler { packetWrapper ->
@ -386,8 +365,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
} }
}) })
//Steer Vehicle this.registerServerbound(ServerboundPackets1_8.STEER_VEHICLE, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x0C, 0x0C, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.FLOAT) //Sideways map(Type.FLOAT) //Sideways
map(Type.FLOAT) //Forwards map(Type.FLOAT) //Forwards

View File

@ -3,19 +3,17 @@ package com.viaversion.aas.protocol.id47toid5.packets
import com.viaversion.aas.protocol.id47toid5.Protocol1_8To1_7_6 import com.viaversion.aas.protocol.id47toid5.Protocol1_8To1_7_6
import com.viaversion.aas.protocol.id47toid5.storage.Windows import com.viaversion.aas.protocol.id47toid5.storage.Windows
import com.viaversion.viaversion.api.minecraft.item.DataItem import com.viaversion.viaversion.api.minecraft.item.DataItem
import com.viaversion.viaversion.api.minecraft.item.Item
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper
import com.viaversion.viaversion.api.type.Type import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.libs.kyori.adventure.text.Component import com.viaversion.viaversion.libs.kyori.adventure.text.Component
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10 import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
fun Protocol1_8To1_7_6.registerInventoryPackets() { fun Protocol1_8To1_7_6.registerInventoryPackets() {
this.registerClientbound(ClientboundPackets1_7.OPEN_WINDOW, object : PacketRemapper() {
//Open Window
this.registerClientbound(State.PLAY, 0x2D, 0x2D, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.UNSIGNED_BYTE) map(Type.UNSIGNED_BYTE)
handler { packetWrapper -> handler { packetWrapper ->
@ -40,8 +38,7 @@ fun Protocol1_8To1_7_6.registerInventoryPackets() {
} }
}) })
//Set Slot this.registerClientbound(ClientboundPackets1_7.SET_SLOT, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x2F, 0x2F, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.UNSIGNED_BYTE) // window id map(Type.UNSIGNED_BYTE) // window id
map(Type.SHORT) // window type map(Type.SHORT) // window type
@ -57,8 +54,7 @@ fun Protocol1_8To1_7_6.registerInventoryPackets() {
} }
}) })
//Window Items this.registerClientbound(ClientboundPackets1_7.WINDOW_ITEMS, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x30, 0x30, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.UNSIGNED_BYTE) //Window Id map(Type.UNSIGNED_BYTE) //Window Id
handler { packetWrapper -> handler { packetWrapper ->
@ -78,8 +74,7 @@ fun Protocol1_8To1_7_6.registerInventoryPackets() {
}) })
//Click Window this.registerServerbound(ServerboundPackets1_8.CLICK_WINDOW, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x0E, 0x0E, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> handler { packetWrapper ->
val windowId = packetWrapper.read(Type.UNSIGNED_BYTE) //Window Id val windowId = packetWrapper.read(Type.UNSIGNED_BYTE) //Window Id
@ -102,8 +97,7 @@ fun Protocol1_8To1_7_6.registerInventoryPackets() {
} }
}) })
//Creative Inventory Action this.registerServerbound(ServerboundPackets1_8.CREATIVE_INVENTORY_ACTION, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x10, 0x10, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.SHORT) //Slot map(Type.SHORT) //Slot
map(Type.ITEM, Types1_7_6_10.COMPRESSED_NBT_ITEM) //Item map(Type.ITEM, Types1_7_6_10.COMPRESSED_NBT_ITEM) //Item

View File

@ -21,7 +21,9 @@ import com.viaversion.viaversion.api.type.types.CustomByteType
import com.viaversion.viaversion.api.type.types.version.Types1_8 import com.viaversion.viaversion.api.type.types.version.Types1_8
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8
import com.viaversion.viaversion.util.ChatColorUtil import com.viaversion.viaversion.util.ChatColorUtil
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.CustomStringType import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.CustomStringType
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10 import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
import de.gerrygames.viarewind.utils.ChatUtil import de.gerrygames.viarewind.utils.ChatUtil
@ -31,15 +33,13 @@ import java.util.*
import kotlin.experimental.and import kotlin.experimental.and
fun Protocol1_8To1_7_6.registerPlayerPackets() { fun Protocol1_8To1_7_6.registerPlayerPackets() {
//Keep Alive this.registerClientbound(ClientboundPackets1_7.KEEP_ALIVE, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x00, 0x00, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) map(Type.INT, Type.VAR_INT)
} }
}) })
//Join Game this.registerClientbound(ClientboundPackets1_7.JOIN_GAME, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x01, 0x01, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT) //Entiy Id map(Type.INT) //Entiy Id
map(Type.UNSIGNED_BYTE) //Gamemode map(Type.UNSIGNED_BYTE) //Gamemode
@ -51,23 +51,20 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Chat Message this.registerClientbound(ClientboundPackets1_7.CHAT_MESSAGE, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x02, 0x02, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.STRING) //Chat Message map(Type.STRING) //Chat Message
create(Type.BYTE, 0.toByte()) //Position (chat box) create(Type.BYTE, 0.toByte()) //Position (chat box)
} }
}) })
//Spawn Position this.registerClientbound(ClientboundPackets1_7.SPAWN_POSITION, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x05, 0x05, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(xyzToPosition, TypeRemapper(Type.POSITION)) //Position map(xyzToPosition, TypeRemapper(Type.POSITION)) //Position
} }
}) })
//Update Health this.registerClientbound(ClientboundPackets1_7.UPDATE_HEALTH, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x06, 0x06, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.FLOAT) //Health map(Type.FLOAT) //Health
map(Type.SHORT, Type.VAR_INT) //Food map(Type.SHORT, Type.VAR_INT) //Food
@ -75,8 +72,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Player Position And Look this.registerClientbound(ClientboundPackets1_7.ENTITY_POSITION_AND_ROTATION, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x08, 0x08, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.DOUBLE) //x map(Type.DOUBLE) //x
handler { packetWrapper -> handler { packetWrapper ->
@ -93,16 +89,14 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Use Bed this.registerClientbound(ClientboundPackets1_7.USE_BED, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x0A, 0x0A, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT, Type.VAR_INT) //Entity Id
map(xyzUBytePos, TypeRemapper(Type.POSITION)) map(xyzUBytePos, TypeRemapper(Type.POSITION))
} }
}) })
//Spawn Player this.registerClientbound(ClientboundPackets1_7.SPAWN_PLAYER, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x0C, 0x0C, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> handler { packetWrapper ->
val entityId = packetWrapper.passthrough(Type.VAR_INT) //Entity Id val entityId = packetWrapper.passthrough(Type.VAR_INT) //Entity Id
@ -197,8 +191,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Set Experience this.registerClientbound(ClientboundPackets1_7.SET_EXPERIENCE, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x1F, 0x1F, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.FLOAT) //Experience bar map(Type.FLOAT) //Experience bar
map(Type.SHORT, Type.VAR_INT) //Level map(Type.SHORT, Type.VAR_INT) //Level
@ -207,8 +200,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
}) })
//Player List Item this.registerClientbound(ClientboundPackets1_7.PLAYER_INFO, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x38, 0x38, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> handler { packetWrapper ->
val name = packetWrapper.read(Type.STRING) val name = packetWrapper.read(Type.STRING)
@ -272,8 +264,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Scoreboard Objective this.registerClientbound(ClientboundPackets1_7.SCOREBOARD_OBJECTIVE, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x3B, 0x3B, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.STRING) // name map(Type.STRING) // name
handler { packetWrapper -> handler { packetWrapper ->
@ -288,8 +279,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Update Score this.registerClientbound(ClientboundPackets1_7.UPDATE_SCORE, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x3C, 0x3C, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> handler { packetWrapper ->
val name = packetWrapper.passthrough(Type.STRING) val name = packetWrapper.passthrough(Type.STRING)
@ -306,8 +296,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Scoreboard Teams this.registerClientbound(ClientboundPackets1_7.TEAMS, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x3E, 0x3E, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.STRING) map(Type.STRING)
handler { packetWrapper -> handler { packetWrapper ->
@ -331,8 +320,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Custom Payload this.registerClientbound(ClientboundPackets1_7.PLUGIN_MESSAGE, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x3F, 0x3F, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.STRING) map(Type.STRING)
handler { packetWrapper -> handler { packetWrapper ->
@ -379,15 +367,13 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Keep Alive this.registerServerbound(ServerboundPackets1_8.KEEP_ALIVE, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x00, 0x00, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.VAR_INT, Type.INT) map(Type.VAR_INT, Type.INT)
} }
}) })
//Custom Payload this.registerServerbound(ServerboundPackets1_8.PLUGIN_MESSAGE, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x17, 0x17, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.STRING) map(Type.STRING)
handler { packetWrapper -> handler { packetWrapper ->
@ -428,8 +414,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Player Position this.registerServerbound(ServerboundPackets1_8.PLAYER_POSITION, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x04, 0x04, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.DOUBLE) //X map(Type.DOUBLE) //X
handler { packetWrapper -> handler { packetWrapper ->
@ -441,8 +426,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Player Position And Look this.registerServerbound(ServerboundPackets1_8.PLAYER_POSITION_AND_ROTATION, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x06, 0x06, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.DOUBLE) //X map(Type.DOUBLE) //X
handler { packetWrapper -> handler { packetWrapper ->
@ -456,17 +440,14 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Animation this.registerServerbound(ServerboundPackets1_8.ANIMATION, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x0A, 0x0A, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
create(Type.INT, 0) //Entity Id, hopefully 0 is ok create(Type.INT, 0) //Entity Id, hopefully 0 is ok
create(Type.BYTE, 1.toByte()) //Animation create(Type.BYTE, 1.toByte()) //Animation
} }
}) })
this.registerServerbound(ServerboundPackets1_8.CLIENT_SETTINGS, object : PacketRemapper() {
//Client Settings
this.registerServerbound(State.PLAY, 0x15, 0x15, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.STRING) map(Type.STRING)
map(Type.BYTE) map(Type.BYTE)
@ -480,8 +461,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
} }
}) })
//Tab-Complete this.registerServerbound(ServerboundPackets1_8.TAB_COMPLETE, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x14, 0x14, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> handler { packetWrapper ->
val text = packetWrapper.read(Type.STRING) val text = packetWrapper.read(Type.STRING)

View File

@ -5,33 +5,32 @@ import com.viaversion.aas.protocol.id47toid5.Protocol1_8To1_7_6
import com.viaversion.aas.protocol.id47toid5.chunks.ChunkPacketTransformer import com.viaversion.aas.protocol.id47toid5.chunks.ChunkPacketTransformer
import com.viaversion.aas.protocol.id47toid5.data.Particle1_8to1_7 import com.viaversion.aas.protocol.id47toid5.data.Particle1_8to1_7
import com.viaversion.aas.protocol.id47toid5.storage.MapStorage import com.viaversion.aas.protocol.id47toid5.storage.MapStorage
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper
import com.viaversion.viaversion.api.protocol.remapper.TypeRemapper import com.viaversion.viaversion.api.protocol.remapper.TypeRemapper
import com.viaversion.viaversion.api.type.Type import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8 import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10 import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
import kotlin.experimental.and import kotlin.experimental.and
fun Protocol1_8To1_7_6.registerWorldPackets() { fun Protocol1_8To1_7_6.registerWorldPackets() {
//Chunk Data this.registerClientbound(ClientboundPackets1_7.CHUNK_DATA, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x21, 0x21, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> ChunkPacketTransformer.transformChunk(packetWrapper) } handler { packetWrapper -> ChunkPacketTransformer.transformChunk(packetWrapper) }
} }
}) })
//Multi Block Change //Multi Block Change
this.registerClientbound(State.PLAY, 0x22, 0x22, object : PacketRemapper() { this.registerClientbound(ClientboundPackets1_7.MULTI_BLOCK_CHANGE, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> ChunkPacketTransformer.transformMultiBlockChange(packetWrapper) } handler { packetWrapper -> ChunkPacketTransformer.transformMultiBlockChange(packetWrapper) }
} }
}) })
//Block Change this.registerClientbound(ClientboundPackets1_7.BLOCK_CHANGE, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x23, 0x23, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(xyzUBytePos, TypeRemapper(Type.POSITION)) //Position map(xyzUBytePos, TypeRemapper(Type.POSITION)) //Position
handler { packetWrapper -> handler { packetWrapper ->
@ -42,8 +41,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() {
} }
}) })
//Block Action this.registerClientbound(ClientboundPackets1_7.BLOCK_ACTION, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x24, 0x24, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(xyzShortPos, TypeRemapper(Type.POSITION)) //Position map(xyzShortPos, TypeRemapper(Type.POSITION)) //Position
map(Type.UNSIGNED_BYTE) map(Type.UNSIGNED_BYTE)
@ -52,8 +50,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() {
} }
}) })
//Block Break Animation this.registerClientbound(ClientboundPackets1_7.BLOCK_BREAK_ANIMATION, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x25, 0x25, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.VAR_INT) //Entity Id map(Type.VAR_INT) //Entity Id
map(xyzToPosition, TypeRemapper(Type.POSITION)) //Position map(xyzToPosition, TypeRemapper(Type.POSITION)) //Position
@ -61,15 +58,13 @@ fun Protocol1_8To1_7_6.registerWorldPackets() {
} }
}) })
//Map Chunk Bulk this.registerClientbound(ClientboundPackets1_7.MAP_BULK_CHUNK, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x26, 0x26, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> ChunkPacketTransformer.transformChunkBulk(packetWrapper) } handler { packetWrapper -> ChunkPacketTransformer.transformChunkBulk(packetWrapper) }
} }
}) })
//Effect this.registerClientbound(ClientboundPackets1_7.EFFECT, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x28, 0x28, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.INT) // id map(Type.INT) // id
map(xyzUBytePos, TypeRemapper(Type.POSITION)) map(xyzUBytePos, TypeRemapper(Type.POSITION))
@ -83,8 +78,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() {
} }
}) })
//Particle this.registerClientbound(ClientboundPackets1_7.SPAWN_PARTICLE, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x2A, 0x2A, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
handler { packetWrapper -> handler { packetWrapper ->
val parts = packetWrapper.read(Type.STRING).split("_").toTypedArray() val parts = packetWrapper.read(Type.STRING).split("_").toTypedArray()
@ -120,8 +114,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() {
} }
}) })
//Update Sign this.registerClientbound(ClientboundPackets1_7.UPDATE_SIGN, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x33, 0x33, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(xyzShortPos, TypeRemapper(Type.POSITION)) //Position map(xyzShortPos, TypeRemapper(Type.POSITION)) //Position
handler { packetWrapper -> handler { packetWrapper ->
@ -135,8 +128,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() {
} }
}) })
//Update Block Entity this.registerClientbound(ClientboundPackets1_7.BLOCK_ENTITY_DATA, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x35, 0x35, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(xyzShortPos, TypeRemapper(Type.POSITION)) //Position map(xyzShortPos, TypeRemapper(Type.POSITION)) //Position
map(Type.UNSIGNED_BYTE) //Action map(Type.UNSIGNED_BYTE) //Action
@ -144,8 +136,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() {
} }
}) })
//Map this.registerClientbound(ClientboundPackets1_7.MAP_DATA, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x34, 0x34, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.VAR_INT) map(Type.VAR_INT)
handler { packetWrapper -> handler { packetWrapper ->
@ -197,16 +188,14 @@ fun Protocol1_8To1_7_6.registerWorldPackets() {
} }
}) })
//Open Sign Editor this.registerClientbound(ClientboundPackets1_7.OPEN_SIGN_EDITOR, object : PacketRemapper() {
this.registerClientbound(State.PLAY, 0x36, 0x36, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(xyzToPosition, TypeRemapper(Type.POSITION)) //Position map(xyzToPosition, TypeRemapper(Type.POSITION)) //Position
} }
}) })
//Player Digging this.registerServerbound(ServerboundPackets1_8.PLAYER_DIGGING, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x07, 0x07, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(Type.UNSIGNED_BYTE, Type.BYTE) //Status map(Type.UNSIGNED_BYTE, Type.BYTE) //Status
map(TypeRemapper(Type.POSITION), xyzUBytePosWriter) map(TypeRemapper(Type.POSITION), xyzUBytePosWriter)
@ -214,8 +203,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() {
} }
}) })
//Player Block Placement this.registerServerbound(ServerboundPackets1_8.PLAYER_BLOCK_PLACEMENT, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x08, 0x08, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(TypeRemapper(Type.POSITION), xyzUBytePosWriter) map(TypeRemapper(Type.POSITION), xyzUBytePosWriter)
map(Type.UNSIGNED_BYTE) map(Type.UNSIGNED_BYTE)
@ -246,8 +234,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() {
} }
}) })
//Update Sign this.registerServerbound(ServerboundPackets1_8.UPDATE_SIGN, object : PacketRemapper() {
this.registerServerbound(State.PLAY, 0x12, 0x12, object : PacketRemapper() {
override fun registerMap() { override fun registerMap() {
map(TypeRemapper(Type.POSITION), xyzShortPosWriter) map(TypeRemapper(Type.POSITION), xyzShortPosWriter)
handler { packetWrapper -> handler { packetWrapper ->