-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.20.4] Data maps #519
[1.20.4] Data maps #519
Conversation
This reverts commit bcc540a.
Last commit published: 9bbcd096226119b5c67735f130bd4435673ac138. PR PublishingThe artifacts published by this PR:Repository DeclarationIn order to use the artifacts published by the PR, add the following repository to your buildscript: repositories {
maven {
name 'Maven for PR #519' // https://github.com/neoforged/NeoForge/pull/519
url 'https://prmaven.neoforged.net/NeoForge/pr519'
content {
includeModule('net.neoforged', 'neoforge')
}
}
} MDK installationIn order to setup a MDK using the latest PR version, run the following commands in a terminal. mkdir NeoForge-pr519
cd NeoForge-pr519
curl -L https://prmaven.neoforged.net/NeoForge/pr519/net/neoforged/neoforge/20.4.177-beta-pr-519-204-reg-attachments/mdk-pr519.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip To test a production environment, you can download the installer from here. |
src/main/java/net/neoforged/neoforge/registries/datamaps/DataMapType.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/DataMapLoader.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/DataMapLoader.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/DataMapLoader.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/DataMapLoader.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/DataMapLoader.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/datamaps/AdvancedDataMapType.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/datamaps/DataMapType.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not done any testing of this PR, but from a code standpoint (and the fact the automated tests pass) it looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While testing further, I found a few issues and also found that a client without this PR (tested with vanilla 1.20.4, NF 20.4.108 and NF 20.4.130) cannot connect to a LAN world or dedicated server with this PR
src/main/java/net/neoforged/neoforge/registries/RegistryManager.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/RegistryManager.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/RegistryManager.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/network/configuration/RegistryDataMapNegotiation.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/network/configuration/RegistryDataMapNegotiation.java
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/ClientRegistryManager.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/ClientRegistryManager.java
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/common/data/DataMapProvider.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/DataMapLoader.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/RegistryManager.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/datamaps/DataMapType.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/datamaps/DataMapValueMerger.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/datamaps/DataMapValueRemover.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and connections work (or not) as expected with NF clients with the PR, NF clients without the PR and vanilla clients
Adds a data-driven system used to attach arbitrary objects to registry entries. Unlike tags, which are an
object->boolean
map, this system is anobject->?
map, that supports lists or maps through the use of mergers and removers.This system will be used by neo to replace vanilla maps such as the
COMPOSTABLES
(see bcc540a as an example implementation of that).Lookups are two
IdentityHashMap
lookups and should be decently fast.You can register a data map using a static
DataMapType
(created throughDataMapType#builder
), and registered inRegisterDataMapTypesEvent
.A more “advanced” version of simple data map types is provided through
AdvancedDataMapType
(and its builder). This version has a third generic, and supports merging values from conflicting data packs and selective removals.Using
DataMapType$Builder#synced
, a data map can become synced to clients. Ifmandatory
, clients that don't support the data map (and vanilla clients, by extension) will be disconnected and not allowed to connect. The use of non-mandatory synced data map types is mainly for replacement of vanilla features with this data-driven system. To use the compostables example, while compostables are only used on the server, Neo can mark the data map as optionally synced, to allow recipe viewers to display the values.Example JSON structure:
In the case of values that are merged through a merger (available for the
AdvancedDataMapType
), you can completely override the value as follows:A remover may also be provided by
AdvancedDataMapType
s. When a remover is provided, theremove
list can become a map, mapping a registry object ID / tag key to a remover object, or an object list withkey
andremover
entries.For example, a remover for a map may accept a list of keys to remove (see the tests class for an example implementation):
When not using the object list, but the map variant, you cannot combine removals without a remover and with a remover:
Supersedes #96.