Posted November 24, 20195 yr Is there a method to add your own custom brewing stand recipes? It has nothing to do with adding custom potions and their effects. Let's say I just want to brew ITEM_A from ITEM_B as the ingredient and water bottles inside. Edited November 26, 20195 yr by Xander402 A few bytes about me: public class Xander402 extends Modder implements IForumMember { int javaExperience, moddingExperience; LearningWay preferredLearningWay; public Xander402() { this.javaExperience = BIG; this.moddingExperience = NOT_SO_BIG; this.preferredLearningWay = LearningWay.through("exampes"); super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay); } @Override public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); } }
November 24, 20195 yr Author Well, I really tried. I looked at BrewingRecipeRegistry, I found BrewingRecipeRegistry.addRecipe(Ingredient, Ingredient, ItemStack); and I put it here: @SubscribeEvent public void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(ItemList.getItems()); BrewingRecipeRegistry.addRecipe( ... ); } but I have no idea how to use Ingredient... I really miss any examples on the internet. I learn the best with examples. My question is: BrewingRecipeRegistry.addRecipe( /* Ingredient input - what to write here? (for example: water bottle*) */, /* Ingredient ingredient - what to write here? (for example: ItemList.ITEM_A) */, new ItemStack(ItemList.ITEM_B, 1) ); // * BTW, I'd like to know how to implement water bottle, since it's not an item, but a Potion Edited November 24, 20195 yr by Xander402 A few bytes about me: public class Xander402 extends Modder implements IForumMember { int javaExperience, moddingExperience; LearningWay preferredLearningWay; public Xander402() { this.javaExperience = BIG; this.moddingExperience = NOT_SO_BIG; this.preferredLearningWay = LearningWay.through("exampes"); super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay); } @Override public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); } }
November 24, 20195 yr Author Alright. I created a class SoySauceRecipe which looks like this: package ... import ... public class SoySauceRecipe implements IBrewingRecipe { private ItemStack output = new ItemStack(ItemList.soy_sauce); SoySauceRecipe() { } @Override public boolean isInput(ItemStack input2) { return input2.getItem().equals(Items.POTION) && PotionUtils.getEffectsFromStack(input2).isEmpty(); } @Override public boolean isIngredient(ItemStack ingredient2) { return ingredient2.getItem() == ItemList.soybean; } @Override public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) { return output; } } and registered the recipe here, in main mod file: package ... import ... @Mod("...") public class SushiMod { ... public SushiMod() { ... FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); } private void setup(final FMLCommonSetupEvent event) { DeferredWorkQueue.runLater(this::registerPotions); } private void registerPotions() { BrewingRecipeRegistry.addRecipe(new SoySauceRecipe()); } } Works fine... but not entirely. There are two problems: According to you, from Topic #64031: Recipes with Water Bottle ItemStack: Quote Yes, PotionUtils.getEffectsFromStack will give you all potions in a potion stack. If there are none, it's a water bottle. a potion with no effect is exclusively a water bottle. But so are potions such as an Awkward Potion as well. Therefore they get accepted as the input for the recipe, too. How to make the recipe only accept pure water bottle? After the soy sauce is brewed and there's still remaining soybean in the ingredient slot, the soy sauce gets brewed again with itself as the input. Why is that happening despite the fact that isInput method returns true only when there's a POTION input slot? Edited November 24, 20195 yr by Xander402 A few bytes about me: public class Xander402 extends Modder implements IForumMember { int javaExperience, moddingExperience; LearningWay preferredLearningWay; public Xander402() { this.javaExperience = BIG; this.moddingExperience = NOT_SO_BIG; this.preferredLearningWay = LearningWay.through("exampes"); super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay); } @Override public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); } }
November 24, 20195 yr Author diesieben07, I really appreciate that you answer people's question in such way that you make them do some research in their own. I even like that. Learning is more efficient when you put some effort into it. But sometimes this method fails :/. As I said, I learn the best with examples. I'm really tired after sieben hours of trying to do such relatively simple thing as adding a working brewing recipe with my mod items to the game... (yeah, I started this topic 7 hours ago and I've been doing nothing but trying to get this working). My SoySauceRecipe class looks like this now: package ... import ,,, public class SoySauceRecipe implements IBrewingRecipe { private ItemStack input = new ItemStack(Items.POTION); private ItemStack ingredient = new ItemStack(ItemList.soybean); private ItemStack output = new ItemStack(ItemList.soy_sauce); public SoySauceRecipe() { } @Override public boolean isInput(ItemStack input2) { return PotionUtils.getPotionFromItem(input2) == Potions.WATER; } @Override public boolean isIngredient(ItemStack ingredient2) { return ingredient2.getItem() == ingredient.getItem(); } @Override public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) { if (ingredient2 != null && input2 != null && isIngredient(ingredient2)) { ItemStack output2 = this.output.copy(); if (input2 != output2) return output2; else return null; } else return null; } } (with the line return PotionUtils.getPotionFromItem(input2) == Potions.WATER; from you plus the IBrewingRecipe#getOutput method found somewhere on this forum), and it all works the same way. Both Awkward Potion and Soy Sauce is still acceptable as the input. Moreover, I just found out that when I don't fill all of the 3 brewing stand output slots with bottles and there is Blaze Powder in its upper-left slot.., it gets replaced with soy sauce after brewing is done. -,- All this mess is shown on the screenshot. So... yeah.. Sorry, but could you please write for me a properly working class SoySauceRecipe that implements IBrewingRecipe with Water Bottle as the only acceptable input, Items.soybean as the ingredient, and Items.soy_sauce as the output..? I believe that this impossible challenge for a beginner modder like me is a piece of cake for somebody like you. A few bytes about me: public class Xander402 extends Modder implements IForumMember { int javaExperience, moddingExperience; LearningWay preferredLearningWay; public Xander402() { this.javaExperience = BIG; this.moddingExperience = NOT_SO_BIG; this.preferredLearningWay = LearningWay.through("exampes"); super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay); } @Override public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); } }
November 25, 20195 yr Author Well... Although debugging did illuminate some things that are going on when operating the brewing stand, one thing remains a mistery. As for now, the recipe works perfectly as intended... but only once. After one brewing, no further can be performed. My SoySauceRecipe class now: package ... import ... public class SoySauceRecipe implements IBrewingRecipe { private static final ItemStack INGREDIENT = new ItemStack(ItemList.soybean); private static final ItemStack OUTPUT = new ItemStack(ItemList.soy_sauce); SoySauceRecipe() { } @Override public boolean isInput(@Nonnull ItemStack stack) { LOGGER.info("IBrewingRecipe#isInput: return " + PotionUtils.getPotionFromItem(stack) + " == " + Potions.WATER); return PotionUtils.getPotionFromItem(stack) == Potions.WATER; } @Override public boolean isIngredient(@Nonnull ItemStack ingredient) { LOGGER.info("IBrewingRecipe#isIngredient: return " + INGREDIENT.getItem() + " == " + ItemList.soybean); return INGREDIENT.getItem() == ItemList.soybean; } @Nonnull @Override public ItemStack getOutput(@Nonnull ItemStack input, @Nonnull ItemStack ingredient) { LOGGER.info("IBrewingRecipe#getOutput: isInput(input) = " + isInput(input) + " isIngredient(ingredient) = " + isIngredient(ingredient) + " -> return " + ((isInput(input) && isIngredient(ingredient)) ? "OUTPUT (=" + OUTPUT + ")" : "ItemStack.EMPTY")); LOGGER.info("Target output: " + OUTPUT); if (isInput(input) && isIngredient(ingredient)) return OUTPUT; return ItemStack.EMPTY; } } Now, when I put Soybean to the ingredient slot, but leave the bottles slots empty, the log shows: [...] IBrewingRecipe#isIngredient: return soybean == soybean [...] IBrewingRecipe#isInput: return net.minecraft.potion.Potion@7f70e244 == net.minecraft.potion.Potion@fd14789 [...] IBrewingRecipe#getOutput: isInput(input) = false isIngredient(ingredient) = true -> return ItemStack.EMPTY [...] Target output: 1 soy_sauce First line - shows what is compared in isIngredient method. Second line - shows what is compared in isInput method. Third line - shows results of isIngredient and isInput methods and resulting ItemStack that is returned as the output. Fourth line - shows what should be the output of the recipe (it's the item declared in the OUTPUT field. Looks good for now. After adding water bottles: [...] IBrewingRecipe#isInput: return net.minecraft.potion.Potion@fd14789 == net.minecraft.potion.Potion@fd14789 [...] IBrewingRecipe#isIngredient: return soybean == soybean [...] IBrewingRecipe#getOutput: isInput(input) = true isIngredient(ingredient) = true -> return OUTPUT (=1 soy_sauce) [...] Target output: 1 soy_sauce As you can see, both isInput and isIngredient are returning true, thus getOutput returns ItemStack with Soy Sauce now, and the brewing begins. Target output is still 1 soy sauce. But after it finishes: [...] IBrewingRecipe#isInput: return net.minecraft.potion.Potion@7f70e244 == net.minecraft.potion.Potion@fd14789 [...] IBrewingRecipe#isIngredient: return soybean == soybean [...] IBrewingRecipe#getOutput: isInput(input) = false isIngredient(ingredient) = true -> return ItemStack.EMPTY [...] Target output: 0 air Despite the fact that the ingredient slot hasn't changed (which even the console output agrees with - as shows the second line), the target output somehow has changed to 0 air... Firstly, this state remains the same regardless of the bottles slots contents. Why is that? It should change when I put a water bottle inside, like at the first brewing. And secondly, how on earth is it possible that target output changed if the console reads content of the OUTPUT field which not only isn't changed anywhere in the code, but also is declared as final?? This looks like a Forge bug to me.., but I don't feel suitable to judge such things. Am I missing something..? --- Here's the GitHub repository: [LINK EXPIRED] Edited November 26, 20195 yr by Xander402 A few bytes about me: public class Xander402 extends Modder implements IForumMember { int javaExperience, moddingExperience; LearningWay preferredLearningWay; public Xander402() { this.javaExperience = BIG; this.moddingExperience = NOT_SO_BIG; this.preferredLearningWay = LearningWay.through("exampes"); super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay); } @Override public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); } }
November 25, 20195 yr Author Well, I'm happy to say that this fixed the error. ? Thank you for all your help on this topic! A few bytes about me: public class Xander402 extends Modder implements IForumMember { int javaExperience, moddingExperience; LearningWay preferredLearningWay; public Xander402() { this.javaExperience = BIG; this.moddingExperience = NOT_SO_BIG; this.preferredLearningWay = LearningWay.through("exampes"); super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay); } @Override public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); } }
April 13, 20214 yr 2 hours ago, eggpasta said: Can you please share your finished code as i am having the same issues don't necropost on a thread from 2 year ago and his solution possibly wouldn't work for you since it was for 1.14 just make a new topic and explain your issues further
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.