Skip to content

Commit

Permalink
Fixed AutoFish module instant rod recast colliding with the flying it…
Browse files Browse the repository at this point in the history
…em. (CCBlueX#629)

* Fixed AutoFish module insta recast colliding with the flying item.

* Small change.
  • Loading branch information
mems01 authored Oct 17, 2021
1 parent ca7d162 commit dbbf5ea
Showing 1 changed file with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package net.ccbluex.liquidbounce.features.module.modules.player

import net.ccbluex.liquidbounce.event.PacketEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.event.repeatable
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module
import net.minecraft.entity.EquipmentSlot
Expand All @@ -37,26 +38,48 @@ import net.minecraft.util.Hand

object ModuleAutoFish : Module("AutoFish", Category.PLAYER) {

val recastRod by boolean("RecastRod", true)
private val recastRod by boolean("RecastRod", true)

val packetHandler = handler<PacketEvent> { event ->
if (player.fishHook == null)
return@handler
private var caughtFish = false

if (event.packet !is PlaySoundS2CPacket || event.packet.sound != SoundEvents.ENTITY_FISHING_BOBBER_SPLASH)
return@handler
override fun disable() {
caughtFish = false
}

for (hand in arrayOf(Hand.MAIN_HAND, Hand.OFF_HAND)) {
if (player.getEquippedStack(hand.equipmentSlot).item !is FishingRodItem)
continue
val repeatable = repeatable {
if (caughtFish) {
for (hand in arrayOf(Hand.MAIN_HAND, Hand.OFF_HAND)) {

if (player.getEquippedStack(hand.equipmentSlot).item !is FishingRodItem) {
continue
}

repeat(1 + if (recastRod) 1 else 0) {
network.sendPacket(PlayerInteractItemC2SPacket(hand))
player.swingHand(hand)

if (recastRod) {
wait(10)
network.sendPacket(PlayerInteractItemC2SPacket(hand))
player.swingHand(hand)
}

caughtFish = false
}
}
}

val packetHandler = handler<PacketEvent> { event ->
if (player.fishHook == null) {
return@handler
}

if (event.packet !is PlaySoundS2CPacket || event.packet.sound != SoundEvents.ENTITY_FISHING_BOBBER_SPLASH) {
return@handler
}

caughtFish = true
}

private val Hand.equipmentSlot: EquipmentSlot
get() = when (this) {
Hand.MAIN_HAND -> EquipmentSlot.MAINHAND
Expand Down

0 comments on commit dbbf5ea

Please sign in to comment.