Added toast generation for datagen'd recipes
This commit is contained in:
parent
a097f9eae1
commit
6fa922c022
6 changed files with 62 additions and 9 deletions
|
@ -25,6 +25,7 @@
|
|||
package reborncore.common.misc;
|
||||
|
||||
import net.minecraft.tag.Tag;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Tells if an item, block etc. has a tag solely for compatibility with other mods.
|
||||
|
@ -39,4 +40,16 @@ public interface TagConvertible<T> {
|
|||
*/
|
||||
Tag.Identified<T> asTag();
|
||||
|
||||
/**
|
||||
* Converts a given object into its tag form if the item is a {@link TagConvertible}.
|
||||
* @param obj the object to convert
|
||||
* @return The tag of the object or the object itself if it is not a {@link TagConvertible}.
|
||||
*/
|
||||
@Contract("null -> null")
|
||||
static Object convertIf(Object obj) {
|
||||
if (obj instanceof TagConvertible<?> convertible)
|
||||
return convertible.asTag();
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue