-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Add REA filters #260
base: 1.21
Are you sure you want to change the base?
Add REA filters #260
Conversation
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.
LGTM, apart from minor Javadoc nitpicks
@@ -501,6 +513,17 @@ public Builder<R, V> defaultValueProvider(@Nullable DefaultValueProvider<R, V> d | |||
return this; | |||
} | |||
|
|||
/** | |||
* Sets the filter for the attachment. |
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.
* Sets the filter for the attachment. | |
* Sets the registry entry filter for the attachment. |
@@ -287,6 +288,15 @@ default Optional<V> get(R entry) { | |||
*/ | |||
boolean remove(TagKey<R> tag); | |||
|
|||
/** | |||
* The entry filter can prevent entries from being shown in the attachment. |
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 entry filter can prevent entries from being shown in the attachment. | |
* Gets the entry filter that determines if certain registry entries can be associated with values in this attachment. |
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.
Absolutely not the API I expected tbh.
I think I'd rather call this "condition" or something.
I'd rather see the filter concept applied to the entry logic, as-in being able to define:
{
id: "#minecraft:wood",
filter: [
"!#minecraft:non_burnable_wood"
]
}
Or something in the line, this could also be the basis of the future "copy" system or something.
Anyway, this system is also fine despite not serving the same purpose as my idea.
@@ -105,6 +105,7 @@ public class BlockContentRegistries { | |||
|
|||
return DataResult.success(block); | |||
})) | |||
.filter(block -> block.getDefaultState().contains(Properties.AXIS)) |
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.
Just noticed this.
While I like the idea, I also find it a bit bad, thought that comes from strippable being kind of awful from the start.
Allowing other kind of blocks to be strippable would be interesting but that's a debate for another PR. But it shows that the conditions system has potential.
This PR needs to be updated to 1.19.4 |
Updated to 1.20 |
@@ -287,6 +288,26 @@ default Optional<V> get(R entry) { | |||
*/ | |||
boolean remove(TagKey<R> tag); | |||
|
|||
/** | |||
* The entry validation can prevent entries from being shown in the attachment. |
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.
"Being shown" is misleading; it implies that this validator will silently drop entries, but you seem to throw a hard exception when an entry that fails the predicate is added:
Lines 197 to 199 in c8e05fb
if (!this.validator.test(entry)) { | |
throw new IllegalArgumentException(String.format("Entry %s does not pass validation for REA %s", this.registry.getId(entry), this.id)); | |
} |
We will need this for 1.21.2 and the new fuel system. I finally though of a good way of doing it, and ill update the pr soon. |
Fixes #255
Very simple API