@@ -2,14 +2,19 @@ package com.lambda.client.command.commands
2
2
3
3
import com.lambda.client.command.ClientCommand
4
4
import com.lambda.client.event.SafeClientEvent
5
+ import com.lambda.client.mixin.extension.setValues
6
+ import com.lambda.client.mixin.extension.useEntityAction
5
7
import com.lambda.client.mixin.extension.useEntityId
6
8
import com.lambda.client.util.items.clickSlotUnsynced
7
9
import com.lambda.client.util.text.MessageSendHelper
10
+ import io.netty.buffer.Unpooled
8
11
import net.minecraft.entity.passive.EntityDonkey
9
12
import net.minecraft.entity.player.EntityPlayer
10
13
import net.minecraft.inventory.ClickType
11
14
import net.minecraft.item.ItemStack
15
+ import net.minecraft.item.crafting.CraftingManager
12
16
import net.minecraft.network.Packet
17
+ import net.minecraft.network.PacketBuffer
13
18
import net.minecraft.network.play.client.*
14
19
import net.minecraft.util.EnumFacing
15
20
import net.minecraft.util.EnumHand
@@ -20,7 +25,7 @@ import net.minecraft.util.text.TextFormatting
20
25
21
26
object PacketCommand : ClientCommand(
22
27
name = " packet" ,
23
- description = " Send any packet you want"
28
+ description = " Send (almost) any packet you want"
24
29
) {
25
30
init {
26
31
literal(" Animation" ) {
@@ -89,8 +94,13 @@ object PacketCommand : ClientCommand(
89
94
}
90
95
91
96
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
+ }
94
104
}
95
105
}
96
106
@@ -144,8 +154,20 @@ object PacketCommand : ClientCommand(
144
154
}
145
155
146
156
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
+ }
149
171
}
150
172
}
151
173
@@ -215,8 +237,22 @@ object PacketCommand : ClientCommand(
215
237
}
216
238
217
239
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
+ }
220
256
}
221
257
}
222
258
@@ -412,6 +448,7 @@ object PacketCommand : ClientCommand(
412
448
executeSafe {
413
449
val packet = CPacketUseEntity ()
414
450
packet.useEntityId = id.value
451
+ packet.useEntityAction = CPacketUseEntity .Action .ATTACK
415
452
416
453
deployPacket(
417
454
packet,
@@ -459,16 +496,29 @@ object PacketCommand : ClientCommand(
459
496
}
460
497
}
461
498
}
462
-
463
499
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
+ }
466
515
}
467
516
}
468
517
}
469
518
470
519
private fun SafeClientEvent.deployPacket (packet : Packet <* >, info : String ) {
471
- connection.sendPacket(packet)
520
+ // bypasses packet cancel :trollepic:
521
+ connection.networkManager.sendPacket(packet, null )
472
522
MessageSendHelper .sendChatMessage(" Sent ${TextFormatting .GRAY }${packet.javaClass.name.split(" ." ).lastOrNull()}${TextFormatting .DARK_RED } > ${TextFormatting .GRAY }$info " )
473
523
}
474
524
}
0 commit comments