Skip to content
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

[Suggestion] Support for mods to customize tweaks without dependencies #87

Open
MarioSMB opened this issue Aug 9, 2022 · 9 comments
Open
Labels
enhancement New feature or request

Comments

@MarioSMB
Copy link

MarioSMB commented Aug 9, 2022

As suggested here: SlimeKnights/TinkersConstruct#4967 (comment)
It would be nice if mods would be able to apply a container tag rather than needing to include Mouse Tweaks as a dependency. Support for Tinker's Construct is partially broken without this.

@YaLTeR
Copy link
Owner

YaLTeR commented Aug 9, 2022

Hm, does @MouseTweaksDisableWheelTweak really require Mouse Tweaks to be loaded at runtime? I've seen a few mods use it, surely they wouldn't if it required Mouse Tweaks... That said I honestly have very little idea how to do this properly (or what a Container tag is) so maybe there's some example I could follow and some test mod with which I could test that I got it right?

@KnightMiner
Copy link

I cannot see how adding an annotation to a class would not be a runtime dependency.

As far as what a container tag is, any registry in minecraft supports tags. Its just like a block tag or an item tag, but on the container registry. Find the registry closest to the container screens and use tags from that.

@YaLTeR YaLTeR added the enhancement New feature or request label Aug 9, 2022
@YaLTeR
Copy link
Owner

YaLTeR commented Aug 9, 2022

I cannot see how adding an annotation to a class would not be a runtime dependency.

The idea was to have an "api" type dependency with the annotation class, and at runtime Mouse Tweaks checks the annotation presence with reflection. I think a number of other mods also have "api" dependencies that don't require said mods loaded at runtime; it's entirely possible that I did something wrong though.

@KnightMiner
Copy link

KnightMiner commented Aug 9, 2022

The mods that do that annotate a class used nowhere else in their logic (that is, that has no use without the mod the annotation is from). Not annotate a class that the mod cannot run without.

For example, JEI annotates a JEI plugin class, not my recipe class or my GUI

@KnightMiner
Copy link

I am going to go ahead and bump this issue again. Adding a container tag is the best way to fix this.

@YaLTeR
Copy link
Owner

YaLTeR commented Jan 2, 2025

Do you mind making a pull request?

@KnightMiner
Copy link

KnightMiner commented Jan 3, 2025

It would be quite awhile before I have time to do that as I'm still focused on making my own mod stable right now.

You would accomplish it far faster as you know your codebase and where you intended that blacklist.

Container menu tags are very straight forward; you just do something like this to query the tag using the container menu instance: https://github.com/SlimeKnights/Mantle/blob/1.20/src/main/java/slimeknights/mantle/util/RegistryHelper.java#L54-L60

(would be easier if Mojang just added a method to fetch a holder given an object).

Beyond that, just make a TagKey<ContainerMenuType> (or whatever the base class is for that registry) forge has examples of other registries in their Tags class.

@YaLTeR
Copy link
Owner

YaLTeR commented Jan 3, 2025

Do you have an example mod I could use to test that I did it right?

@KnightMiner
Copy link

KnightMiner commented Jan 3, 2025

You should be able to just add the tag to some vanilla container, e.g. a chest. Registry name is menu, so data/mousetweaks/tags/menu/disable_wheel_tweak.json would be the location for TagKey.create(Registries.MENU, new ResourceLocation("mousetweaks", "disable_wheel_tweak")). Just make sure to fill the tag with menu IDs if you are using the menu registry for this, seems if you wanted to test with a single chest that is minecraft:generic_9x3.

You could use a different registry but I think menu is closest to a screen. If a screen has no menu, then there is not really an equivalent and you'd need a more complex API to allow disabling without a runtime time dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants