From 4c4398d2cd03e36e2a32f0164296cc49e1d12420 Mon Sep 17 00:00:00 2001 From: Semmieboy YT Date: Thu, 2 Jun 2022 21:19:45 +0200 Subject: [PATCH] Performance improvement --- src/main/java/semmiedev/disc_jockey/SongPlayer.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/semmiedev/disc_jockey/SongPlayer.java b/src/main/java/semmiedev/disc_jockey/SongPlayer.java index 99ecc8e..fbc233b 100644 --- a/src/main/java/semmiedev/disc_jockey/SongPlayer.java +++ b/src/main/java/semmiedev/disc_jockey/SongPlayer.java @@ -55,6 +55,7 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick { tuned = false; } + // TODO: 6/2/2022 Play note blocks every song tick, instead of every tick. That way the song will sound better @Override public void onStartTick(ClientWorld world) { if (!running) return; @@ -178,13 +179,9 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick { double y = Math.max(box.minY, Math.min(pos.y, box.maxY)); double z = Math.max(box.minZ, Math.min(pos.z, box.maxZ)); - double distance = Math.sqrt( - (x - pos.x) * (x - pos.x) + - (y - pos.y) * (y - pos.y) + - (z - pos.z) * (z - pos.z) - ); + double distance = (x - pos.x) * (x - pos.x) + (y - pos.y) * (y - pos.y) + (z - pos.z) * (z - pos.z); - return distance < radius; + return distance < radius * radius; } private HashMap getNotes(Instrument instrument) {