Added toast generation for datagen'd recipes

This commit is contained in:
Ayutac 2022-02-09 20:29:50 +01:00
parent a097f9eae1
commit 6fa922c022
6 changed files with 62 additions and 9 deletions

View file

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