类 DataMapType<R,T>
java.lang.Object
net.neoforged.neoforge.registries.datamaps.DataMapType<R,T>
- 直接已知子类:
AdvancedDataMapType
A registry data map contains data-driven object that can be attached to a registry object.
Data maps are registered to the RegisterDataMapTypesEvent
.
They are loaded from JSON files located at:
<map namespace>/data_maps/<registry namespace>/<registry path>/<map path>.json
The registry namespace
is omitted if it is "minecraft".
The structure of the json file is as follows:
{
"replace": false // If true, all previous data will be cleared.
// The values object is a map of registry entry ID / tag to data map values.
"values": {
"someobject:someid": {}, // The object being attached
"#somepath:sometag": {} // Tags are also supported. All objects in the tag will then receieve the same value
},
// Optional object. Entries specified here will be removed after the data of the current json file is attached
"remove": ["minecraft:carrot", "#minecraft:logs"]
}
Data maps support conditions both JSON-level and attachment-level through the "neoforge:value"<T> object.
Data maps may be synced by specifying a networkCodec()
. If the map is mandatory
,
then vanilla clients (or any client that doesn't support this map) will not be able to connect.
Both datapack registries and normal, built-in registries support data maps.
You can access a data map using IRegistryExtension.getDataMap(DataMapType)
and IWithData.getData(DataMapType)
.
You can usually go through IWithData.getData(DataMapType) Holder} implementations in order to get the data of an object directly.
- 另请参阅:
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明private final com.mojang.serialization.Codec
<T> private final ResourceLocation
private final boolean
private final @Nullable com.mojang.serialization.Codec
<T> private final ResourceKey
<Registry<R>> -
构造器概要
构造器构造器说明DataMapType
(ResourceKey<Registry<R>> registryKey, ResourceLocation id, com.mojang.serialization.Codec<T> codec, @Nullable com.mojang.serialization.Codec<T> networkCodec, boolean mandatorySync) -
方法概要
修饰符和类型方法说明static <T,
R> DataMapType.Builder <T, R> builder
(ResourceLocation id, ResourceKey<Registry<R>> registry, com.mojang.serialization.Codec<T> codec) 返回 a data map type builder。com.mojang.serialization.Codec
<T> codec()
返回 the codec used to decode values。id()
返回 the ID of this data map。boolean
返回true
if this data map must be present on the client, andfalse
otherwise。@Nullable com.mojang.serialization.Codec
<T> 返回 the codec used to sync values。返回 the key of the registry this data map is for。
-
字段详细资料
-
registryKey
-
id
-
codec
-
networkCodec
-
mandatorySync
private final boolean mandatorySync
-
-
构造器详细资料
-
DataMapType
DataMapType(ResourceKey<Registry<R>> registryKey, ResourceLocation id, com.mojang.serialization.Codec<T> codec, @Nullable @Nullable com.mojang.serialization.Codec<T> networkCodec, boolean mandatorySync)
-
-
方法详细资料
-
builder
public static <T,R> DataMapType.Builder<T,R> builder(ResourceLocation id, ResourceKey<Registry<R>> registry, com.mojang.serialization.Codec<T> codec) 返回 a data map type builder。- 类型参数:
T
- the type of the data mapR
- the registry the data is for- 参数:
id
- the ID of the data mapregistry
- the key of the registry the data map is forcodec
- the codec used to deserialize the values from JSON- 返回:
- a data map type builder
-
registryKey
返回 the key of the registry this data map is for。- 返回:
- the key of the registry this data map is for
-
id
返回 the ID of this data map。- 返回:
- the ID of this data map
-
codec
返回 the codec used to decode values。- 返回:
- the codec used to decode values
-
networkCodec
返回 the codec used to sync values。- 返回:
- the codec used to sync values
-
mandatorySync
public boolean mandatorySync()返回true
if this data map must be present on the client, andfalse
otherwise。- 返回:
true
if this data map must be present on the client, andfalse
otherwise
-