diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayNetworkHandler.java b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayNetworkHandler.java index c6580d88..de2ed3ef 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayNetworkHandler.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayNetworkHandler.java @@ -17,36 +17,37 @@ import net.minecraft.server.world.EntityTrackingListener; @Mixin(ServerPlayNetworkHandler.class) abstract class MixinServerPlayNetworkHandler implements EntityTrackingListener, ServerPlayPacketListener { + @Shadow public ServerPlayerEntity player; @Shadow private boolean floating; @Shadow private int floatingTicks; - private boolean flyingSurvival; private boolean prevMotionChecks; @Inject(method = "onPlayerMove(Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;)V", at = @At("HEAD")) private void beforePlayerMove(PlayerMoveC2SPacket packet, CallbackInfo info) { - ServerPlayerEntity player = ((ServerPlayNetworkHandler)(Object)this).player; NetworkThreadUtils.forceMainThread(packet, this, player.getServerWorld()); - flyingSurvival = Pony.of(player).getPhysics().isFlyingSurvival; - - if (flyingSurvival) { - setPreventMotionChecks(true); + prevMotionChecks = player.isInTeleportationState(); + if (Pony.of(player).getPhysics().isFlyingSurvival) { + ((ServerPlayerEntityDuck)player).setPreventMotionChecks(true); } } @Inject(method = "onPlayerMove(Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;)V", at = @At("RETURN")) private void afterPlayerMove(PlayerMoveC2SPacket packet, CallbackInfo info) { - if (flyingSurvival) { - setPreventMotionChecks(prevMotionChecks); + ((ServerPlayerEntityDuck)player).setPreventMotionChecks(prevMotionChecks); + if (Pony.of(player).getPhysics().isFlyingSurvival) { + floating = false; + floatingTicks = 0; + player.fallDistance = 0; } } - private void setPreventMotionChecks(boolean motionChecks) { - ServerPlayerEntity player = ((ServerPlayNetworkHandler)(Object)this).player; - prevMotionChecks = player.isInTeleportationState(); - ((ServerPlayerEntityDuck)player).setPreventMotionChecks(motionChecks); - player.fallDistance = 0; - floating = false; - floatingTicks = 0; + @Inject(method = "tick()V", at = @At("HEAD")) + private void beforePlayerTick() { + if (Pony.of(player).getPhysics().isFlyingSurvival) { + floating = false; + floatingTicks = 0; + player.fallDistance = 0; + } } }