-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
OroArmor
wants to merge
4
commits into
QuiltMC:1.21
Choose a base branch
from
OroArmor:rea-filters
base: 1.21
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add REA filters #260
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -20,6 +20,7 @@ | |||||
import java.util.Optional; | ||||||
import java.util.Set; | ||||||
import java.util.function.Function; | ||||||
import java.util.function.Predicate; | ||||||
|
||||||
import com.mojang.serialization.Codec; | ||||||
import org.jetbrains.annotations.ApiStatus; | ||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* This can be used to prevent values from tags leaking into the registry entry attachment when not intended, | ||||||
* such as nether wood in furnace fuels. | ||||||
* | ||||||
* @return the associated entry filter. | ||||||
*/ | ||||||
Predicate<R> entryFilter(); | ||||||
|
||||||
/** | ||||||
* {@return this attachment's "value associated with entry" event} | ||||||
*/ | ||||||
|
@@ -444,6 +454,8 @@ final class Builder<R, V> { | |||||
private @Nullable V defaultValue; | ||||||
private @Nullable DefaultValueProvider<R, V> defaultValueProvider; | ||||||
|
||||||
private Predicate<R> filter = o -> true; | ||||||
|
||||||
private Builder(Registry<R> registry, Identifier id, Class<V> valueClass, Codec<V> codec) { | ||||||
this.registry = registry; | ||||||
this.id = id; | ||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* | ||||||
* @param filter the entry filter | ||||||
* @return this builder | ||||||
*/ | ||||||
public Builder<R, V> filter(Predicate<R> filter) { | ||||||
this.filter = filter; | ||||||
return this; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Builds a new attachment. | ||||||
* | ||||||
|
@@ -510,10 +533,10 @@ public RegistryEntryAttachment<R, V> build() { | |||||
RegistryEntryAttachment<R, V> attachment; | ||||||
if (this.defaultValueProvider == null) { | ||||||
attachment = new ConstantDefaultRegistryEntryAttachmentImpl<>(this.registry, this.id, this.valueClass, | ||||||
this.codec, this.side, this.defaultValue); | ||||||
this.codec, this.side, this.defaultValue, this.filter); | ||||||
} else { | ||||||
attachment = new ComputedDefaultRegistryEntryAttachmentImpl<>(this.registry, this.id, this.valueClass, | ||||||
this.codec, this.side, this.defaultValueProvider); | ||||||
this.codec, this.side, this.defaultValueProvider, this.filter); | ||||||
} | ||||||
RegistryEntryAttachmentHolder.registerAttachment(this.registry, attachment); | ||||||
return attachment; | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.