Jump to content

[FIXED] [1.14.4] Custom brewing recipes?


Xander402

Recommended Posts

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 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++; }); }
}

 

Link to comment
Share on other sites

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 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++; }); }
}

 

Link to comment
Share on other sites

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:

  1. 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?

  2. 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 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++; }); }
}

 

Link to comment
Share on other sites

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.

 

2019-11-25_00.28.53.png

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++; }); }
}

 

Link to comment
Share on other sites

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
  1. First line - shows what is compared in isIngredient method.
  2. Second line - shows what is compared in isInput method.
  3. Third line - shows results of isIngredient and isInput methods and resulting ItemStack that is returned as the output.
  4. 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 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++; }); }
}

 

Link to comment
Share on other sites

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++; }); }
}

 

Link to comment
Share on other sites

  • 1 year later...
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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Turning the Tables: My Journey to Reclaim Stolen Bitcoins with Expert Help. When my Bitcoin wallet was hacked and my entire cryptocurrency portfolio was stolen, I felt utterly devastated and hopeless. Having worked hard to build up my digital assets, the sudden loss was gut-wrenching. It felt like my financial future had been ripped away in an instant, leaving me overwhelmed by a sense of betrayal and despair. In my search for help, I discovered TECH CYBER FORCE Recovery, a renowned cybersecurity firm specializing in cryptocurrency recovery. I was met with professionalism and empathy from my first contact with them. The team demonstrated a steadfast commitment to helping me retrieve my stolen Bitcoins. They understood the emotional toll of my situation and approached my case with genuine concern. TECH CYBER FORCE Recovery swung into action immediately, leveraging its extensive expertise in blockchain forensics and hacker tracking techniques. Their process was meticulous. They analyzed my transaction history, followed the digital trail left by the hackers, and worked diligently to pinpoint the location of the stolen funds. I was impressed by their technical prowess; they employed advanced cryptographic methods and strategic negotiations with the perpetrators, all while keeping me informed about their progress. The recovery process was complex and fraught with challenges. However, the tenacity displayed by the team was truly awe-inspiring. They navigated cryptocurrency crime's murky and ever-evolving landscape with skill and determination. After a series of strategic moves, they managed to recover the majority of my Bitcoins successfully.  
    • I removed giacomos_hud, oculus, (dont know what you mean with iris), enhanced_boss_bars, epicfight and essential.  Server still doesnt want to boot. new logs after removing: https://pastebin.com/LuM2PFtN I dont quite understand the "server side" and "client side" difference..
    • There are client side only mods in your server files   Remove giacomos_hud, oculus, iris, enhanced_boss_bars and epicfight You can keep these mods in your client Maybe also remove essentials
    • Here is my Log with java 17: https://pastebin.com/RPdWSjwq
    • Been working on creating a server for this mod, but i keep getting this error over and over again.  I have tried updating/changing the Forge launcher, Removing/replacing the ops.json and whitelist.json folders, and removing certain mods. Crash report log: https://pastebin.com/Bu046cVq Debug.log https://pastebin.com/7hKm40ke Latest.log https://pastebin.com/nCRLUH3b any help would be great thanks!
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.