Use NetworkMovingEvent instead of SendPacketEvents in NoFall, NoSprint
This commit is contained in:
parent
04186c4d1e
commit
008b70c02c
4 changed files with 5 additions and 33 deletions
|
@ -1,13 +0,0 @@
|
|||
package codes.som.hibiscus.mixins;
|
||||
|
||||
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(PlayerMoveC2SPacket.class)
|
||||
public interface MixinExtPlayerMoveC2SPacket {
|
||||
@Accessor
|
||||
@Mutable
|
||||
void setOnGround(boolean onGround);
|
||||
}
|
|
@ -2,19 +2,11 @@ package codes.som.hibiscus.features.player
|
|||
|
||||
import codes.som.hibiscus.api.feature.Feature
|
||||
import codes.som.hibiscus.api.feature.FeatureCategory
|
||||
import codes.som.hibiscus.events.SendPacketEvent
|
||||
import codes.som.hibiscus.mixins.MixinExtPlayerMoveC2SPacket
|
||||
import codes.som.hibiscus.util.ext.requireExtension
|
||||
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket
|
||||
import codes.som.hibiscus.events.NetworkMovingEvent
|
||||
|
||||
class NoFallDamage : Feature("No Fall Damage", FeatureCategory.PLAYER) {
|
||||
init {
|
||||
on { (packet): SendPacketEvent ->
|
||||
if (packet is PlayerMoveC2SPacket) {
|
||||
requireExtension<MixinExtPlayerMoveC2SPacket>(packet)
|
||||
packet.setOnGround(true)
|
||||
}
|
||||
}
|
||||
on<NetworkMovingEvent> { it.onGround = false }
|
||||
}
|
||||
|
||||
override fun createFeatureCommand() =
|
||||
|
|
|
@ -2,19 +2,13 @@ package codes.som.hibiscus.features.player
|
|||
|
||||
import codes.som.hibiscus.api.feature.Feature
|
||||
import codes.som.hibiscus.api.feature.FeatureCategory
|
||||
import codes.som.hibiscus.events.SendPacketEvent
|
||||
import codes.som.hibiscus.events.NetworkMovingEvent
|
||||
import codes.som.hibiscus.player
|
||||
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket
|
||||
|
||||
class NoSprintingPacket : Feature("No Sprinting Packet", FeatureCategory.PLAYER) {
|
||||
init {
|
||||
on { event: SendPacketEvent ->
|
||||
val (packet) = event
|
||||
if (packet is ClientCommandC2SPacket) {
|
||||
if (packet.mode == ClientCommandC2SPacket.Mode.START_SPRINTING && !player.isTouchingWater) {
|
||||
event.cancel()
|
||||
}
|
||||
}
|
||||
on<NetworkMovingEvent>(cond = { !player.isTouchingWater }) {
|
||||
it.sprinting = false
|
||||
}
|
||||
|
||||
hiddenInOverlay = true
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
"MixinExtEntity",
|
||||
"MixinExtMinecraftClient",
|
||||
"MixinExtPlayerInteractEntityC2SPacket",
|
||||
"MixinExtPlayerMoveC2SPacket",
|
||||
"MixinExtUpdatePlayerAbilitiesC2SPacket",
|
||||
"MixinGameRenderer",
|
||||
"MixinKeyboard",
|
||||
|
|
Loading…
Reference in a new issue