Class ConditionalOps<T>
java.lang.Object
net.minecraft.resources.DelegatingOps<T>
net.minecraft.resources.RegistryOps<T>
net.neoforged.neoforge.common.conditions.ConditionalOps<T>
- All Implemented Interfaces:
com.mojang.serialization.DynamicOps<T>
Extension of
RegistryOps that also encapsulates a ICondition.IContext.
This allows getting the ICondition.IContext while decoding an entry from within a codec.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprivate static final classNested classes/interfaces inherited from class net.minecraft.resources.RegistryOps
RegistryOps.RegistryInfo<T>, RegistryOps.RegistryInfoLookup -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringKey used to store the value associated with conditions, when the value is not represented as a map.private final ICondition.IContextstatic final StringKey used for the conditions inside an object.Fields inherited from class net.minecraft.resources.DelegatingOps
delegate -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> com.mojang.serialization.Codec<Optional<T>> createConditionalCodec(com.mojang.serialization.Codec<T> ownerCodec) static <T> com.mojang.serialization.Codec<Optional<T>> createConditionalCodec(com.mojang.serialization.Codec<T> ownerCodec, String conditionalsKey) Creates a conditional codec.static <T> com.mojang.serialization.Codec<Optional<WithConditions<T>>> createConditionalCodecWithConditions(com.mojang.serialization.Codec<T> ownerCodec) static <T> com.mojang.serialization.Codec<Optional<WithConditions<T>>> createConditionalCodecWithConditions(com.mojang.serialization.Codec<T> ownerCodec, String conditionalsKey) Creates a conditional codec.static <T> com.mojang.serialization.Codec<List<T>> decodeListWithElementConditions(com.mojang.serialization.Codec<T> ownerCodec) Creates a codec that can decode a list of elements, and will check for conditions on each element.static com.mojang.serialization.MapCodec<ICondition.IContext> Returns a codec that can retrieve aICondition.IContextfrom a registry ops, for example withretrieveContext().decode(ops, ops.emptyMap()).Methods inherited from class net.minecraft.resources.RegistryOps
create, create, equals, getter, hashCode, injectRegistryContext, owner, retrieveElement, retrieveGetter, retrieveRegistryLookup, withParentMethods inherited from class net.minecraft.resources.DelegatingOps
compressMaps, convertTo, createBoolean, createByte, createByteList, createDouble, createFloat, createInt, createIntList, createList, createLong, createLongList, createMap, createMap, createNumeric, createShort, createString, empty, emptyList, emptyMap, getBooleanValue, getByteBuffer, getIntStream, getList, getLongStream, getMap, getMapEntries, getMapValues, getNumberValue, getStream, getStringValue, listBuilder, mapBuilder, mergeToList, mergeToList, mergeToMap, mergeToMap, mergeToMap, mergeToPrimitive, removeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.mojang.serialization.DynamicOps
convertList, convertMap, get, getGeneric, getNumberValue, set, update, updateGeneric, withDecoder, withEncoder, withParser
-
Field Details
-
context
-
DEFAULT_CONDITIONS_KEY
Key used for the conditions inside an object.- See Also:
-
CONDITIONAL_VALUE_KEY
Key used to store the value associated with conditions, when the value is not represented as a map. For example, if we wanted to store the value 2 with some conditions, we could do:{ "neoforge:conditions": [ ... ], "neoforge:value": 2 }- See Also:
-
-
Constructor Details
-
ConditionalOps
-
-
Method Details
-
retrieveContext
Returns a codec that can retrieve aICondition.IContextfrom a registry ops, for example withretrieveContext().decode(ops, ops.emptyMap()). -
createConditionalCodec
public static <T> com.mojang.serialization.Codec<Optional<T>> createConditionalCodec(com.mojang.serialization.Codec<T> ownerCodec) - See Also:
-
createConditionalCodec
public static <T> com.mojang.serialization.Codec<Optional<T>> createConditionalCodec(com.mojang.serialization.Codec<T> ownerCodec, String conditionalsKey) Creates a conditional codec.The conditional codec is generally not suitable for use as a dispatch target because it is never a
MapCodec.MapCodecCodec. -
decodeListWithElementConditions
public static <T> com.mojang.serialization.Codec<List<T>> decodeListWithElementConditions(com.mojang.serialization.Codec<T> ownerCodec) Creates a codec that can decode a list of elements, and will check for conditions on each element. -
createConditionalCodecWithConditions
public static <T> com.mojang.serialization.Codec<Optional<WithConditions<T>>> createConditionalCodecWithConditions(com.mojang.serialization.Codec<T> ownerCodec) - See Also:
-
createConditionalCodecWithConditions
public static <T> com.mojang.serialization.Codec<Optional<WithConditions<T>>> createConditionalCodecWithConditions(com.mojang.serialization.Codec<T> ownerCodec, String conditionalsKey) Creates a conditional codec.The conditional codec is generally not suitable for use as a dispatch target because it is never a
MapCodec.MapCodecCodec.
-