Adds some Tag helper functions

This commit is contained in:
zontreck 2024-04-25 02:30:31 -07:00
parent aa6cb0e367
commit 4bf127bc14
2 changed files with 33 additions and 1 deletions

View file

@ -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

View 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;
}
}