-
-
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.21.3] Encourage more usage of IConditionBuider #1716
base: 1.21.x
Are you sure you want to change the base?
Conversation
by deprecating all shortcut constructors and moving them into `IConditionBuilder`
Last commit published: e2da34f7dfabb3644c92149210097427b2ad9131. 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 #1716' // https://github.com/neoforged/NeoForge/pull/1716
url 'https://prmaven.neoforged.net/NeoForge/pr1716'
content {
includeModule('net.neoforged', 'testframework')
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-pr1716
cd NeoForge-pr1716
curl -L https://prmaven.neoforged.net/NeoForge/pr1716/net/neoforged/neoforge/21.3.57-beta-pr-1716-pr-condition-builder/mdk-pr1716.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. |
less of a breaking change
import org.slf4j.Logger; | ||
|
||
public interface DataProvider { | ||
-public interface DataProvider { |
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.
Do we really want it in every data provider? Or should we be more selective and only implement it where we know it is usable?
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 remembered seeing this PR (#1315) and thought our condition system supported any data file now, but guess I my assumption on that was wrong as it was closed not merged.
I can go through and find all the providers which directly support conditions, rather than implementing onto DataProvider
.
/** | ||
* @deprecated Use {@link IConditionBuilder} | ||
*/ | ||
@Deprecated(forRemoval = true, since = "1.12.3") |
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.
1.12.3?
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.
Good catch, should be fixed now
@@ -46,8 +45,8 @@ static void conditionalDatapackEntries(final DynamicTest test, final Registratio | |||
event.getLookupProvider(), | |||
builder, | |||
conditions -> { | |||
conditions.accept(CONDITIONAL_FALSE_DAMAGE_TYPE, FalseCondition.INSTANCE); | |||
conditions.accept(CONDITIONAL_TRUE_DAMAGE_TYPE, TrueCondition.INSTANCE); | |||
conditions.accept(CONDITIONAL_FALSE_DAMAGE_TYPE, IConditionBuilder.of().never()); |
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.
Makes me wonder if static methods in the builder would work instead. 🤔
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 was thinking that too, but that would have to wait until 21.4
Since afaik cant make static versions cause the method signature will conflict the the default ones.
@@ -17,14 +19,32 @@ default ICondition and(ICondition... values) { | |||
return new AndCondition(List.of(values)); | |||
} | |||
|
|||
default ICondition FALSE() { | |||
default ICondition never() { | |||
// TODO: Maybe also rename class and registry entry to 'never' as well |
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.
This kind of TODO will get forgotten and come back to haunt us in a few years. :P
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.
Deprecated the old TRUE
/FALSE
in favor of newly added always
/never
conditions
This PR aims to encourage modders to make more use of
IConditionBuilder
rather than constructing condition instances themselvesthis is done by
DataProvider
s which support conditions to now implementIConditionBuilder
making all of its helpers freely available to all inheritors.of
method allowing users to construct an instance in places where they do not have aDataProvider
or can implement it themselves.ICondtionBuilder
TRUE
/FALSE
conditions in favor of the newalways
/never
conditions