This repository has been archived by the owner on Apr 22, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 375
Adding packet mode to fastbreak, issue #796 #985
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
40 changes: 38 additions & 2 deletions
40
src/main/java/me/zeroeightsix/kami/module/modules/player/Fastbreak.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 |
---|---|---|
@@ -1,17 +1,53 @@ | ||
package me.zeroeightsix.kami.module.modules.player | ||
|
||
import me.zero.alpine.listener.EventHandler | ||
import me.zero.alpine.listener.Listener | ||
import me.zero.alpine.listener.EventHook | ||
import me.zeroeightsix.kami.event.events.PacketEvent | ||
import me.zeroeightsix.kami.module.Module | ||
import me.zeroeightsix.kami.setting.Settings | ||
import net.minecraft.network.play.client.CPacketPlayerDigging | ||
|
||
/** | ||
* @author 086 | ||
* Updated by Xiaro on 24/06/2018. | ||
*/ | ||
@Module.Info( | ||
name = "Fastbreak", | ||
category = Module.Category.PLAYER, | ||
description = "Nullifies block hit delay" | ||
description = "Breaks block faster" | ||
) | ||
class Fastbreak : Module() { | ||
private val mode = register(Settings.e<FastBreakMode>("Mode", FastBreakMode.HIT_DELAY)) | ||
private val sneakTrigger = register(Settings.booleanBuilder("Sneak Trigger").withValue(true).withVisibility { mode.value == FastBreakMode.PACKET}.build()) | ||
|
||
private enum class FastBreakMode { | ||
HIT_DELAY, PACKET | ||
} | ||
|
||
private var isPacketMining = false | ||
private var diggingPacket = CPacketPlayerDigging() | ||
|
||
@EventHandler | ||
private val sendListener = Listener(EventHook { event: PacketEvent.Send -> | ||
if (event.packet !is CPacketPlayerDigging || mode.value != FastBreakMode.PACKET) return@EventHook | ||
val packet = event.packet as CPacketPlayerDigging | ||
|
||
if (packet.action == CPacketPlayerDigging.Action.START_DESTROY_BLOCK && !isPacketMining && ((sneakTrigger.value && mc.player.isSneaking) || !sneakTrigger.value)) { | ||
isPacketMining = true | ||
diggingPacket = packet | ||
} else if (packet.action == CPacketPlayerDigging.Action.ABORT_DESTROY_BLOCK && isPacketMining) { /* Cancels aborting packets */ | ||
event.cancel() | ||
} | ||
}) | ||
|
||
override fun onUpdate() { | ||
mc.playerController.blockHitDelay = 0 | ||
if (mode.value == FastBreakMode.HIT_DELAY) { | ||
mc.playerController.blockHitDelay = 0 | ||
} else if (isPacketMining) { | ||
val stopDiggingPacket = CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, diggingPacket.position, diggingPacket.facing) | ||
mc.connection!!.sendPacket(stopDiggingPacket) /* Sends a stop digging packet so the blocks will actually be mined after the server side breaking animation */ | ||
isPacketMining = false | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the year be 2020?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops lol