Posted August 31, 201411 yr 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
August 31, 201411 yr 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/
September 1, 201411 yr Please read about how events work. An event simply runs when certain conditions are met; in this case it's when a potion is brewed.
September 1, 201411 yr 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/
September 1, 201411 yr Author 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) { } }
September 1, 201411 yr I gave you an example, you should copy it. You have to pass the event type as the parameter -- that is how it knows what your are subscribed to. So you can't pass the itemstack, you need to pass the PotionBrewedEvent. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
September 1, 201411 yr Author 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?
September 2, 201411 yr 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/
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.