From d0f4d495957d2454bdf43a64d31a21f06849e677 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 14 Mar 2019 19:22:18 +0800 Subject: Using Cloth as a hard dependency now --- .../net/minecraft/recipe/REIPotionRecipeUtils.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/net/minecraft/recipe/REIPotionRecipeUtils.java (limited to 'src/main/java/net/minecraft/recipe/REIPotionRecipeUtils.java') diff --git a/src/main/java/net/minecraft/recipe/REIPotionRecipeUtils.java b/src/main/java/net/minecraft/recipe/REIPotionRecipeUtils.java new file mode 100644 index 000000000..cc3bc6508 --- /dev/null +++ b/src/main/java/net/minecraft/recipe/REIPotionRecipeUtils.java @@ -0,0 +1,36 @@ +package net.minecraft.recipe; + +import com.google.common.collect.Lists; +import me.shedaniel.cloth.api.ReflectionUtils; +import net.minecraft.item.Item; +import net.minecraft.potion.Potion; + +import java.util.List; + +public class REIPotionRecipeUtils { + + public static Object getInputFromRecipe(BrewingRecipeRegistry.Recipe o) throws Throwable { + return ReflectionUtils.getField(o, Object.class, 0).orElseThrow(ReflectionUtils.ReflectionException::new); + } + + public static Object getOutputFromRecipe(Object o) throws Throwable { + return ReflectionUtils.getField(o, Object.class, 2).orElseThrow(ReflectionUtils.ReflectionException::new); + } + + public static Ingredient getIngredientFromRecipe(Object o) throws Throwable { + return ReflectionUtils.getField(o, Ingredient.class, 1).orElseThrow(ReflectionUtils.ReflectionException::new); + } + + public static List> getItemRecipes() { + return ReflectionUtils.getStaticField(BrewingRecipeRegistry.class, List.class, 1).orElse(Lists.newArrayList()); + } + + public static List> getPotionRecipes() { + return ReflectionUtils.getStaticField(BrewingRecipeRegistry.class, List.class, 0).orElse(Lists.newArrayList()); + } + + public static List getPotionTypes() { + return ReflectionUtils.getStaticField(BrewingRecipeRegistry.class, List.class, 2).orElse(Lists.newArrayList()); + } + +} -- cgit