Jump to content

How do you use PotionBrewedEvent?


killerjdog51

Recommended Posts

Alright, so im trying to brew a custom potion using the resistance effect in the game (a resistance potion) and to do that im trying to use the PotionBrewedEvent. the problem is im not exactly sure how to use this event or how it works... but this is my code so far.

package com.Deer.Main;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import com.Deer.Item.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.brewing.PotionBrewedEvent;

public class PotionEventHandler extends PotionBrewedEvent{




public PotionEventHandler(ItemStack[] brewingStacks) {
	super(brewingStacks);

}


}

 

please help me with this. i would really appreciate it. sincerely killerjdog51

Link to comment
Share on other sites

Thats..... not how events work.

 

You need to make a class and register it with

MinecraftForge.EVENT_BUS.register(new YourClass());

. In that class make a method with the event as a parameter. Above the method, put the @SubscribeEvent annotation. Then you can do whatever you want with the event.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

The problem with your code is that by extending the event you are basically creating a new event.  That's not what you want to do; instead you need to handle the existing event.

 

So first of all, your event handling class shouldn't extend anything.  Just be a class on its own.

 

Secondly, the methods in your event handling class need to be annotated with @SubscribeEvent.  Just put this right before each method.

 

Then to make sure it is subscribed to the event you want, the parameter passed to the method should be the event you want to listen for.  For example:

    @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
    public void onEvent(PotionBrewedEvent event)
    {
         System.out.println("A potion was brewed!");       
    }

 

Then you have to make sure the whole class is registered to the right event bus.  For general information on that, please see my tutorial: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

 

Lastly you need to put some code into the method that does what you want.  The key is that the event parameter contains fields that are useful for the particular event.  In this case there is event.brewingstacks which passes whatever has been brewed (note it could be null).

 

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Ok, so am i suppose to subscribe it like this?

package com.Deer.Main;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import com.Deer.Item.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.brewing.PotionBrewedEvent;

public class PotionEventHandler{



@SubscribeEvent
public void PotionEventHandler(ItemStack[] brewingStacks) {

}


}

Link to comment
Share on other sites

ahhh, i see now. i didnt notice before, thank you. so how do you actually have it brew the potion when you insert a certain item. am i supose to use an If statement?

 

What exactly are you trying to do?  The PotionBrewedEvent fires right when it is ready to finish brewing and output the resulting potions.  Do you want to change the brewing recipe instead?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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

    • file:///C:/Users/Danie/Downloads/Capture.JPG I keep experiencing this error, does anyone know how to fix it here is the report: file:///C:/Users/Danie/AppData/Roaming/.minecraft/crash-reports/Bug_report1.txt
    • Hi, i am unable to join a multiplayer server my friend and i created. We started it with some mods then decided to add some others and this is when the error appeared. We are using Curseforge, the server is in 1.20.1 . The full error message is "Internal Exception: io.netty.handler.codec.DecoderException: java.lang.ArrayIndexOutOfBoundsException: Index 17196645 out of bounds for length 13" I am the only one with that issue, my friends can log in and out no problem. I have tried switching minecraft account but that doesn't help so i guess the bug is on my side. We use the same mod profile so i know the error doesn't come from there. Here is the latest.log file https://pastebin.com/X6J9Fnnf. If you need more informations to try and investigate, please let me know. Big thanks to anyone that will try to help
    • [00:02:07] [main/ERROR]: Missing or unsupported mandatory dependencies:     Mod ID: 'kotlinforforge', Requested by: 'flightlib', Expected range: '[4.3.0,)', Actual version: '[MISSING]'     Mod ID: 'terrablender', Requested by: 'biomesoplenty', Expected range: '[2.2.0.154,)', Actual version: '[MISSING]'     Mod ID: 'geckolib', Requested by: 'cakescosmetics', Expected range: '[4.4,)', Actual version: '[MISSING]'     Mod ID: 'balm', Requested by: 'waystones', Expected range: '[7.2.0,)', Actual version: '[MISSING]'     Mod ID: 'oculus', Requested by: 'irisflw', Expected range: '[1.6.15,)', Actual version: '[MISSING]'     Mod ID: 'cupboard', Requested by: 'betterfpsdist', Expected range: '[1.20.1-1.5,)', Actual version: '[MISSING]' [00:02:53] [main/WARN]: Mod file C:\Users\ezkid\AppData\Roaming\.minecraft\libraries\net\minecraftforge\fmlcore\1.20.1-47.2.32\fmlcore-1.20.1-47.2.32.jar is missing mods.toml file [00:02:54] [main/WARN]: Mod file C:\Users\ezkid\AppData\Roaming\.minecraft\libraries\net\minecraftforge\javafmllanguage\1.20.1-47.2.32\javafmllanguage-1.20.1-47.2.32.jar is missing mods.toml file [00:02:54] [main/WARN]: Mod file C:\Users\ezkid\AppData\Roaming\.minecraft\libraries\net\minecraftforge\lowcodelanguage\1.20.1-47.2.32\lowcodelanguage-1.20.1-47.2.32.jar is missing mods.toml file [00:02:54] [main/WARN]: Mod file C:\Users\ezkid\AppData\Roaming\.minecraft\libraries\net\minecraftforge\mclanguage\1.20.1-47.2.32\mclanguage-1.20.1-47.2.32.jar is missing mods.toml file [00:02:65] [main/ERROR]: Skipping early mod setup due to previous error
    • Guns and more cool stuff
    • nvm i did it, turn out i just needed to install a drive or smth
  • Topics

×
×
  • Create New...

Important Information

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