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 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impr: Separate BoatFly from EntitySpeed (#2155)
Co-authored-by: lv <[email protected]>
- Loading branch information
Showing
4 changed files
with
121 additions
and
67 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
79 changes: 79 additions & 0 deletions
79
src/main/kotlin/org/kamiblue/client/module/modules/movement/BoatFly.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,79 @@ | ||
package org.kamiblue.client.module.modules.movement | ||
|
||
import net.minecraft.entity.Entity | ||
import net.minecraft.entity.item.EntityBoat | ||
import net.minecraft.network.play.client.CPacketInput | ||
import net.minecraft.network.play.client.CPacketPlayer | ||
import net.minecraft.network.play.client.CPacketVehicleMove | ||
import net.minecraft.network.play.server.SPacketMoveVehicle | ||
import net.minecraft.util.EnumHand | ||
import net.minecraft.world.chunk.EmptyChunk | ||
import org.kamiblue.client.event.SafeClientEvent | ||
import org.kamiblue.client.event.events.PacketEvent | ||
import org.kamiblue.client.event.events.PlayerTravelEvent | ||
import org.kamiblue.client.module.Category | ||
import org.kamiblue.client.module.Module | ||
import org.kamiblue.client.util.EntityUtils.steerEntity | ||
import org.kamiblue.client.util.MovementUtils | ||
import org.kamiblue.client.util.MovementUtils.calcMoveYaw | ||
import org.kamiblue.client.util.threads.safeListener | ||
import kotlin.math.cos | ||
import kotlin.math.sin | ||
|
||
internal object BoatFly : Module( | ||
name = "BoatFly", | ||
category = Category.MOVEMENT, | ||
description = "Fly using boats" | ||
) { | ||
private const val flight = true | ||
|
||
private val speed by setting("Speed", 1.0f, 0.1f..25.0f, 0.1f) | ||
private val antiStuck by setting("Anti Stuck", true) | ||
private val glideSpeed by setting("Glide Speed", 0.1f, 0.0f..1.0f, 0.01f) | ||
private val upSpeed by setting("Up Speed", 1.0f, 0.0f..5.0f, 0.1f) | ||
val opacity by setting("Boat Opacity", 1.0f, 0.0f..1.0f, 0.01f) | ||
private val forceInteract by setting("Force Interact", false) | ||
private val interactTickDelay by setting("Interact Delay", 2, 1..20, 1, { forceInteract }, description = "Force interact packet delay, in ticks.") | ||
|
||
init { | ||
safeListener<PacketEvent.Send> { | ||
val ridingEntity = player.ridingEntity | ||
|
||
if (!forceInteract || ridingEntity !is EntityBoat) return@safeListener | ||
|
||
if (it.packet is CPacketPlayer.Rotation || it.packet is CPacketInput) { | ||
it.cancel() | ||
} | ||
|
||
if (it.packet is CPacketVehicleMove) { | ||
if (player.ticksExisted % interactTickDelay == 0) { | ||
playerController.interactWithEntity(player, ridingEntity, EnumHand.MAIN_HAND) | ||
} | ||
} | ||
} | ||
|
||
safeListener<PacketEvent.Receive> { | ||
if (!forceInteract || player.ridingEntity !is EntityBoat || it.packet !is SPacketMoveVehicle) return@safeListener | ||
it.cancel() | ||
} | ||
|
||
safeListener<PlayerTravelEvent> { | ||
player.ridingEntity?.let { entity -> | ||
if (entity is EntityBoat && entity.controllingPassenger == player) { | ||
steerEntity(entity, speed, antiStuck) | ||
|
||
// Make sure the boat doesn't turn etc (params: isLeftDown, isRightDown, isForwardDown, isBackDown) | ||
entity.rotationYaw = player.rotationYaw | ||
entity.updateInputs(false, false, false, false) | ||
|
||
if (flight) fly(entity) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun fly(entity: Entity) { | ||
if (!entity.isInWater) entity.motionY = -glideSpeed.toDouble() | ||
if (mc.gameSettings.keyBindJump.isKeyDown) entity.motionY += upSpeed / 2.0 | ||
} | ||
} |
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
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