diff --git a/src/main/java/com/tocard/cam/Camera.java b/src/main/java/com/tocard/cam/Camera.java index 3c84094..7571100 100644 --- a/src/main/java/com/tocard/cam/Camera.java +++ b/src/main/java/com/tocard/cam/Camera.java @@ -21,7 +21,7 @@ public class Camera extends JavaPlugin implements Listener { public static ArrayList controlPoints = new ArrayList<>(); public static Logger logger; public static Plugin plugin; - private static float dt = 0.01f; + public static int nbSubdiv = 100; @Override public void onEnable() { @@ -89,6 +89,8 @@ public class Camera extends JavaPlugin implements Listener { public static void compute() { patchYaws(); + float dt = 1 / (float) nbSubdiv; + int nControlPoints = controlPoints.size(); curve = new ArrayList<>(); diff --git a/src/main/java/com/tocard/cam/ExecuteTraveling.java b/src/main/java/com/tocard/cam/ExecuteTraveling.java index c1f9263..4b43874 100644 --- a/src/main/java/com/tocard/cam/ExecuteTraveling.java +++ b/src/main/java/com/tocard/cam/ExecuteTraveling.java @@ -17,6 +17,18 @@ public class ExecuteTraveling implements CommandExecutor { if (sender instanceof Player) { Player player = (Player) sender; + int fromIndex, toIndex; + try { + fromIndex = Integer.parseInt(args[0]); + } catch (Exception e) { + fromIndex = 0; + } + try { + toIndex = Integer.parseInt(args[1]); + } catch (Exception e) { + toIndex = (Camera.controlPoints.size() - 1) / 3; + } + if (taskID >= 0) { // Cancel show task Bukkit.getScheduler().cancelTask(taskID); @@ -25,7 +37,8 @@ public class ExecuteTraveling implements CommandExecutor { return true; } - curveIterator = Camera.curve.iterator(); + curveIterator = Camera.curve.subList(fromIndex * (Camera.nbSubdiv + 1), toIndex * (Camera.nbSubdiv + 1)) + .iterator(); taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Camera.plugin, new Runnable() { @Override