forked from CCBlueX/LiquidBounce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added AutoFish module. (CCBlueX#601)
* Added AutoFish module. * Removed a debug message. * Added rod recast option + check to find out if the player has already casted the rod. * Cleaned up the code Co-authored-by: superblaubeere27 <[email protected]>
- Loading branch information
1 parent
2d9230f
commit eb4fbec
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/ModuleAutoFish.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) | ||
* | ||
* Copyright (c) 2016 - 2021 CCBlueX | ||
* | ||
* LiquidBounce is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiquidBounce is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package net.ccbluex.liquidbounce.features.module.modules.player | ||
|
||
import net.ccbluex.liquidbounce.event.PacketEvent | ||
import net.ccbluex.liquidbounce.event.handler | ||
import net.ccbluex.liquidbounce.features.module.Category | ||
import net.ccbluex.liquidbounce.features.module.Module | ||
import net.minecraft.entity.EquipmentSlot | ||
import net.minecraft.item.FishingRodItem | ||
import net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket | ||
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket | ||
import net.minecraft.sound.SoundEvents | ||
import net.minecraft.util.Hand | ||
|
||
object ModuleAutoFish : Module("AutoFish", Category.PLAYER) { | ||
|
||
val recastRod by boolean("RecastRod", true) | ||
|
||
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 | ||
|
||
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) | ||
} | ||
} | ||
} | ||
|
||
private val Hand.equipmentSlot: EquipmentSlot | ||
get() = when (this) { | ||
Hand.MAIN_HAND -> EquipmentSlot.MAINHAND | ||
Hand.OFF_HAND -> EquipmentSlot.OFFHAND | ||
} | ||
|
||
} |