Adds some Tag helper functions
This commit is contained in:
parent
aa6cb0e367
commit
4bf127bc14
2 changed files with 33 additions and 1 deletions
|
@ -53,7 +53,7 @@ mod_name=Zontreck's Library Mod
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=GPLv3
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1201.13.042524.0215
|
||||
mod_version=1201.13.042524.0230
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
|
32
src/main/java/dev/zontreck/libzontreck/util/TagUtils.java
Normal file
32
src/main/java/dev/zontreck/libzontreck/util/TagUtils.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package dev.zontreck.libzontreck.util;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class TagUtils
|
||||
{
|
||||
/**
|
||||
* Get either the entry, or supply a default value
|
||||
* @param tag
|
||||
* @param entry
|
||||
* @param other
|
||||
* @return
|
||||
*/
|
||||
public static int intOr(CompoundTag tag, String entry, int other)
|
||||
{
|
||||
if(tag.contains(entry)) return tag.getInt(entry);
|
||||
else return other;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get either the entry, or supply a default value
|
||||
* @param tag
|
||||
* @param entry
|
||||
* @param other
|
||||
* @return
|
||||
*/
|
||||
public static String strOr(CompoundTag tag, String entry, String other)
|
||||
{
|
||||
if(tag.contains(entry)) return tag.getString(entry);
|
||||
else return other;
|
||||
}
|
||||
}
|
Reference in a new issue