Class SoundLocation

java.lang.Object
de.mrjulsen.dragnsounds.core.filesystem.SoundLocation
All Implemented Interfaces:
de.mrjulsen.mcdragonlib.data.INBTSerializable

public class SoundLocation extends Object implements de.mrjulsen.mcdragonlib.data.INBTSerializable
An object to locate sound files.
  • Field Details

    • level

      protected net.minecraft.world.level.Level level
    • namespace

      protected String namespace
    • relativePath

      protected String relativePath
  • Constructor Details

    • SoundLocation

      public SoundLocation(net.minecraft.world.level.Level level, String namespace, String relativePath)
      Creates an object to locate a specific folder containing the desired sound files.
      Parameters:
      namespace - The namespace directory name. The namespace is the first directory (root) inside the mod's data folder inside the world's data folder.
      relativePath - The relative path inside the namespace directory. Can be an empty string.
    • SoundLocation

      public SoundLocation(net.minecraft.world.level.Level level, String location)
      Creates an object to locate a specific folder containing the desired sound files.
      Parameters:
      location - The string value of a sound location. Should contain : to separate namespace and path.
      Examples:
      namespace:path/to/file
    • SoundLocation

      public SoundLocation(net.minecraft.world.level.Level level, Path location)
  • Method Details

    • setLevel

      public void setLevel(net.minecraft.world.level.Level level)
    • isAllowedInNamespace

      public static boolean isAllowedInNamespace(char character)
    • isAllowedInPath

      public static boolean isAllowedInPath(char character)
    • isAllowedInSoundLocation

      public static boolean isAllowedInSoundLocation(char character)
    • getNamespace

      public String getNamespace()
      Returns:
      The name of the working directory where the sound files are saved. The mod's sound folder in each world is divided into several subfolders (namespaces), each of which represents its own workspace in which each addon can work as desired. Addons can then decide for themselves whether they want to expand these working areas even further.
    • getRelativePath

      public String getRelativePath()
      Returns:
      The relative path within the namespace folder.
    • buildPath

      public String buildPath()
      Returns:
      The String of the complete relative path containing the namespace and relative path variable. (e.g. my_namespace/my/sub/dir)
    • resolve

      public final Optional<Path> resolve()
      Validates the given path to prevent access of files outside the sound's root directory.
      Returns:
      A filled Optional when the given path in this object is valid.
    • getModDirectory

      public static final Path getModDirectory(net.minecraft.world.level.Level level)
      Parameters:
      level - The world the sound is saved in.
      Returns:
      The path to the directory inside the world's data folder where the sounds are saved.
    • getLevel

      public net.minecraft.world.level.Level getLevel()
      The world the sound is located in.
      Returns:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • serializeNbt

      public net.minecraft.nbt.CompoundTag serializeNbt()
      Specified by:
      serializeNbt in interface de.mrjulsen.mcdragonlib.data.INBTSerializable
    • deserializeNbt

      public void deserializeNbt(net.minecraft.nbt.CompoundTag nbt)
      Specified by:
      deserializeNbt in interface de.mrjulsen.mcdragonlib.data.INBTSerializable
    • fromNbt

      public static SoundLocation fromNbt(net.minecraft.nbt.CompoundTag nbt, net.minecraft.world.level.Level level)
    • empty

      public static SoundLocation empty()