Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6281a8d
commit d8edb14
Showing
2 changed files
with
47 additions
and
20 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/org/auioc/mcmod/arnicalib/game/datagen/tag/IHTagsProvider.java
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.auioc.mcmod.arnicalib.game.datagen.tag; | ||
|
||
import java.util.function.Predicate; | ||
import javax.annotation.Nullable; | ||
import net.minecraft.data.tags.TagsProvider.TagAppender; | ||
import net.minecraftforge.registries.IForgeRegistry; | ||
import net.minecraftforge.registries.IForgeRegistryEntry; | ||
|
||
public interface IHTagsProvider<T extends IForgeRegistryEntry<T>> { | ||
|
||
@Nullable | ||
default IForgeRegistry<T> getRegistry() { | ||
return null; | ||
} | ||
|
||
default TagAppender<T> addFromRegistry(TagAppender<T> appender, Predicate<T> predicate) { | ||
var registry = this.getRegistry(); | ||
if (registry == null) throw new UnsupportedOperationException("'addFromRegistry' method should not be called unless a registry is specified"); | ||
for (var value : registry.getValues()) { | ||
if (predicate.test(value)) { | ||
appender.add(value); | ||
} | ||
} | ||
return appender; | ||
} | ||
|
||
} |
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