diff --git a/build.gradle.kts b/build.gradle.kts index 0ee5afc..62d55b3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -61,7 +61,7 @@ dependencies { val vvVer = "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:viabackwards:$vbVer") { isTransitive = false } implementation("com.github.ViaVersion.ViaRewind:viarewind-all:$vrVer") { isTransitive = false } diff --git a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/Protocol1_8To1_7_6.kt b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/Protocol1_8To1_7_6.kt index 804e6be..439368c 100644 --- a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/Protocol1_8To1_7_6.kt +++ b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/Protocol1_8To1_7_6.kt @@ -3,10 +3,15 @@ package com.viaversion.aas.protocol.id47toid5 import com.viaversion.aas.protocol.id47toid5.packets.* import com.viaversion.aas.protocol.id47toid5.storage.* 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 -object Protocol1_8To1_7_6 : AbstractSimpleProtocol() { +object Protocol1_8To1_7_6 : AbstractProtocol() { private val placeable = hashSetOf() init { @@ -97,7 +102,6 @@ object Protocol1_8To1_7_6 : AbstractSimpleProtocol() { fun getInventoryString(b: Int): String { return when (b) { - 0 -> "minecraft:chest" 1 -> "minecraft:crafting_table" 2 -> "minecraft:furnace" 3 -> "minecraft:dispenser" @@ -109,8 +113,7 @@ object Protocol1_8To1_7_6 : AbstractSimpleProtocol() { 9 -> "minecraft:hopper" 10 -> "minecraft:dropper" 11 -> "EntityHorse" - else -> throw IllegalArgumentException("Unknown type $b") + else -> "minecraft:chest" } } - } \ No newline at end of file diff --git a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/EntityPackets.kt b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/EntityPackets.kt index 5e8a028..072c3e7 100644 --- a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/EntityPackets.kt +++ b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/EntityPackets.kt @@ -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.xyzToPosition 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.TypeRemapper import com.viaversion.viaversion.api.type.Type 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 kotlin.experimental.and fun Protocol1_8To1_7_6.registerEntityPackets() { - //Entity Equipment - this.registerClientbound(State.PLAY, 0x04, 0x04, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_EQUIPMENT, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id map(Type.SHORT) //Slot @@ -24,8 +24,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Animation - this.registerClientbound(State.PLAY, 0x0B, 0x0B, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_ANIMATION, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> val entityId = packetWrapper.read(Type.VAR_INT) //Entity Id @@ -49,8 +48,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Collect Item - this.registerClientbound(State.PLAY, 0x0D, 0x0D, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.COLLECT_ITEM, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Collected 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(State.PLAY, 0x0E, 0x0E, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SPAWN_ENTITY, object : PacketRemapper() { override fun registerMap() { map(Type.VAR_INT) map(Type.BYTE) @@ -119,8 +116,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Spawn Mob - this.registerClientbound(State.PLAY, 0x0F, 0x0F, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SPAWN_MOB, object : PacketRemapper() { override fun registerMap() { map(Type.VAR_INT) map(Type.UNSIGNED_BYTE) @@ -154,8 +150,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Spawn Painting - this.registerClientbound(State.PLAY, 0x10, 0x10, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SPAWN_PAINTING, object : PacketRemapper() { override fun registerMap() { map(Type.VAR_INT) //Entity Id map(Type.STRING) //Title @@ -170,8 +165,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Spawn Experience Orb - this.registerClientbound(State.PLAY, 0x11, 0x11, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SPAWN_EXPERIENCE_ORB, object : PacketRemapper() { override fun registerMap() { map(Type.VAR_INT) map(Type.INT) @@ -187,8 +181,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Entity Velocity - this.registerClientbound(State.PLAY, 0x12, 0x12, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_VELOCITY, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id map(Type.SHORT) //velX @@ -197,8 +190,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Destroy Entities - this.registerClientbound(State.PLAY, 0x13, 0x13, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.DESTROY_ENTITIES, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> val amount = packetWrapper.read(Type.BYTE).toInt() @@ -213,15 +205,13 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Entity - this.registerClientbound(State.PLAY, 0x14, 0x14, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_MOVEMENT, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id } }) - //Entity Relative Move - this.registerClientbound(State.PLAY, 0x15, 0x15, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_POSITION, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id map(Type.BYTE) //x @@ -231,8 +221,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Entity Look - this.registerClientbound(State.PLAY, 0x16, 0x16, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_HEAD_LOOK, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id map(Type.BYTE) //yaw @@ -241,8 +230,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Entity Look and Relative Move - this.registerClientbound(State.PLAY, 0x17, 0x17, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_POSITION_AND_ROTATION, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id map(Type.BYTE) //x @@ -254,8 +242,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Entity Teleport - this.registerClientbound(State.PLAY, 0x18, 0x18, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_TELEPORT, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id map(Type.INT) //x @@ -267,16 +254,14 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Entity Head Look - this.registerClientbound(State.PLAY, 0x19, 0x19, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_ROTATION, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id map(Type.BYTE) //Head yaw } }) - //Entity MetadataType - this.registerClientbound(State.PLAY, 0x1C, 0x1C, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_METADATA, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id 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(State.PLAY, 0x1D, 0x1D, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_EFFECT, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id map(Type.BYTE) //Effect Id @@ -306,16 +290,14 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Remove Entity Effect - this.registerClientbound(State.PLAY, 0x1E, 0x1E, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.REMOVE_ENTITY_EFFECT, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id map(Type.BYTE) //Effect Id } }) - //Entity Properties - this.registerClientbound(State.PLAY, 0x20, 0x20, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_PROPERTIES, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id handler { packetWrapper -> @@ -337,8 +319,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { }) - //Spawn Global Entity - this.registerClientbound(State.PLAY, 0x2C, 0x2C, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SPAWN_GLOBAL_ENTITY, object : PacketRemapper() { override fun registerMap() { map(Type.VAR_INT) map(Type.BYTE) @@ -354,8 +335,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Use Entity - this.registerServerbound(State.PLAY, 0x02, 0x02, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.INTERACT_ENTITY, object : PacketRemapper() { override fun registerMap() { map(Type.VAR_INT, Type.INT) handler { packetWrapper -> @@ -372,8 +352,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Entity Action - this.registerServerbound(State.PLAY, 0x0B, 0x0B, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.ENTITY_ACTION, object : PacketRemapper() { override fun registerMap() { map(Type.VAR_INT, Type.INT) //Entity Id handler { packetWrapper -> @@ -386,8 +365,7 @@ fun Protocol1_8To1_7_6.registerEntityPackets() { } }) - //Steer Vehicle - this.registerServerbound(State.PLAY, 0x0C, 0x0C, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.STEER_VEHICLE, object : PacketRemapper() { override fun registerMap() { map(Type.FLOAT) //Sideways map(Type.FLOAT) //Forwards diff --git a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/InventoryPackets.kt b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/InventoryPackets.kt index fafc783..f66c2be 100644 --- a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/InventoryPackets.kt +++ b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/InventoryPackets.kt @@ -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.storage.Windows 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.type.Type 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.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 fun Protocol1_8To1_7_6.registerInventoryPackets() { - - //Open Window - this.registerClientbound(State.PLAY, 0x2D, 0x2D, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.OPEN_WINDOW, object : PacketRemapper() { override fun registerMap() { map(Type.UNSIGNED_BYTE) handler { packetWrapper -> @@ -40,8 +38,7 @@ fun Protocol1_8To1_7_6.registerInventoryPackets() { } }) - //Set Slot - this.registerClientbound(State.PLAY, 0x2F, 0x2F, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SET_SLOT, object : PacketRemapper() { override fun registerMap() { map(Type.UNSIGNED_BYTE) // window id map(Type.SHORT) // window type @@ -57,8 +54,7 @@ fun Protocol1_8To1_7_6.registerInventoryPackets() { } }) - //Window Items - this.registerClientbound(State.PLAY, 0x30, 0x30, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.WINDOW_ITEMS, object : PacketRemapper() { override fun registerMap() { map(Type.UNSIGNED_BYTE) //Window Id handler { packetWrapper -> @@ -78,8 +74,7 @@ fun Protocol1_8To1_7_6.registerInventoryPackets() { }) - //Click Window - this.registerServerbound(State.PLAY, 0x0E, 0x0E, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.CLICK_WINDOW, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> val windowId = packetWrapper.read(Type.UNSIGNED_BYTE) //Window Id @@ -102,8 +97,7 @@ fun Protocol1_8To1_7_6.registerInventoryPackets() { } }) - //Creative Inventory Action - this.registerServerbound(State.PLAY, 0x10, 0x10, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.CREATIVE_INVENTORY_ACTION, object : PacketRemapper() { override fun registerMap() { map(Type.SHORT) //Slot map(Type.ITEM, Types1_7_6_10.COMPRESSED_NBT_ITEM) //Item diff --git a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/PlayerPackets.kt b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/PlayerPackets.kt index 091d80d..ded9bcb 100644 --- a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/PlayerPackets.kt +++ b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/PlayerPackets.kt @@ -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.libs.opennbt.tag.builtin.ListTag 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 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.Types1_7_6_10 import de.gerrygames.viarewind.utils.ChatUtil @@ -31,15 +33,13 @@ import java.util.* import kotlin.experimental.and fun Protocol1_8To1_7_6.registerPlayerPackets() { - //Keep Alive - this.registerClientbound(State.PLAY, 0x00, 0x00, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.KEEP_ALIVE, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) } }) - //Join Game - this.registerClientbound(State.PLAY, 0x01, 0x01, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.JOIN_GAME, object : PacketRemapper() { override fun registerMap() { map(Type.INT) //Entiy Id map(Type.UNSIGNED_BYTE) //Gamemode @@ -51,23 +51,20 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Chat Message - this.registerClientbound(State.PLAY, 0x02, 0x02, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.CHAT_MESSAGE, object : PacketRemapper() { override fun registerMap() { map(Type.STRING) //Chat Message create(Type.BYTE, 0.toByte()) //Position (chat box) } }) - //Spawn Position - this.registerClientbound(State.PLAY, 0x05, 0x05, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SPAWN_POSITION, object : PacketRemapper() { override fun registerMap() { map(xyzToPosition, TypeRemapper(Type.POSITION)) //Position } }) - //Update Health - this.registerClientbound(State.PLAY, 0x06, 0x06, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.UPDATE_HEALTH, object : PacketRemapper() { override fun registerMap() { map(Type.FLOAT) //Health map(Type.SHORT, Type.VAR_INT) //Food @@ -75,8 +72,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Player Position And Look - this.registerClientbound(State.PLAY, 0x08, 0x08, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.ENTITY_POSITION_AND_ROTATION, object : PacketRemapper() { override fun registerMap() { map(Type.DOUBLE) //x handler { packetWrapper -> @@ -93,16 +89,14 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Use Bed - this.registerClientbound(State.PLAY, 0x0A, 0x0A, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.USE_BED, object : PacketRemapper() { override fun registerMap() { map(Type.INT, Type.VAR_INT) //Entity Id map(xyzUBytePos, TypeRemapper(Type.POSITION)) } }) - //Spawn Player - this.registerClientbound(State.PLAY, 0x0C, 0x0C, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SPAWN_PLAYER, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> val entityId = packetWrapper.passthrough(Type.VAR_INT) //Entity Id @@ -197,8 +191,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Set Experience - this.registerClientbound(State.PLAY, 0x1F, 0x1F, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SET_EXPERIENCE, object : PacketRemapper() { override fun registerMap() { map(Type.FLOAT) //Experience bar map(Type.SHORT, Type.VAR_INT) //Level @@ -207,8 +200,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { }) - //Player List Item - this.registerClientbound(State.PLAY, 0x38, 0x38, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.PLAYER_INFO, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> val name = packetWrapper.read(Type.STRING) @@ -272,8 +264,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Scoreboard Objective - this.registerClientbound(State.PLAY, 0x3B, 0x3B, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SCOREBOARD_OBJECTIVE, object : PacketRemapper() { override fun registerMap() { map(Type.STRING) // name handler { packetWrapper -> @@ -288,8 +279,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Update Score - this.registerClientbound(State.PLAY, 0x3C, 0x3C, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.UPDATE_SCORE, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> val name = packetWrapper.passthrough(Type.STRING) @@ -306,8 +296,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Scoreboard Teams - this.registerClientbound(State.PLAY, 0x3E, 0x3E, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.TEAMS, object : PacketRemapper() { override fun registerMap() { map(Type.STRING) handler { packetWrapper -> @@ -331,8 +320,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Custom Payload - this.registerClientbound(State.PLAY, 0x3F, 0x3F, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.PLUGIN_MESSAGE, object : PacketRemapper() { override fun registerMap() { map(Type.STRING) handler { packetWrapper -> @@ -379,15 +367,13 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Keep Alive - this.registerServerbound(State.PLAY, 0x00, 0x00, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.KEEP_ALIVE, object : PacketRemapper() { override fun registerMap() { map(Type.VAR_INT, Type.INT) } }) - //Custom Payload - this.registerServerbound(State.PLAY, 0x17, 0x17, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.PLUGIN_MESSAGE, object : PacketRemapper() { override fun registerMap() { map(Type.STRING) handler { packetWrapper -> @@ -428,8 +414,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Player Position - this.registerServerbound(State.PLAY, 0x04, 0x04, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.PLAYER_POSITION, object : PacketRemapper() { override fun registerMap() { map(Type.DOUBLE) //X handler { packetWrapper -> @@ -441,8 +426,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Player Position And Look - this.registerServerbound(State.PLAY, 0x06, 0x06, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.PLAYER_POSITION_AND_ROTATION, object : PacketRemapper() { override fun registerMap() { map(Type.DOUBLE) //X handler { packetWrapper -> @@ -456,17 +440,14 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Animation - this.registerServerbound(State.PLAY, 0x0A, 0x0A, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.ANIMATION, object : PacketRemapper() { override fun registerMap() { create(Type.INT, 0) //Entity Id, hopefully 0 is ok create(Type.BYTE, 1.toByte()) //Animation } }) - - //Client Settings - this.registerServerbound(State.PLAY, 0x15, 0x15, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.CLIENT_SETTINGS, object : PacketRemapper() { override fun registerMap() { map(Type.STRING) map(Type.BYTE) @@ -480,8 +461,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() { } }) - //Tab-Complete - this.registerServerbound(State.PLAY, 0x14, 0x14, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.TAB_COMPLETE, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> val text = packetWrapper.read(Type.STRING) diff --git a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/WorldPackets.kt b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/WorldPackets.kt index 1a4e65c..3afa7b8 100644 --- a/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/WorldPackets.kt +++ b/src/main/kotlin/com/viaversion/aas/protocol/id47toid5/packets/WorldPackets.kt @@ -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.data.Particle1_8to1_7 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.TypeRemapper 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.legacy.LegacyComponentSerializer +import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_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 kotlin.experimental.and fun Protocol1_8To1_7_6.registerWorldPackets() { - //Chunk Data - this.registerClientbound(State.PLAY, 0x21, 0x21, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.CHUNK_DATA, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> ChunkPacketTransformer.transformChunk(packetWrapper) } } }) //Multi Block Change - this.registerClientbound(State.PLAY, 0x22, 0x22, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.MULTI_BLOCK_CHANGE, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> ChunkPacketTransformer.transformMultiBlockChange(packetWrapper) } } }) - //Block Change - this.registerClientbound(State.PLAY, 0x23, 0x23, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.BLOCK_CHANGE, object : PacketRemapper() { override fun registerMap() { map(xyzUBytePos, TypeRemapper(Type.POSITION)) //Position handler { packetWrapper -> @@ -42,8 +41,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() { } }) - //Block Action - this.registerClientbound(State.PLAY, 0x24, 0x24, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.BLOCK_ACTION, object : PacketRemapper() { override fun registerMap() { map(xyzShortPos, TypeRemapper(Type.POSITION)) //Position map(Type.UNSIGNED_BYTE) @@ -52,8 +50,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() { } }) - //Block Break Animation - this.registerClientbound(State.PLAY, 0x25, 0x25, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.BLOCK_BREAK_ANIMATION, object : PacketRemapper() { override fun registerMap() { map(Type.VAR_INT) //Entity Id map(xyzToPosition, TypeRemapper(Type.POSITION)) //Position @@ -61,15 +58,13 @@ fun Protocol1_8To1_7_6.registerWorldPackets() { } }) - //Map Chunk Bulk - this.registerClientbound(State.PLAY, 0x26, 0x26, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.MAP_BULK_CHUNK, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> ChunkPacketTransformer.transformChunkBulk(packetWrapper) } } }) - //Effect - this.registerClientbound(State.PLAY, 0x28, 0x28, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.EFFECT, object : PacketRemapper() { override fun registerMap() { map(Type.INT) // id map(xyzUBytePos, TypeRemapper(Type.POSITION)) @@ -83,8 +78,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() { } }) - //Particle - this.registerClientbound(State.PLAY, 0x2A, 0x2A, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.SPAWN_PARTICLE, object : PacketRemapper() { override fun registerMap() { handler { packetWrapper -> val parts = packetWrapper.read(Type.STRING).split("_").toTypedArray() @@ -120,8 +114,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() { } }) - //Update Sign - this.registerClientbound(State.PLAY, 0x33, 0x33, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.UPDATE_SIGN, object : PacketRemapper() { override fun registerMap() { map(xyzShortPos, TypeRemapper(Type.POSITION)) //Position handler { packetWrapper -> @@ -135,8 +128,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() { } }) - //Update Block Entity - this.registerClientbound(State.PLAY, 0x35, 0x35, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.BLOCK_ENTITY_DATA, object : PacketRemapper() { override fun registerMap() { map(xyzShortPos, TypeRemapper(Type.POSITION)) //Position map(Type.UNSIGNED_BYTE) //Action @@ -144,8 +136,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() { } }) - //Map - this.registerClientbound(State.PLAY, 0x34, 0x34, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.MAP_DATA, object : PacketRemapper() { override fun registerMap() { map(Type.VAR_INT) handler { packetWrapper -> @@ -197,16 +188,14 @@ fun Protocol1_8To1_7_6.registerWorldPackets() { } }) - //Open Sign Editor - this.registerClientbound(State.PLAY, 0x36, 0x36, object : PacketRemapper() { + this.registerClientbound(ClientboundPackets1_7.OPEN_SIGN_EDITOR, object : PacketRemapper() { override fun registerMap() { map(xyzToPosition, TypeRemapper(Type.POSITION)) //Position } }) - //Player Digging - this.registerServerbound(State.PLAY, 0x07, 0x07, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.PLAYER_DIGGING, object : PacketRemapper() { override fun registerMap() { map(Type.UNSIGNED_BYTE, Type.BYTE) //Status map(TypeRemapper(Type.POSITION), xyzUBytePosWriter) @@ -214,8 +203,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() { } }) - //Player Block Placement - this.registerServerbound(State.PLAY, 0x08, 0x08, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.PLAYER_BLOCK_PLACEMENT, object : PacketRemapper() { override fun registerMap() { map(TypeRemapper(Type.POSITION), xyzUBytePosWriter) map(Type.UNSIGNED_BYTE) @@ -246,8 +234,7 @@ fun Protocol1_8To1_7_6.registerWorldPackets() { } }) - //Update Sign - this.registerServerbound(State.PLAY, 0x12, 0x12, object : PacketRemapper() { + this.registerServerbound(ServerboundPackets1_8.UPDATE_SIGN, object : PacketRemapper() { override fun registerMap() { map(TypeRemapper(Type.POSITION), xyzShortPosWriter) handler { packetWrapper ->