diff --git a/build.gradle b/build.gradle
index 266aa7a..3d7485b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -56,7 +56,7 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
- modImplementation "maven.modrinth:area_lib:0.0.2"
+ modImplementation "maven.modrinth:area_lib:0.0.4"
}
processResources {
diff --git a/gradle.properties b/gradle.properties
index b40f00c..753bfa9 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -8,7 +8,7 @@ minecraft_version=1.21.1
loader_version=0.16.9
# Mod Properties
-mod_version=4.0.0
+mod_version=5.0.0
maven_group=symbolics.division.meret
archives_base_name=meret
diff --git a/src/client/java/symbolics/division/meret/MeretClient.java b/src/client/java/symbolics/division/meret/MeretClient.java
index 5697a26..8667fc2 100644
--- a/src/client/java/symbolics/division/meret/MeretClient.java
+++ b/src/client/java/symbolics/division/meret/MeretClient.java
@@ -1,7 +1,11 @@
package symbolics.division.meret;
+import com.mojang.datafixers.util.Pair;
+import dev.doublekekse.area_lib.Area;
import dev.doublekekse.area_lib.data.AreaClientData;
import dev.doublekekse.area_lib.data.AreaSavedData;
+import it.unimi.dsi.fastutil.PriorityQueue;
+import it.unimi.dsi.fastutil.objects.ObjectArrayPriorityQueue;
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.Holder;
@@ -13,6 +17,9 @@
import net.minecraft.world.item.JukeboxSong;
import org.jetbrains.annotations.Nullable;
+import java.util.Comparator;
+import java.util.Objects;
+
public class MeretClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
@@ -23,25 +30,46 @@ public void onInitializeClient() {
public static Music getOverride(LocalPlayer player) {
if (player == null) return null;
- AreaSavedData.IdentifiableArea potentialArea = AreaClientData.getClientLevelData()
- .find(player.level(), player.position());
+ Area[] areas = AreaClientData.getClientLevelData().getAreas().toArray(Area[]::new);
- if (potentialArea == null) return null;
+ PriorityQueue queue = new ObjectArrayPriorityQueue<>(areas.length, Comparator.comparingInt(Area::getPriority));
+// for (Area potentialArea : areas) {
+// queue.enqueue(potentialArea);
+// }
Registry songRegistry = player.level().registryAccess().registry(Registries.JUKEBOX_SONG).orElse(null);
- if (songRegistry == null) return null;
+ if (songRegistry == null) {
+ Meret.LOGGER.info("Could not get a handle on songRegistry, you will not hear any music.");
+ return null;
+ }
+
+ var songTags = songRegistry.getTagNames().toList();
+
+
+// for (var tag : songTags) {
+// Area area = AreaClientData.getClientLevelData().get(tag.location());
+// if (area != null && area.contains(player))
+// queue.enqueue(area);
+// }
+
+// return null;
+// if (queue.isEmpty()) return null;
+
+// songRegistry.getOrCreateTag()
- TagKey musicTag = TagKey.create(
- Registries.JUKEBOX_SONG,
- potentialArea.id()
- );
- HolderSet.Named taggedHolders = songRegistry.getOrCreateTag(musicTag);
- Holder song = taggedHolders.getRandomElement(player.getRandom()).orElse(null);
- if (song == null) return null;
+ // sorry jasmine (´・ω・`)
+ return songRegistry.getTagNames()
+ .map(tag -> new Pair<>(tag, AreaClientData.getClientLevelData().get(tag.location())))
+ .filter(p -> p.getSecond() != null && p.getSecond().contains(player))
+ .max(Comparator.comparingInt(p -> p.getSecond().getPriority()))
+ .flatMap(p -> songRegistry.getOrCreateTag(p.getFirst()).getRandomElement(player.getRandom()))
+ .map(song -> new Music(song.value().soundEvent(), 10, 10, false))
+ .orElse(null);
- return new Music(song.value().soundEvent(), 20 * 3 * 60, 20 * 5 * 60, false);
+// return new Music(song.value().soundEvent(), 10, 10, false);
+//// return new Music(song.value().soundEvent(), 20 * 3 * 60, 20 * 5 * 60, false);
}
}
\ No newline at end of file