-
Notifications
You must be signed in to change notification settings - Fork 484
Entry Removals in json tag files #4721
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
base: 1.21.9
Are you sure you want to change the base?
Entry Removals in json tag files #4721
Conversation
fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/impl/tag/FabricTagEntryImpl.java
Outdated
Show resolved
Hide resolved
fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/mixin/tag/TagGroupLoaderMixin.java
Show resolved
Hide resolved
| private boolean required; | ||
|
|
||
| @Unique | ||
| private final boolean removed; |
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.
Not too keen on this implementation, as is breaks assumptions that other mods may use for the TagEntry class. Instead, maybe TagFile should maintain a separate list for c:remove, in a way that is closer to the actual file representation.
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.
The reason it's done like this is to avoid adding a field to TagFile. We'll have to discuss alternatives. I don't really like extending TagEntry, but maybe that is preferable. I considered doing more patching to fake the field better, but decided against it for now.
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.
Whats the concern with adding a Field to TagFile? is it the fact its a mixin? Its not a deal breaker if we are careful.
fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/mixin/tag/TagEntryMixin.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 havent done an indepth review of the impl just yet. Overall I am happy with the propsoal.
I think we should start by having this as fabric:remove. As I said on discord I am hesitant to merge a c:remove without first being 100% sure that neo are also going to adopt this, we have been burnt by this before. Lets concenrate on ourselves first as we can easily add support for c:remove later when the stars have all aligned.
Data generation support is also required for this, and I think there is a lot of scope to improve the tests.
This looks like a great start though 👍
|
|
||
| import net.fabricmc.fabric.impl.tag.util.WrapperCodec; | ||
|
|
||
| public final class FabricTagEntryImpl { |
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.
FabricTagEntryImpl but it doesnt implement FabricTagEntry?
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'm not sure what to call it, as it just contains the mixin context thread local and the codec we merge. It can implement FabricTagEntry, but then the mixin doesn't implement FabricTagEntryImpl, and if we make it an interface so the mixin can implement it, then we lose encapsulation
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.
Perhaps FabricTagEntryInternals is clearer to what it actually does?
| private boolean required; | ||
|
|
||
| @Unique | ||
| private final boolean removed; |
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.
Whats the concern with adding a Field to TagFile? is it the fact its a mixin? Its not a deal breaker if we are careful.
| // Test 1: Alias two non-empty tags | ||
| public static final TagKey<Item> GEMS = tagKey(RegistryKeys.ITEM, "gems"); | ||
| public static final TagKey<Item> EXPENSIVE_ROCKS = tagKey(RegistryKeys.ITEM, "expensive_rocks"); | ||
| public static final TagKey<Item> GEMS = TagTestUtils.tagKey(RegistryKeys.ITEM, "gems"); |
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.
Nit: Static import TagTestUtils, will make the diff a little nicer.
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.
Re:
Whats the concern with adding a Field to TagFile? is it the fact its a mixin? Its not a deal breaker if we are careful.
It is a record, and there currently isn't a good way to add a record field with a mixin. With current jvm behavior it wouldn't be the end of the world, but I'd prefer to avoid it if possible. I have some unpushed commits that help with this a little, I think, so I'll re request review when I push.
Git didn't give me the option to respond to the actual comment for some reason
adds a
c:removefield to json tag files allowing removals from existing contents.{ "replace": false, "c:remove": [ "brick" ], "values": [ "brick", "snowball" ] }