Skip to content

Commit b2c0708

Browse files
committed
Added ServerSpoof
1 parent f368fce commit b2c0708

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.lambda.module.modules.client
2+
3+
import com.lambda.event.events.PacketEvent
4+
import com.lambda.event.listener.SafeListener.Companion.listener
5+
import com.lambda.module.Module
6+
import com.lambda.module.tag.ModuleTag
7+
import com.lambda.util.Communication.info
8+
import com.lambda.util.text.*
9+
import io.netty.buffer.Unpooled
10+
import net.minecraft.network.PacketByteBuf
11+
import net.minecraft.network.packet.BrandCustomPayload
12+
import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket
13+
import net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket
14+
import net.minecraft.text.ClickEvent
15+
16+
object ServerSpoof : Module(
17+
name = "ServerSpoof",
18+
description = "Decide yourself if you want to accept the server resource pack.",
19+
defaultTags = setOf(ModuleTag.BYPASS)
20+
) {
21+
private val spoofClientBrand by setting("Spoof Client Brand", true)
22+
private val spoofName by setting("Spoof Name", "vanilla", visibility = { spoofClientBrand })
23+
private val cancelResourcePack by setting("Cancel Resource Pack Loading", true)
24+
25+
init {
26+
listener<PacketEvent.Send.Pre> {
27+
val packet = it.packet
28+
if (packet !is CustomPayloadC2SPacket) return@listener
29+
val payload = packet.payload
30+
if (payload !is BrandCustomPayload) return@listener
31+
if (!spoofClientBrand || payload.id() != BrandCustomPayload.ID) return@listener
32+
33+
payload.write(PacketByteBuf(Unpooled.buffer()).writeString(spoofName))
34+
}
35+
36+
listener<PacketEvent.Receive.Pre> { event ->
37+
val packet = event.packet
38+
if (!cancelResourcePack) return@listener
39+
if (packet !is ResourcePackSendS2CPacket) return@listener
40+
41+
event.cancel()
42+
43+
this@ServerSpoof.info(buildText {
44+
literal("Canceled ${if (packet.required) "required" else "optional"} server ressource pack. ")
45+
clickEvent(ClickEvent(ClickEvent.Action.OPEN_URL, packet.url)) {
46+
styled(color = Color.GREEN, underlined = true) {
47+
literal("(Click here to download)")
48+
}
49+
}
50+
})
51+
}
52+
}
53+
}

common/src/main/kotlin/com/lambda/module/tag/ModuleTag.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ class ModuleTag(override val name: String) : Nameable {
2626
val CLIENT = ModuleTag("Client")
2727
val HIDDEN = ModuleTag("Hidden")
2828
val GRIM = ModuleTag("Grim")
29+
val BYPASS = ModuleTag("Bypass")
2930
}
3031
}

0 commit comments

Comments
 (0)