neoforged / NeoForge

Neo Modding API for Minecraft, based on Forge
https://neoforged.net
Other
1.25k stars 179 forks source link

[1.21.3] Add condition to validate feature flags enabled state #1706

Closed ApexModder closed 58 minutes ago

ApexModder commented 2 hours ago

Modders who maintain multi-jar mods, that being mods whose feature set is split across multiple jars, may want a single flag in their common jar which toggles features across all of their mod jars. Due to the nature of how feature packs work and are enabled, this is not possible.

While you can have multiple packs which all enable the same flag, they will all display as individual selections in the "experiments" screen, when the intention is to have 1 toggle for all these packs.

To work around that, modders can make use of the newly added condition in this PR, which takes in a set of feature flags and whether to validate for them being enabled or disabled to conditionally load their desired elements without needing to be in the same feature pack.

neoforged-pr-publishing[bot] commented 2 hours ago

Last commit published: a532e439eae683949a5897d25eb69ff436d55a54.

PR Publishing ### The artifacts published by this PR: - :package: [`net.neoforged:testframework:21.3.44-beta-pr-1706-pr-feature-flag-condition`](https://github.com/neoforged/NeoForge/packages/2325466) - :package: [`net.neoforged:neoforge:21.3.44-beta-pr-1706-pr-feature-flag-condition`](https://github.com/neoforged/NeoForge/packages/2325465) ### Repository Declaration In order to use the artifacts published by the PR, add the following repository to your buildscript: ```gradle repositories { maven { name 'Maven for PR #1706' // https://github.com/neoforged/NeoForge/pull/1706 url 'https://prmaven.neoforged.net/NeoForge/pr1706' content { includeModule('net.neoforged', 'testframework') includeModule('net.neoforged', 'neoforge') } } } ``` ### MDK installation In order to setup a MDK using the latest PR version, run the following commands in a terminal. The script works on both *nix and Windows as long as you have the JDK `bin` folder on the path. The script will clone the MDK in a folder named `NeoForge-pr1706`. On Powershell you will need to remove the `-L` flag from the `curl` invocation. ```sh mkdir NeoForge-pr1706 cd NeoForge-pr1706 curl -L https://prmaven.neoforged.net/NeoForge/pr1706/net/neoforged/neoforge/21.3.44-beta-pr-1706-pr-feature-flag-condition/mdk-pr1706.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](https://prmaven.neoforged.net/NeoForge/pr1706/net.neoforged/neoforge/21.3.44-beta-pr-1706-pr-feature-flag-condition/neoforge-21.3.44-beta-pr-1706-pr-feature-flag-condition-installer.jar).
ApexModder commented 58 minutes ago

Closing as this does not seem possible, thought I had it implemented and working but turns out initial world/server load reports the incorrect status for feature flag states causing the test recipe to not be enabled. Subsequent /reload after the world/server has loaded does fix this.

I have tried many different ways to pass the enabled feature set to the conditions context object, but nothing seems to work, and flags are always reporting back as disabled.