[cleanup] Cleaned up AntiChainPop code

This commit is contained in:
Xiaro 2020-11-11 16:06:50 -05:00
parent 8f4cdc3762
commit 8560369e64
No known key found for this signature in database
GPG Key ID: 996D265D6E155377
1 changed files with 16 additions and 24 deletions

View File

@ -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
}
}