use of net.minecraft.potion.PotionHelper.MixPredicate in project Random-Things by lumien231.
the class ModRecipes method addGlowingMushroomRecipes.
public static void addGlowingMushroomRecipes() {
try {
Field listField = PotionHelper.class.getDeclaredField(MCPNames.field("field_185213_a"));
ReflectionUtil.makeModifiable(listField);
Field inputField = MixPredicate.class.getDeclaredField(MCPNames.field("field_185198_a"));
ReflectionUtil.makeModifiable(inputField);
Field reagentField = MixPredicate.class.getDeclaredField(MCPNames.field("field_185199_b"));
ReflectionUtil.makeModifiable(reagentField);
Field outputField = MixPredicate.class.getDeclaredField(MCPNames.field("field_185200_c"));
ReflectionUtil.makeModifiable(outputField);
List<PotionHelper.MixPredicate<PotionType>> conversionList = (List<MixPredicate<PotionType>>) listField.get(null);
List<MixPredicate<PotionType>> toAdd = new ArrayList<MixPredicate<PotionType>>();
for (MixPredicate<PotionType> p : conversionList) {
Ingredient reagent = (Ingredient) reagentField.get(p);
if (reagent.test(new ItemStack(Items.GLOWSTONE_DUST))) {
PotionType input = (PotionType) inputField.get(p);
PotionType output = (PotionType) outputField.get(p);
toAdd.add(new MixPredicate<PotionType>(input, Ingredient.fromItem(Item.getItemFromBlock(ModBlocks.glowingMushroom)), output));
}
}
RandomThings.instance.logger.log(Level.DEBUG, "Added " + toAdd.size() + " Glowing Mushroom Recipes");
conversionList.addAll(toAdd);
} catch (Exception e) {
RandomThings.instance.logger.log(Level.ERROR, "Couldn't add glowing mushroom potion recipes, please report this as a bug");
e.printStackTrace();
}
}
Aggregations