java.lang.Object
me.andreasmelone.glowingeyes.common.util.Util

public class Util extends Object
  • Constructor Details

    • Util

      public Util()
  • Method Details

    • serializeMap

      public static <K extends Serializable, V extends Serializable> byte[] serializeMap(Map<K,V> map)
      Serialize a map to a byte array
      Type Parameters:
      K - the key type of the map, has to be serializable
      V - the value type of the map, has to be serializable
      Parameters:
      map - the map to serialize
      Returns:
      the byte array containing the serialized map, in case of an error an empty byte array
    • deserializeMap

      public static <MAP extends Map<K, V>, K extends Serializable, V extends Serializable> MAP deserializeMap(byte[] serializedMap)
      Deserialize a map from a byte array
      Type Parameters:
      MAP - the type of the map, including K and V
      K - the key type of the map, has to be serializable
      V - the value type of the map, has to be serializable
      Parameters:
      serializedMap - the byte array containing the serialized map
      Returns:
      the deserialized map, in case of an error null, please make sure to handle properly
    • toCompoundTag

      public static <K, V> net.minecraft.nbt.CompoundTag toCompoundTag(com.mojang.serialization.Codec<K> codecK, com.mojang.serialization.Codec<V> codecV, Map<K,V> map)
    • toMap

      public static <K, V> Map<K,V> toMap(com.mojang.serialization.Codec<K> codecK, com.mojang.serialization.Codec<V> codecV, net.minecraft.nbt.CompoundTag tag)
    • round

      public static float round(float value, int places)
    • round

      public static float round(float value)
    • sanitizeForId

      public static String sanitizeForId(String name)
    • id

      public static net.minecraft.resources.ResourceLocation id(String namespace, String path)
    • emptyStreamCodec

      public static <T, U> net.minecraft.network.codec.StreamCodec<T,U> emptyStreamCodec(Supplier<U> constructor)