From fab53630283573263ec08f1bd4f1bb256c6478f9 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 29 May 2020 20:35:31 +0200 Subject: [PATCH] Fixed some mechanics not taking spectator mode into account --- .../com/minelittlepony/unicopia/client/gui/UHud.java | 4 ++++ .../unicopia/entity/player/PlayerPhysics.java | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java index 0c37a9b5..4a3e5ca2 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java @@ -25,6 +25,10 @@ public class UHud extends DrawableHelper { public void render(InGameHud hud, float tickDelta) { + if (client.player == null || client.player.isSpectator()) { + return; + } + int scaledWidth = client.getWindow().getScaledWidth(); int scaledHeight = client.getWindow().getScaledHeight(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java index fe96af50..8b3e132a 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -52,7 +52,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickable, Moti } private boolean checkCanFly() { - if (pony.getOwner().abilities.creativeMode) { + if (pony.getOwner().abilities.creativeMode || pony.getOwner().isSpectator()) { return true; } @@ -100,15 +100,17 @@ public class PlayerPhysics extends EntityPhysics implements Tickable, Moti } } + boolean creative = entity.abilities.creativeMode || pony.getOwner().isSpectator(); + entity.abilities.allowFlying = checkCanFly(); - if (!entity.abilities.creativeMode) { + if (!creative) { entity.abilities.flying |= entity.abilities.allowFlying && isFlying && !entity.onGround && !entity.isTouchingWater(); } - isFlying = entity.abilities.flying && !entity.abilities.creativeMode; + isFlying = entity.abilities.flying && !creative; - if (!entity.abilities.creativeMode && !entity.isFallFlying()) { + if (!creative && !entity.isFallFlying()) { if (isFlying && !entity.hasVehicle()) { if (!isRainbooming && getHorizontalMotion(entity) > 0.2 && flightExperience < MAXIMUM_FLIGHT_EXPERIENCE) {