Skip to content

Commit

Permalink
Hums it up! (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeryn99 authored May 28, 2024
1 parent 5725497 commit fed5b2b
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package whocraft.tardis_refined.client.screen.selections;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.brigadier.StringReader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.ObjectSelectionList;
Expand All @@ -14,8 +15,8 @@
import whocraft.tardis_refined.common.hum.TardisHums;
import whocraft.tardis_refined.common.network.messages.hums.ChangeHumMessage;
import whocraft.tardis_refined.common.util.MiscHelper;

import java.io.StringReader;
import java.util.Collection;
import java.util.Comparator;

public class HumSelectionScreen extends SelectionScreen {
private HumEntry currentHumEntry;
Expand Down Expand Up @@ -105,10 +106,13 @@ public Component getSelectedDisplayName() {
@Override
public ObjectSelectionList createSelectionList() {
int leftPos = this.width / 2 - 75;
GenericMonitorSelectionList<SelectionListEntry> selectionList = new GenericMonitorSelectionList<>(this.minecraft, 100, 80, leftPos, this.topPos + 30, this.topPos + this.imageHeight - 60, 12);
GenericMonitorSelectionList<SelectionListEntry> selectionList = new GenericMonitorSelectionList<>(this.minecraft, 150, 80, leftPos, this.topPos + 30, this.topPos + this.imageHeight - 60, 12);
selectionList.setRenderBackground(false);

for (HumEntry humEntry : TardisHums.getRegistry().values()) {
Collection<HumEntry> knownHums = TardisHums.getRegistry().values();
knownHums = knownHums.stream().sorted(Comparator.comparing(HumEntry::getName)).toList();

for (HumEntry humEntry : knownHums) {
Component name = Component.literal(MiscHelper.getCleanName(humEntry.getIdentifier().getPath()));

// Check for if the tellraw name is incomplete, or fails to pass.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import org.jetbrains.annotations.NotNull;
import whocraft.tardis_refined.constants.NbtConstants;
import whocraft.tardis_refined.registry.TRDimensionTypes;

public class LoopingHumSound extends LoopingSound{
Expand All @@ -26,6 +27,13 @@ public void tick() {
super.tick();
volume = 0.10F;
LocalPlayer player = Minecraft.getInstance().player;

if(soundEvent.getLocation().getNamespace().contains(NbtConstants.MINECRAFT)){
volume = 1f;
} else {
volume = 0.10F;
}

if(player != null){
setLocation(player.position());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package whocraft.tardis_refined.common.hum;

import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.client.sounds.QuickSimpleSound;
import whocraft.tardis_refined.common.util.CodecJsonReloadListener;
import whocraft.tardis_refined.registry.TRSoundRegistry;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.*;

public class TardisHums {

Expand All @@ -21,7 +22,52 @@ public class TardisHums {
public static final HumEntry CAVE = new HumEntry(new ResourceLocation(TardisRefined.MODID, "cave"), TRSoundRegistry.HUM_CAVE.getId(), new ArrayList<>());
public static final HumEntry TOYOTA = new HumEntry(new ResourceLocation(TardisRefined.MODID, "toyota"), TRSoundRegistry.HUM_TOYOTA.getId(), new ArrayList<>());
public static final HumEntry CLASSIC = new HumEntry(new ResourceLocation(TardisRefined.MODID, "classic"), TRSoundRegistry.HUM_CLASSIC.getId(), new ArrayList<>());
public static final HumEntry HUM_1996 = new HumEntry(new ResourceLocation(TardisRefined.MODID, "hum_1996"), TRSoundRegistry.HUM_1996.getId(), new ArrayList<>());
public static final HumEntry VICTORIAN = new HumEntry(new ResourceLocation(TardisRefined.MODID, "victorian"), TRSoundRegistry.HUM_VICTORIAN.getId(), new ArrayList<>());

public static final HumEntry BASALT_DELTAS = new HumEntry(
new ResourceLocation(TardisRefined.MODID, "basalt_deltas"),
SoundEvents.AMBIENT_BASALT_DELTAS_LOOP.value().getLocation(),
createSoundList(SoundEvents.AMBIENT_BASALT_DELTAS_ADDITIONS.value(), SoundEvents.AMBIENT_BASALT_DELTAS_MOOD.value())
);

public static final HumEntry CRIMSON_FOREST = new HumEntry(
new ResourceLocation(TardisRefined.MODID, "crimson_forest"),
SoundEvents.AMBIENT_CRIMSON_FOREST_LOOP.value().getLocation(),
createSoundList(SoundEvents.AMBIENT_CRIMSON_FOREST_ADDITIONS.value(), SoundEvents.AMBIENT_CRIMSON_FOREST_MOOD.value())
);

public static final HumEntry NETHER_WASTES = new HumEntry(
new ResourceLocation(TardisRefined.MODID, "nether_wastes"),
SoundEvents.AMBIENT_NETHER_WASTES_LOOP.value().getLocation(),
createSoundList(SoundEvents.AMBIENT_NETHER_WASTES_ADDITIONS.value(), SoundEvents.AMBIENT_NETHER_WASTES_MOOD.value())
);

public static final HumEntry UNDER_WATER = new HumEntry(
new ResourceLocation(TardisRefined.MODID, "under_water"),
SoundEvents.AMBIENT_UNDERWATER_LOOP.getLocation(),
createSoundList(SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS, SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS_RARE, SoundEvents.AMBIENT_UNDERWATER_LOOP_ADDITIONS_ULTRA_RARE)
);


public static final HumEntry SOUL_SAND_VALLEY = new HumEntry(
new ResourceLocation(TardisRefined.MODID, "soul_sand_valley"),
SoundEvents.AMBIENT_SOUL_SAND_VALLEY_LOOP.value().getLocation(),
createSoundList(SoundEvents.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS.value(), SoundEvents.AMBIENT_SOUL_SAND_VALLEY_MOOD.value())
);

public static final HumEntry WARPED_FOREST = new HumEntry(
new ResourceLocation(TardisRefined.MODID, "warped_forest"),
SoundEvents.AMBIENT_WARPED_FOREST_LOOP.value().getLocation(),
createSoundList(SoundEvents.AMBIENT_WARPED_FOREST_ADDITIONS.value(), SoundEvents.AMBIENT_WARPED_FOREST_MOOD.value())
);

private static List<ResourceLocation> createSoundList(SoundEvent... sounds) {
ArrayList<ResourceLocation> soundList = new ArrayList<>();
for (SoundEvent sound : sounds) {
soundList.add(sound.getLocation());
}
return soundList;
}

/**
* A factory method to create the instance of our reload listener.
Expand Down Expand Up @@ -55,7 +101,7 @@ public static Map<ResourceLocation, HumEntry> registerDefaultHums() {
addDefaultHum(getDefaultHum());
addDefaultHum(CAVE);
addDefaultHum(TOYOTA);
addDefaultHum(HUM_1996);
addDefaultHum(VICTORIAN);
addDefaultHum(CLASSIC);
return DEFAULT_HUMS;
}
Expand All @@ -72,7 +118,7 @@ private static HumEntry addDefaultHum(HumEntry hum) {
public static HumEntry getDefaultHum() {
ArrayList<ResourceLocation> arrayList = new ArrayList();
arrayList.add(new ResourceLocation(TardisRefined.MODID, "interior_creaks"));
return new HumEntry(new ResourceLocation(TardisRefined.MODID, "coral_hum"), TRSoundRegistry.HUM_CORAL.getId(), arrayList);
return new HumEntry(new ResourceLocation(TardisRefined.MODID, "coral"), TRSoundRegistry.HUM_CORAL.getId(), arrayList);
}

public static Map<ResourceLocation, HumEntry> getDefaultHums() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class NbtConstants {
public static final String FUEL = "fuel";
public static final String MAXIMUM_FUEL = "MaximumFuel";
public static final String IS_PASSIVELY_REFUELING = "is_passively_refueling";
public static final CharSequence MINECRAFT = "minecraft";

public static TardisNavLocation getTardisNavLocation(CompoundTag tag, String prefix, TardisLevelOperator operator) {
BlockPos position = NbtUtils.readBlockPos(tag.getCompound(prefix + NbtConstants.LOCATION_POSITION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class TRSoundRegistry {
public static final RegistrySupplier<SoundEvent> HUM_CAVE = setUpSound("hum_cave");
public static final RegistrySupplier<SoundEvent> HUM_TOYOTA = setUpSound("hum_toyota");
public static final RegistrySupplier<SoundEvent> HUM_CLASSIC = setUpSound("hum_classic");
public static final RegistrySupplier<SoundEvent> HUM_1996 = setUpSound("hum_1996");
public static final RegistrySupplier<SoundEvent> HUM_VICTORIAN = setUpSound("victorian");


// Screwdriver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ public CompletableFuture<?> run(CachedOutput arg) {
TardisHums.registerDefaultHums();
data.putAll(TardisHums.getDefaultHums());
addHum(TardisHums.getDefaultHum());
addHum(TardisHums.HUM_1996);
addHum(TardisHums.VICTORIAN);
addHum(TardisHums.TOYOTA);
addHum(TardisHums.CLASSIC);
addHum(TardisHums.CAVE);
addHum(TardisHums.CRIMSON_FOREST);
addHum(TardisHums.BASALT_DELTAS);
addHum(TardisHums.NETHER_WASTES);
addHum(TardisHums.SOUL_SAND_VALLEY);
addHum(TardisHums.WARPED_FOREST);
addHum(TardisHums.UNDER_WATER);
}

this.addHums();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void registerSounds() {
add(TRSoundRegistry.BULKHEAD_LOCKED.get(), basicSound("bulkhead_locked", new ResourceLocation(TardisRefined.MODID, "blocks/bulkhead_locked")));
add(TRSoundRegistry.HUM_CORAL.get(), basicSound("hum_coral", new ResourceLocation(TardisRefined.MODID, "tardis/interior_hums/humcoral")));
add(TRSoundRegistry.HUM_CAVE.get(), basicSound("hum_cave", new ResourceLocation(TardisRefined.MODID, "tardis/interior_hums/cave")));
add(TRSoundRegistry.HUM_1996.get(), basicSound("hum_1996", new ResourceLocation(TardisRefined.MODID, "tardis/interior_hums/hum1996")));
add(TRSoundRegistry.HUM_VICTORIAN.get(), basicSound("hum_victorian", new ResourceLocation(TardisRefined.MODID, "tardis/interior_hums/humvictorian")));
add(TRSoundRegistry.HUM_CLASSIC.get(), basicSound("hum_classic", new ResourceLocation(TardisRefined.MODID, "tardis/interior_hums/humclassic")));
add(TRSoundRegistry.HUM_TOYOTA.get(), basicSound("hum_toyota", new ResourceLocation(TardisRefined.MODID, "tardis/interior_hums/humtoyota")));
add(TRSoundRegistry.INTERIOR_CREAKS.get(), basicSound("interior_creaks", new ResourceLocation(TardisRefined.MODID, "tardis/ambience/interior_creaks_1"), new ResourceLocation(TardisRefined.MODID, "tardis/ambience/interior_creaks_2"), new ResourceLocation(TardisRefined.MODID, "tardis/ambience/interior_creaks_3")));
Expand Down

0 comments on commit fed5b2b

Please sign in to comment.