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

Add REA filters #260

Open
wants to merge 4 commits into
base: 1.21
Choose a base branch
from
Open

Add REA filters #260

wants to merge 4 commits into from

Conversation

OroArmor
Copy link
Member

Fixes #255

Very simple API

@OroArmor OroArmor requested a review from a team January 29, 2023 05:38
@OroArmor OroArmor requested a review from a team as a code owner January 29, 2023 05:38
@OroArmor OroArmor added enhancement New feature or request library: block Related to the block library. library: item Related to the item library. library: data Related to the data library. t: new api This adds a new API. s: waiting for test This pull request is waiting to be tested, the PR cannot be put in FCP until it has been tested. labels Jan 29, 2023
@OroArmor OroArmor added s: tested This pull request has been tested and confirmed as working. and removed s: waiting for test This pull request is waiting to be tested, the PR cannot be put in FCP until it has been tested. labels Jan 29, 2023
Copy link
Contributor

@Leo40Git Leo40Git left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.

Copy link
Contributor

@LambdAurora LambdAurora left a 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))
Copy link
Contributor

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.

@TheGlitch76 TheGlitch76 added s: outdated This pull request is outdated. and removed s: tested This pull request has been tested and confirmed as working. labels Mar 31, 2023
@TheGlitch76
Copy link
Contributor

This PR needs to be updated to 1.19.4

@OroArmor OroArmor changed the base branch from 1.19.3 to 1.20 August 31, 2023 06:31
@OroArmor
Copy link
Member Author

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.
Copy link
Contributor

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:

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));
}

@OroArmor OroArmor changed the base branch from 1.20 to 1.21 July 31, 2024 19:06
@OroArmor
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request library: block Related to the block library. library: data Related to the data library. library: item Related to the item library. s: outdated This pull request is outdated. t: new api This adds a new API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make an entry filter for REAs
4 participants