mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +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)
|
@Mixin(ServerPlayNetworkHandler.class)
|
||||||
abstract class MixinServerPlayNetworkHandler implements EntityTrackingListener, ServerPlayPacketListener {
|
abstract class MixinServerPlayNetworkHandler implements EntityTrackingListener, ServerPlayPacketListener {
|
||||||
|
@Shadow public ServerPlayerEntity player;
|
||||||
@Shadow private boolean floating;
|
@Shadow private boolean floating;
|
||||||
@Shadow private int floatingTicks;
|
@Shadow private int floatingTicks;
|
||||||
|
|
||||||
private boolean flyingSurvival;
|
|
||||||
private boolean prevMotionChecks;
|
private boolean prevMotionChecks;
|
||||||
|
|
||||||
@Inject(method = "onPlayerMove(Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;)V", at = @At("HEAD"))
|
@Inject(method = "onPlayerMove(Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;)V", at = @At("HEAD"))
|
||||||
private void beforePlayerMove(PlayerMoveC2SPacket packet, CallbackInfo info) {
|
private void beforePlayerMove(PlayerMoveC2SPacket packet, CallbackInfo info) {
|
||||||
ServerPlayerEntity player = ((ServerPlayNetworkHandler)(Object)this).player;
|
|
||||||
NetworkThreadUtils.forceMainThread(packet, this, player.getServerWorld());
|
NetworkThreadUtils.forceMainThread(packet, this, player.getServerWorld());
|
||||||
flyingSurvival = Pony.of(player).getPhysics().isFlyingSurvival;
|
prevMotionChecks = player.isInTeleportationState();
|
||||||
|
if (Pony.of(player).getPhysics().isFlyingSurvival) {
|
||||||
if (flyingSurvival) {
|
((ServerPlayerEntityDuck)player).setPreventMotionChecks(true);
|
||||||
setPreventMotionChecks(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onPlayerMove(Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;)V", at = @At("RETURN"))
|
@Inject(method = "onPlayerMove(Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;)V", at = @At("RETURN"))
|
||||||
private void afterPlayerMove(PlayerMoveC2SPacket packet, CallbackInfo info) {
|
private void afterPlayerMove(PlayerMoveC2SPacket packet, CallbackInfo info) {
|
||||||
if (flyingSurvival) {
|
((ServerPlayerEntityDuck)player).setPreventMotionChecks(prevMotionChecks);
|
||||||
setPreventMotionChecks(prevMotionChecks);
|
if (Pony.of(player).getPhysics().isFlyingSurvival) {
|
||||||
|
floating = false;
|
||||||
|
floatingTicks = 0;
|
||||||
|
player.fallDistance = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPreventMotionChecks(boolean motionChecks) {
|
@Inject(method = "tick()V", at = @At("HEAD"))
|
||||||
ServerPlayerEntity player = ((ServerPlayNetworkHandler)(Object)this).player;
|
private void beforePlayerTick() {
|
||||||
prevMotionChecks = player.isInTeleportationState();
|
if (Pony.of(player).getPhysics().isFlyingSurvival) {
|
||||||
((ServerPlayerEntityDuck)player).setPreventMotionChecks(motionChecks);
|
floating = false;
|
||||||
player.fallDistance = 0;
|
floatingTicks = 0;
|
||||||
floating = false;
|
player.fallDistance = 0;
|
||||||
floatingTicks = 0;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue