mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Move flight check fixes to onTick()
This commit is contained in:
parent
a6a19a4d4b
commit
6057d8ea3b
1 changed files with 16 additions and 15 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue