Class SoundLocation
java.lang.Object
de.mrjulsen.dragnsounds.core.filesystem.SoundLocation
- All Implemented Interfaces:
de.mrjulsen.mcdragonlib.data.INBTSerializable
An object to locate sound files.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSoundLocation
(net.minecraft.world.level.Level level, String location) Creates an object to locate a specific folder containing the desired sound files.SoundLocation
(net.minecraft.world.level.Level level, String namespace, String relativePath) Creates an object to locate a specific folder containing the desired sound files.SoundLocation
(net.minecraft.world.level.Level level, Path location) -
Method Summary
Modifier and TypeMethodDescriptionvoid
deserializeNbt
(net.minecraft.nbt.CompoundTag nbt) static SoundLocation
empty()
boolean
static SoundLocation
fromNbt
(net.minecraft.nbt.CompoundTag nbt, net.minecraft.world.level.Level level) net.minecraft.world.level.Level
getLevel()
The world the sound is located in.static final Path
getModDirectory
(net.minecraft.world.level.Level level) int
hashCode()
static boolean
isAllowedInNamespace
(char character) static boolean
isAllowedInPath
(char character) static boolean
isAllowedInSoundLocation
(char character) resolve()
Validates the given path to prevent access of files outside the sound's root directory.net.minecraft.nbt.CompoundTag
void
setLevel
(net.minecraft.world.level.Level level) toString()
-
Field Details
-
level
protected net.minecraft.world.level.Level level -
namespace
-
relativePath
-
-
Constructor Details
-
SoundLocation
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
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
-
-
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
- 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
- Returns:
- The relative path within the namespace folder.
-
buildPath
- Returns:
- The String of the complete relative path containing the namespace and relative path variable. (e.g.
my_namespace/my/sub/dir
)
-
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
- 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() -
equals
-
toString
-
serializeNbt
public net.minecraft.nbt.CompoundTag serializeNbt()- Specified by:
serializeNbt
in interfacede.mrjulsen.mcdragonlib.data.INBTSerializable
-
deserializeNbt
public void deserializeNbt(net.minecraft.nbt.CompoundTag nbt) - Specified by:
deserializeNbt
in interfacede.mrjulsen.mcdragonlib.data.INBTSerializable
-
fromNbt
public static SoundLocation fromNbt(net.minecraft.nbt.CompoundTag nbt, net.minecraft.world.level.Level level) -
empty
-