Skip to content

Commit

Permalink
make the mod actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
HamaIndustries committed Nov 26, 2024
1 parent 64cd528 commit 2535c88
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
16 changes: 2 additions & 14 deletions src/client/java/symbolics/division/meret/MeretClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public static Music getOverride(LocalPlayer player) {

if (potentialArea == null) return null;

System.out.println("found area " + potentialArea.id().toString());

Registry<JukeboxSong> songRegistry = player.level().registryAccess().registry(Registries.JUKEBOX_SONG).orElse(null);
Registry<SoundEvent> soundRegistry = player.level().registryAccess().registry(Registries.SOUND_EVENT).orElse(null);

if (songRegistry == null) return null;

Expand All @@ -41,20 +38,11 @@ public static Music getOverride(LocalPlayer player) {
potentialArea.id()
);

TagKey<SoundEvent> soundTag = TagKey.create(
Registries.SOUND_EVENT,
potentialArea.id()
);

HolderSet.Named<SoundEvent> taggedSoundHolders = soundRegistry.getOrCreateTag(soundTag);

HolderSet.Named<JukeboxSong> taggedHolders = songRegistry.getOrCreateTag(musicTag);
Holder<JukeboxSong> song = taggedHolders.getRandomElement(player.getRandom()).orElse(null);
Holder<SoundEvent> soundSong = taggedSoundHolders.getRandomElement(player.getRandom()).orElse(null);

if (soundSong == null) return null;
if (song == null) return null;

// vanilla game music values
return new Music(soundSong, 300, 300, false);
return new Music(song.value().soundEvent(), 300, 300, false);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
package symbolics.division.meret.mixin.client;

import dev.doublekekse.area_lib.data.AreaClientData;
import dev.doublekekse.area_lib.data.AreaSavedData;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.sounds.Music;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.JukeboxSong;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/symbolics/division/meret/Meret.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ public static ResourceLocation id(String id) {
}

public static final class OVERRIDES {
public static final ResourceLocation INDUSTRIAL_ID = ResourceLocation.fromNamespaceAndPath("mf121_music", "music.chrono_stereo");
public static final SoundEvent INDUSTRIAL = SoundEvent.createVariableRangeEvent(INDUSTRIAL_ID);
// public static final ResourceLocation STONE_ID = ResourceLocation.fromNamespaceAndPath(MF_ID, "override.industrial");
// public static final SoundEvent STONE = SoundEvent.createVariableRangeEvent(STONE_ID);
// public static final ResourceLocation IRON_ID = ResourceLocation.fromNamespaceAndPath(MF_ID, "override.industrial");
// public static final SoundEvent IRON = SoundEvent.createVariableRangeEvent(IRON_ID);
// public static final ResourceLocation INDUSTRIAL_ID = ResourceLocation.fromNamespaceAndPath(MF_ID, "override.industrial");
// public static final SoundEvent INDUSTRIAL = SoundEvent.createVariableRangeEvent(INDUSTRIAL_ID);
// public static final ResourceLocation INFO_ID = ResourceLocation.fromNamespaceAndPath(MF_ID, "override.industrial");
// public static final SoundEvent INFO = SoundEvent.createVariableRangeEvent(INFO_ID);

}

@Override
Expand All @@ -34,7 +41,7 @@ public void onInitialize() {
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.

Registry.register(BuiltInRegistries.SOUND_EVENT, OVERRIDES.INDUSTRIAL_ID, OVERRIDES.INDUSTRIAL);
// Registry.register(BuiltInRegistries.SOUND_EVENT, OVERRIDES.INDUSTRIAL_ID, OVERRIDES.INDUSTRIAL);
// Registry.register(Registries.SOUND_EVENT, OVERRIDES.INDUSTRIAL_ID, OVERRIDES.INDUSTRIAL);

}
Expand Down

0 comments on commit 2535c88

Please sign in to comment.