Record Class DataType<T>
java.lang.Object
java.lang.Record
dev.latvian.mods.klib.data.DataType<T>
- All Implemented Interfaces:
ArgumentGetter<T>, CustomRegistryOwnTypeProvider<io.netty.buffer.ByteBuf, DataType<?>>, CustomRegistryValue<io.netty.buffer.ByteBuf, DataType<?>>, RefOptimizer<DataType<?>>, WithKey
public record DataType<T>(com.mojang.serialization.Codec<T> codec, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> streamCodec, List<Map.Entry<String,T>> enumValues, @Nullable DataType<?> componentType)
extends Record
implements CustomRegistryValue<io.netty.buffer.ByteBuf, DataType<?>>, ArgumentGetter<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CustomRegistry<io.netty.buffer.ByteBuf, DataType<?>> Fields inherited from interface WithKey
COMPARATOR -
Constructor Summary
ConstructorsConstructorDescriptionDataType(com.mojang.serialization.Codec<T> codec, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> streamCodec, List<Map.Entry<String, T>> enumValues, @Nullable DataType<?> componentType) Creates an instance of aDataTyperecord class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.brigadier.arguments.ArgumentType<?> argument(net.minecraft.commands.CommandBuildContext ctx) com.mojang.serialization.Codec<T> codec()Returns the value of thecodecrecord component.@Nullable DataType<?> Returns the value of thecomponentTyperecord component.static <L,R> DataType <com.mojang.datafixers.util.Either<L, R>> static <T,L, R> DataType <T> either(DataType<L> left, DataType<R> right, Function<L, T> leftTo, Function<R, T> rightTo, Function<T, com.mojang.datafixers.util.Either<L, R>> from) Returns the value of theenumValuesrecord component.booleanIndicates whether some other object is "equal to" this one.get(com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx, String name) CustomRegistry<io.netty.buffer.ByteBuf, DataType<?>> inthashCode()Returns a hash code value for this object.listOf()static <T> DataType<T> of(com.mojang.serialization.Codec<T> codec, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> streamCodec) static <T> DataType<T> of(com.mojang.serialization.Codec<T> codec, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> streamCodec, List<Map.Entry<String, T>> enumValues) static <E> DataType<E> of(E[] values) static <E> DataType<E> of(E[] values, @Nullable NameProvider<E> nameProvider) static <T> DataType<net.minecraft.resources.ResourceKey<T>> of(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> registry) setOf()net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> Returns the value of thestreamCodecrecord component.@Nullable NumbertoString()Returns a string representation of this record class.static <C, T extends C>
DataType<C> unit(T value) Methods inherited from interface CustomRegistryOwnTypeProvider
typeMethods inherited from interface CustomRegistryValue
optionalKey, refMethods inherited from interface RefOptimizer
optimize
-
Field Details
-
REGISTRY
-
CODEC
-
STREAM_CODEC
-
DATA_TYPE
-
-
Constructor Details
-
DataType
public DataType(com.mojang.serialization.Codec<T> codec, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> streamCodec, List<Map.Entry<String, T>> enumValues, @Nullable @Nullable DataType<?> componentType) Creates an instance of aDataTyperecord class.- Parameters:
codec- the value for thecodecrecord componentstreamCodec- the value for thestreamCodecrecord componentenumValues- the value for theenumValuesrecord componentcomponentType- the value for thecomponentTyperecord component
-
-
Method Details
-
of
-
of
public static <T> DataType<T> of(com.mojang.serialization.Codec<T> codec, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> streamCodec) -
of
-
of
-
of
public static <T> DataType<net.minecraft.resources.ResourceKey<T>> of(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> registry) -
unit
-
either
-
either
-
getRegistry
- Specified by:
getRegistryin interfaceCustomRegistryValue<io.netty.buffer.ByteBuf, DataType<?>>
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
toString
-
listOf
-
setOf
-
argument
public com.mojang.brigadier.arguments.ArgumentType<?> argument(net.minecraft.commands.CommandBuildContext ctx) -
get
public T get(com.mojang.brigadier.context.CommandContext<net.minecraft.commands.CommandSourceStack> ctx, String name) throws com.mojang.brigadier.exceptions.CommandSyntaxException - Specified by:
getin interfaceArgumentGetter<T>- Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
toNumber
-
codec
Returns the value of thecodecrecord component.- Returns:
- the value of the
codecrecord component
-
streamCodec
public net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> streamCodec()Returns the value of thestreamCodecrecord component.- Returns:
- the value of the
streamCodecrecord component
-
enumValues
-
componentType
Returns the value of thecomponentTyperecord component.- Returns:
- the value of the
componentTyperecord component
-