Class ForgeRegistryObjectGSONAdapter<E,T extends net.minecraft.world.level.storage.loot.SerializerType<E>>

java.lang.Object
com.petrolpark.data.ForgeRegistryObjectGSONAdapter<E,T>
All Implemented Interfaces:
com.google.gson.JsonDeserializer<E>, com.google.gson.JsonSerializer<E>

public class ForgeRegistryObjectGSONAdapter<E,T extends net.minecraft.world.level.storage.loot.SerializerType<E>> extends Object implements com.google.gson.JsonDeserializer<E>, com.google.gson.JsonSerializer<E>
Copy of GsonAdapterFactory for custom Registries.
  • Constructor Details

    • ForgeRegistryObjectGSONAdapter

      protected ForgeRegistryObjectGSONAdapter(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, String elementName, String typeKey, Function<E,T> typeGetter, Supplier<T> defaultType, Pair<Supplier<T>,net.minecraft.world.level.storage.loot.GsonAdapterFactory.InlineSerializer<? extends E>> inlineType)
  • Method Details

    • builder

      public static <E, T extends net.minecraft.world.level.storage.loot.SerializerType<E>> ForgeRegistryObjectGSONAdapter.Builder<E,T> builder(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry, String elementName, String typeKey, Function<E,T> typeGetter)
    • serialize

      public com.google.gson.JsonElement serialize(E src, Type typeOfSrc, com.google.gson.JsonSerializationContext context)
      Specified by:
      serialize in interface com.google.gson.JsonSerializer<E>
    • deserialize

      public E deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) throws com.google.gson.JsonParseException
      Specified by:
      deserialize in interface com.google.gson.JsonDeserializer<E>
      Throws:
      com.google.gson.JsonParseException