mirror of https://github.com/kami-blue/client
[cleanup] Cleaned up AntiChainPop code
This commit is contained in:
parent
8f4cdc3762
commit
8560369e64
|
@ -16,40 +16,32 @@ import net.minecraft.network.play.server.SPacketEntityStatus
|
|||
object AntiChainPop : Module() {
|
||||
private val mode = register(Settings.e<Mode>("Mode", Mode.PACKET))
|
||||
|
||||
private enum class Mode {
|
||||
ITEMS, PACKET
|
||||
}
|
||||
|
||||
private var totems = 0
|
||||
|
||||
init {
|
||||
listener<PacketEvent.Receive> {
|
||||
if (mode.value != Mode.PACKET || it.packet !is SPacketEntityStatus || it.packet.opCode.toInt() != 35) return@listener
|
||||
mc.world?.let { world ->
|
||||
if (it.packet.getEntity(world) == mc.player) packetMode()
|
||||
listener<PacketEvent.Receive> { event ->
|
||||
if (mode.value != Mode.PACKET || event.packet !is SPacketEntityStatus || event.packet.opCode.toInt() != 35) return@listener
|
||||
mc.world?.let {
|
||||
if (event.packet.getEntity(it) == mc.player) {
|
||||
Surround.enable()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
listener<SafeTickEvent> {
|
||||
if (mode.value == Mode.ITEMS) {
|
||||
itemMode()
|
||||
}
|
||||
if (mode.value == Mode.ITEMS) return@listener
|
||||
val old = totems
|
||||
val new = InventoryUtils.countItemAll(449)
|
||||
if (new < old) Surround.enable()
|
||||
totems = new
|
||||
}
|
||||
}
|
||||
|
||||
private fun itemMode() {
|
||||
val old = totems
|
||||
if (InventoryUtils.countItemAll(449) < old) {
|
||||
Surround.enable()
|
||||
}
|
||||
totems = InventoryUtils.countItemAll(449)
|
||||
}
|
||||
|
||||
private fun packetMode() {
|
||||
Surround.enable()
|
||||
}
|
||||
|
||||
public override fun onToggle() {
|
||||
override fun onToggle() {
|
||||
totems = 0
|
||||
}
|
||||
|
||||
private enum class Mode {
|
||||
ITEMS, PACKET
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue