diff --git a/src/main/java/com/replaymod/pathing/properties/CameraProperties.java b/src/main/java/com/replaymod/pathing/properties/CameraProperties.java index fceec366..cf427cc0 100644 --- a/src/main/java/com/replaymod/pathing/properties/CameraProperties.java +++ b/src/main/java/com/replaymod/pathing/properties/CameraProperties.java @@ -3,6 +3,7 @@ package com.replaymod.pathing.properties; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.replaymod.replay.ReplayHandler; +import com.replaymod.replay.camera.CameraEntity; import com.replaymod.replaystudio.pathing.change.Change; import com.replaymod.replaystudio.pathing.property.AbstractProperty; import com.replaymod.replaystudio.pathing.property.AbstractPropertyGroup; @@ -52,7 +53,10 @@ public class CameraProperties extends AbstractPropertyGroup { public void applyToGame(Triple value, @NonNull Object replayHandler) { ReplayHandler handler = ((ReplayHandler) replayHandler); handler.spectateCamera(); - handler.getCameraEntity().setCameraPosition(value.getLeft(), value.getMiddle(), value.getRight()); + CameraEntity cameraEntity = handler.getCameraEntity(); + if (cameraEntity != null) { + cameraEntity.setCameraPosition(value.getLeft(), value.getMiddle(), value.getRight()); + } } @Override @@ -90,7 +94,10 @@ public class CameraProperties extends AbstractPropertyGroup { public void applyToGame(Triple value, @NonNull Object replayHandler) { ReplayHandler handler = ((ReplayHandler) replayHandler); handler.spectateCamera(); - handler.getCameraEntity().setCameraRotation(value.getLeft(), value.getMiddle(), value.getRight()); + CameraEntity cameraEntity = handler.getCameraEntity(); + if (cameraEntity != null) { + cameraEntity.setCameraRotation(value.getLeft(), value.getMiddle(), value.getRight()); + } } @Override diff --git a/src/main/java/com/replaymod/pathing/properties/SpectatorProperty.java b/src/main/java/com/replaymod/pathing/properties/SpectatorProperty.java index 9038e179..a273d8da 100644 --- a/src/main/java/com/replaymod/pathing/properties/SpectatorProperty.java +++ b/src/main/java/com/replaymod/pathing/properties/SpectatorProperty.java @@ -3,6 +3,7 @@ package com.replaymod.pathing.properties; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.replaymod.replay.ReplayHandler; +import com.replaymod.replay.camera.CameraEntity; import com.replaymod.replaystudio.pathing.property.AbstractProperty; import com.replaymod.replaystudio.pathing.property.PropertyPart; import com.replaymod.replaystudio.pathing.property.PropertyParts; @@ -32,7 +33,9 @@ public class SpectatorProperty extends AbstractProperty { @Override public void applyToGame(Integer value, Object replayHandler) { ReplayHandler handler = ((ReplayHandler) replayHandler); - World world = handler.getCameraEntity().getEntityWorld(); + CameraEntity cameraEntity = handler.getCameraEntity(); + if (cameraEntity == null) return; + World world = cameraEntity.getEntityWorld(); // Lookup entity by id, returns null if an entity with the id does not exists Entity target = world.getEntityById(value); // Spectate entity, when called with null, returns to camera