@@ -2,14 +2,19 @@ package com.lambda.client.command.commands
22
33import com.lambda.client.command.ClientCommand
44import com.lambda.client.event.SafeClientEvent
5+ import com.lambda.client.mixin.extension.setValues
6+ import com.lambda.client.mixin.extension.useEntityAction
57import com.lambda.client.mixin.extension.useEntityId
68import com.lambda.client.util.items.clickSlotUnsynced
79import com.lambda.client.util.text.MessageSendHelper
10+ import io.netty.buffer.Unpooled
811import net.minecraft.entity.passive.EntityDonkey
912import net.minecraft.entity.player.EntityPlayer
1013import net.minecraft.inventory.ClickType
1114import net.minecraft.item.ItemStack
15+ import net.minecraft.item.crafting.CraftingManager
1216import net.minecraft.network.Packet
17+ import net.minecraft.network.PacketBuffer
1318import net.minecraft.network.play.client.*
1419import net.minecraft.util.EnumFacing
1520import net.minecraft.util.EnumHand
@@ -20,7 +25,7 @@ import net.minecraft.util.text.TextFormatting
2025
2126object PacketCommand : ClientCommand(
2227 name = " packet" ,
23- description = " Send any packet you want"
28+ description = " Send (almost) any packet you want"
2429) {
2530 init {
2631 literal(" Animation" ) {
@@ -89,8 +94,13 @@ object PacketCommand : ClientCommand(
8994 }
9095
9196 literal(" ClientStatus" ) {
92- executeSafe {
93- MessageSendHelper .sendChatMessage(" Not yet implemented. Consider to make a pull request." )
97+ enum<CPacketClientStatus .State >(" state" ) { state ->
98+ executeSafe {
99+ deployPacket(
100+ CPacketClientStatus (state.value),
101+ " ${state.value} "
102+ )
103+ }
94104 }
95105 }
96106
@@ -144,8 +154,20 @@ object PacketCommand : ClientCommand(
144154 }
145155
146156 literal(" CustomPayload" ) {
147- executeSafe {
148- MessageSendHelper .sendChatMessage(" Not yet implemented. Consider to make a pull request." )
157+ string(" channel" ) { channel ->
158+ // todo: technically we need to be able to send more data types to fully utilize this packet, but I'm too lazy to implement it and it doesn't fit in well with commands
159+ string(" stringData" ) { data ->
160+ executeSafe {
161+ PacketBuffer (Unpooled .buffer())
162+ .apply { writeString(data.value) }
163+ .also {
164+ deployPacket(
165+ CPacketCustomPayload (channel.value, it),
166+ " ${channel.value} ${data.value} "
167+ )
168+ }
169+ }
170+ }
149171 }
150172 }
151173
@@ -215,8 +237,22 @@ object PacketCommand : ClientCommand(
215237 }
216238
217239 literal(" PlaceRecipe" ) {
218- executeSafe {
219- MessageSendHelper .sendChatMessage(" Not yet implemented. Consider to make a pull request." )
240+ int(" windowId" ) { windowId ->
241+ string(" recipe" ) { recipe ->
242+ boolean(" makeAll" ) { makeAll ->
243+ executeSafe {
244+ CraftingManager .REGISTRY .keys
245+ .find { it.toString() == recipe.value }?.let {
246+ CraftingManager .REGISTRY .getObject(it)?.let { iRecipe ->
247+ deployPacket(
248+ CPacketPlaceRecipe (windowId.value, iRecipe, makeAll.value),
249+ " ${windowId.value} ${recipe.value} ${makeAll.value} "
250+ )
251+ }
252+ }
253+ }
254+ }
255+ }
220256 }
221257 }
222258
@@ -412,6 +448,7 @@ object PacketCommand : ClientCommand(
412448 executeSafe {
413449 val packet = CPacketUseEntity ()
414450 packet.useEntityId = id.value
451+ packet.useEntityAction = CPacketUseEntity .Action .ATTACK
415452
416453 deployPacket(
417454 packet,
@@ -459,16 +496,29 @@ object PacketCommand : ClientCommand(
459496 }
460497 }
461498 }
462-
463499 literal(" VehicleMove" ) {
464- executeSafe {
465- MessageSendHelper .sendChatMessage(" Not yet implemented. Consider to make a pull request." )
500+ double(" x" ) { x ->
501+ double(" y" ) { y ->
502+ double(" z" ) { z ->
503+ float(" yaw" ) { yaw ->
504+ float(" pitch" ) { pitch ->
505+ executeSafe {
506+ deployPacket(
507+ CPacketVehicleMove ().setValues(x.value, y.value, z.value, yaw.value, pitch.value),
508+ " ${x.value} ${y.value} ${z.value} ${yaw.value} ${pitch.value} "
509+ )
510+ }
511+ }
512+ }
513+ }
514+ }
466515 }
467516 }
468517 }
469518
470519 private fun SafeClientEvent.deployPacket (packet : Packet <* >, info : String ) {
471- connection.sendPacket(packet)
520+ // bypasses packet cancel :trollepic:
521+ connection.networkManager.sendPacket(packet, null )
472522 MessageSendHelper .sendChatMessage(" Sent ${TextFormatting .GRAY }${packet.javaClass.name.split(" ." ).lastOrNull()}${TextFormatting .DARK_RED } > ${TextFormatting .GRAY }$info " )
473523 }
474524}
0 commit comments