diff --git a/gradle.properties b/gradle.properties index 64c253f..9f4a898 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/dev/zontreck/libzontreck/util/TagUtils.java b/src/main/java/dev/zontreck/libzontreck/util/TagUtils.java new file mode 100644 index 0000000..fe8fc0c --- /dev/null +++ b/src/main/java/dev/zontreck/libzontreck/util/TagUtils.java @@ -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; + } +}