Package com.petrolpark.data
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classForgeRegistryObjectGSONAdapter.Builder<E,T extends net.minecraft.world.level.storage.loot.SerializerType<E>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedForgeRegistryObjectGSONAdapter(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 Summary
Modifier and TypeMethodDescriptionstatic <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) deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) com.google.gson.JsonElement
-
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:
serializein interfacecom.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:
deserializein interfacecom.google.gson.JsonDeserializer<E>- Throws:
com.google.gson.JsonParseException
-