Class Utils

java.lang.Object
me.tnoctua.nmodutils.util.Utils

public class Utils extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static double
    Voxel width for use in VoxelShape math
    static final HashMap<String,String>
    Common side translations for use in data generation.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.text.MutableText
    addTranslation(String translationKey)
    Add a translation key with a missing translation and returns the translated text.
    static net.minecraft.text.MutableText
    addTranslation(String translationKey, String value)
    Adds a translation key and returns the translated text.
    static Optional<net.minecraft.item.ItemStack>
    fromNbt(net.minecraft.registry.RegistryWrapper.WrapperLookup registries, net.minecraft.nbt.NbtElement nbt)
    Returns an item stack from a provided nbt compound, without logging errors.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • P

      public static double P
      Voxel width for use in VoxelShape math
    • TRANSLATIONS

      public static final HashMap<String,String> TRANSLATIONS
      Common side translations for use in data generation.
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • addTranslation

      public static net.minecraft.text.MutableText addTranslation(String translationKey)
      Add a translation key with a missing translation and returns the translated text.

      This should ideally be called once per unique translation key, other than those automatically registered.

      For example this call can be used in place of Minecraft's translatable text calls.

      Parameters:
      translationKey - translation key
    • addTranslation

      public static net.minecraft.text.MutableText addTranslation(String translationKey, String value)
      Adds a translation key and returns the translated text.
      Parameters:
      translationKey - translation key
      value - translation value
    • fromNbt

      public static Optional<net.minecraft.item.ItemStack> fromNbt(net.minecraft.registry.RegistryWrapper.WrapperLookup registries, net.minecraft.nbt.NbtElement nbt)
      Returns an item stack from a provided nbt compound, without logging errors.

      NOTE: The error is important, so make sure the item stack you're setting is NEVER null or brave the desync.

      Parameters:
      registries - registry lookup
      nbt - item stack as nbt compound
      Returns:
      item stack if it could be parsed from nbt