Skip to content

add NamespacedIdentifier to Core API - #50

Merged
SpaceWalkerRS merged 5 commits into
gen2from
namespaced-identifier
Dec 6, 2025
Merged

add NamespacedIdentifier to Core API#50
SpaceWalkerRS merged 5 commits into
gen2from
namespaced-identifier

Conversation

@SpaceWalkerRS

Copy link
Copy Markdown
Member

Essentially equivalent to Minecraft's Identifier, it'll be very useful for future APIs, and also for the Networking rewrite I'm working on.

I chose a different name to avoid the name conflict with the Vanilla class.

@ENDERZOMBI102

ENDERZOMBI102 commented Nov 22, 2025

Copy link
Copy Markdown

isn't the name a bit too long? maybe Location or just Id is better?

@SpaceWalkerRS
SpaceWalkerRS force-pushed the namespaced-identifier branch 2 times, most recently from 860c5d0 to 503cada Compare November 23, 2025 15:50
@SpaceWalkerRS

Copy link
Copy Markdown
Member Author

I updated the PR with more convenience methods for creating, validating, and parsing identifiers. I placed all of these in a separate class.

For validation, I went with [a-zA-Z0-9-._] for namespaces, and [a-zA-Z0-9-._/] for identifiers. This matches modern Identifiers except for the upper case letters, which I added only because they were used in Vanilla between 1.6 and 1.10.

Just like in 1.13+, identifiers are validated upon creation, and an exception is thrown if validation fails. I decided to do this validation in the factory methods rather than in the constructor of the identifier itself, because I think it may be useful to be able to construct invalid identifiers when parsing them from a legacy source.

@SpaceWalkerRS

Copy link
Copy Markdown
Member Author

Not sure what we're gonna do with the name yet. A bunch of discussion took place on Discord though.

@FubyCutie

Copy link
Copy Markdown

I'm of the opinion that names should tell you what isn't identical, in this case, very little of course, but using a synonym just for the sake of it being different doesn't help at all on that front. Something like OrnitheID or OrnitheIdentifier I think encapsulates it better, if we're claiming that the only difference is that it's implemented by OSL, rather than vanilla, which sounds not far off.

@SpaceWalkerRS

Copy link
Copy Markdown
Member Author

NamespacedIdentifier is now an interface. OSL provides its own implementation (NamespacedIdentifierImpl - devs won't interact with this directly), and also makes Vanilla's Identifier implement that interface.

Identifier's equals method is also modified to accept other implementations of NamespacedIdentifier, and NamespacedIdentifierImpls hashCode implementation exactly matches Identifier's.

I did not make NamespacedIdentifier extend Comparable because it would make compatibility with Identifier more dificult, and I don't think it's functionality we necessarily need.

@SpaceWalkerRS

Copy link
Copy Markdown
Member Author

oh one thing - it doesn't add the interface with interface injection yet, I'm saving that for later after some build script changes to make use of the fabric.mod.json generation task

@ENDERZOMBI102

Copy link
Copy Markdown

Maybe we could add a Comparator<NamespacedIdentifier>?

@SpaceWalkerRS
SpaceWalkerRS merged commit 37e23fc into gen2 Dec 6, 2025
2 checks passed
@SpaceWalkerRS
SpaceWalkerRS deleted the namespaced-identifier branch December 6, 2025 15:24
SpaceWalkerRS added a commit that referenced this pull request Dec 6, 2025
add `NamespacedIdentifier` to Core API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants