Package net.minecraft.util
Class JsonSerializing.SerializerBuilder<E,T extends JsonSerializableType<E>>
java.lang.Object
net.minecraft.util.JsonSerializing.SerializerBuilder<E,T>
- Enclosing class:
JsonSerializing
public static class JsonSerializing.SerializerBuilder<E,T extends JsonSerializableType<E>>
extends Object
A builder for serializing types to JSON that can either obtain a type from
a registry to handle JSON conversion or handle with a custom logic bound
to a type.
When the root element read is an object, the built serializer obtains the type from registry to handle reading; otherwise, it falls back to custom logic.
- Mappings:
Namespace Name official dyo$a
intermediary net/minecraft/class_5330$class_5331
named net/minecraft/util/JsonSerializing$SerializerBuilder
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
defaultType
(T defaultType) Sets the default type that is used when there's no ID field.elementSerializer
(T type, JsonSerializing.ElementSerializer<? extends E> serializer) Sets the element serializer and its target type.
-
Field Details
-
registry
- Mappings:
Namespace Name Mixin selector official a
Ldyo$a;a:Lhq;
intermediary field_25192
Lnet/minecraft/class_5330$class_5331;field_25192:Lnet/minecraft/class_2378;
named registry
Lnet/minecraft/util/JsonSerializing$SerializerBuilder;registry:Lnet/minecraft/registry/Registry;
-
rootFieldName
- Mappings:
Namespace Name Mixin selector official b
Ldyo$a;b:Ljava/lang/String;
intermediary field_25193
Lnet/minecraft/class_5330$class_5331;field_25193:Ljava/lang/String;
named rootFieldName
Lnet/minecraft/util/JsonSerializing$SerializerBuilder;rootFieldName:Ljava/lang/String;
-
idFieldName
- Mappings:
Namespace Name Mixin selector official c
Ldyo$a;c:Ljava/lang/String;
intermediary field_25194
Lnet/minecraft/class_5330$class_5331;field_25194:Ljava/lang/String;
named idFieldName
Lnet/minecraft/util/JsonSerializing$SerializerBuilder;idFieldName:Ljava/lang/String;
-
typeGetter
- Mappings:
Namespace Name Mixin selector official d
Ldyo$a;d:Ljava/util/function/Function;
intermediary field_25195
Lnet/minecraft/class_5330$class_5331;field_25195:Ljava/util/function/Function;
named typeGetter
Lnet/minecraft/util/JsonSerializing$SerializerBuilder;typeGetter:Ljava/util/function/Function;
-
elementSerializer
@Nullable private @Nullable com.mojang.datafixers.util.Pair<T extends JsonSerializableType<E>,JsonSerializing.ElementSerializer<? extends E>> elementSerializer- Mappings:
Namespace Name Mixin selector official e
Ldyo$a;e:Lcom/mojang/datafixers/util/Pair;
intermediary field_25196
Lnet/minecraft/class_5330$class_5331;field_25196:Lcom/mojang/datafixers/util/Pair;
named elementSerializer
Lnet/minecraft/util/JsonSerializing$SerializerBuilder;elementSerializer:Lcom/mojang/datafixers/util/Pair;
-
defaultType
- Mappings:
Namespace Name Mixin selector official f
Ldyo$a;f:Ldyy;
intermediary field_28444
Lnet/minecraft/class_5330$class_5331;field_28444:Lnet/minecraft/class_5336;
named defaultType
Lnet/minecraft/util/JsonSerializing$SerializerBuilder;defaultType:Lnet/minecraft/util/JsonSerializableType;
-
-
Constructor Details
-
SerializerBuilder
SerializerBuilder(Registry<T> registry, String rootFieldName, String idFieldName, Function<E, T> typeIdentification) - Mappings:
Namespace Name Mixin selector official <init>
Ldyo$a;<init>(Lhq;Ljava/lang/String;Ljava/lang/String;Ljava/util/function/Function;)V
intermediary <init>
Lnet/minecraft/class_5330$class_5331;<init>(Lnet/minecraft/class_2378;Ljava/lang/String;Ljava/lang/String;Ljava/util/function/Function;)V
named <init>
Lnet/minecraft/util/JsonSerializing$SerializerBuilder;<init>(Lnet/minecraft/registry/Registry;Ljava/lang/String;Ljava/lang/String;Ljava/util/function/Function;)V
-
-
Method Details
-
elementSerializer
public JsonSerializing.SerializerBuilder<E,T> elementSerializer(T type, JsonSerializing.ElementSerializer<? extends E> serializer) Sets the element serializer and its target type. It can serialize and deserialize instances of one type to non-JsonObject
elements.- Parameters:
type
- the target type of the element serializerserializer
- the element serializer- API Note:
- There can only be one element serializer for this builder and the built serializer. Calling this method replaces any previous serializer.
- Mappings:
Namespace Name Mixin selector official a
Ldyo$a;a(Ldyy;Ldyo$b;)Ldyo$a;
intermediary method_32385
Lnet/minecraft/class_5330$class_5331;method_32385(Lnet/minecraft/class_5336;Lnet/minecraft/class_5330$class_5332;)Lnet/minecraft/class_5330$class_5331;
named elementSerializer
Lnet/minecraft/util/JsonSerializing$SerializerBuilder;elementSerializer(Lnet/minecraft/util/JsonSerializableType;Lnet/minecraft/util/JsonSerializing$ElementSerializer;)Lnet/minecraft/util/JsonSerializing$SerializerBuilder;
-
defaultType
Sets the default type that is used when there's no ID field.- Parameters:
defaultType
- the default type- Returns:
- this instance
- Mappings:
Namespace Name Mixin selector official a
Ldyo$a;a(Ldyy;)Ldyo$a;
intermediary method_33409
Lnet/minecraft/class_5330$class_5331;method_33409(Lnet/minecraft/class_5336;)Lnet/minecraft/class_5330$class_5331;
named defaultType
Lnet/minecraft/util/JsonSerializing$SerializerBuilder;defaultType(Lnet/minecraft/util/JsonSerializableType;)Lnet/minecraft/util/JsonSerializing$SerializerBuilder;
-
build
- Mappings:
Namespace Name Mixin selector official a
Ldyo$a;a()Ljava/lang/Object;
intermediary method_29307
Lnet/minecraft/class_5330$class_5331;method_29307()Ljava/lang/Object;
named build
Lnet/minecraft/util/JsonSerializing$SerializerBuilder;build()Ljava/lang/Object;
-