Interface ConfigTag
- All Known Subinterfaces:
ConfigCategory,ConfigValue,ConfigValueList
- All Known Implementing Classes:
AbstractConfigTag,ConfigCategoryImpl,ConfigValueImpl,ConfigValueListImpl
-
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a deep clone of thisConfigTag.default voiddelete()Delete this tag from the parent.default voidManually trigger all registeredConfigCallback's in the tree.Gets the comment for the tag.default StringgetDesc()Gets a descriptive name for this tag.getName()Gets the name of this tag.@Nullable ConfigCategoryGet the parent tag.booleanisDirty()If thisConfigTagor any of its children are dirty and requires flushing to disk.booleanChecks if this tags is a synthetic network tag.voidread(MCDataInput in) Read this tag from aMCDataInput.booleanChecks if this tag or any of its children require client sync.voidreset()Reset this tag back to the default.voidResets all network tags back to their original value.voidrunSync(ConfigCallback.Reason reason) Triggers all registeredConfigCallback's in the tree with the specified reason.default voidsave()Saves the config to disk if any values have changed.setComment(String comment) Sets the comment for this tag.
Will be split on\n.setComment(String... comment) Sets the comment for this tag.setComment(List<String> comment) Sets the comment for this tag.Sets this tag as requiring syncing to the client.voidwrite(MCDataOutput out) Write this tag to aMCDataOutput.
-
Method Details
-
getName
String getName()Gets the name of this tag.- Returns:
- The name.
-
getDesc
Gets a descriptive name for this tag.some.tag.name- Returns:
- The descriptive name.
-
getParent
Get the parent tag.This will be
nullfor the root tag.- Returns:
- The parent or
null.
-
setComment
Sets the comment for this tag.
Will be split on\n.- Parameters:
comment- The comment line.- Returns:
- The same config tag.
-
setComment
Sets the comment for this tag.- Parameters:
comment- The comment lines.- Returns:
- The same config tag.
-
setComment
Sets the comment for this tag.- Parameters:
comment- The comment lines.- Returns:
- The same config tag.
-
getComment
Gets the comment for the tag.- Returns:
- The comment.
-
syncTagToClient
ConfigTag syncTagToClient()Sets this tag as requiring syncing to the client.Register your root tag via
ConfigSyncManager.registerSync(ResourceLocation, ConfigTag). -
requiresClientSync
boolean requiresClientSync()Checks if this tag or any of its children require client sync.- Returns:
- If client sync is required.
-
forceSync
default void forceSync()Manually trigger all registeredConfigCallback's in the tree. -
runSync
Triggers all registeredConfigCallback's in the tree with the specified reason.This method should probably not be called by anyone else.
- Parameters:
reason- The reason.
-
isNetworkTag
boolean isNetworkTag()Checks if this tags is a synthetic network tag.Synthetic network tags will exist on the client when some form of dynamic config structure is synced to the client.
- Returns:
- If the tag is synthetic.
-
save
default void save() -
isDirty
boolean isDirty()If thisConfigTagor any of its children are dirty and requires flushing to disk.- Returns:
- If the branch is dirty.
-
delete
default void delete()Delete this tag from the parent. -
reset
void reset()Reset this tag back to the default.In the event that this is a
ConfigCategorysets all descendant values to their default. -
copy
ConfigTag copy()Creates a deep clone of thisConfigTag.If this is called on a child tag, it will split from its parent.
Does not keep callbacks.
- Returns:
- The deep copied tag.
-
write
Write this tag to aMCDataOutput. Only categories and/or tags which havesyncTagToClient()set will be written.- Parameters:
out- The output stream.
-
read
Read this tag from aMCDataInput. All tags and values will be read and inserted into the tree.If a tag does not already exist in the tree, one will be added and marked as a 'network tag',
isNetworkTag().All tags with a network value will be reset to default when
resetFromNetwork()is called, whilst any 'network only' tags will be deleted.- Parameters:
in- The input stream.
-
resetFromNetwork
void resetFromNetwork()Resets all network tags back to their original value.Whilst a tag is set from the network, it is effectively immutable and may not be set.
Any tags which are 'network only' are deleted during this operation.
-