Jump to content

event handler testing


gyro42

Recommended Posts

What events are you trying to handle?

 

For testing I use a lot of console statements using System.out.println() then you can check to see if the code is following the path you expect.  It is also interesting to learn how the events fire -- some only fire on Server, some on both Client and Server, etc.  So print out a lot of console statements and watch and learn.

 

Otherwise, for any given event hopefully you have an idea when it should fire.  If you're handling a block harvest event, then go into your game and start harvesting blocks.  And so forth.

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

Link to comment
Share on other sites

right now im trying to get into a vanilla block harvest event. I am trying to add my mod item to the drop list, and failing at it :D

 

anyways i just want some kind of method that will fire for me when my if statements arent all true that shows in game somehow (damage player, add an effect on block destruction, something)

Link to comment
Share on other sites

right now im trying to get into a vanilla block harvest event. I am trying to add my mod item to the drop list, and failing at it :D

 

anyways i just want some kind of method that will fire for me when my if statements arent all true that shows in game somehow (damage player, add an effect on block destruction, something)

 

From the way you describe it, I think you may be thinking about events wrong.  Normally you don't fire the events (although you can in certain circumstances).  Instead the built-in events are firing whenever things happen in the game and you can intercept them.  So you need to basically register an entity handling method for the event you're interested in, and the event parameter that gets passed into that event will have information (like the drops) and allow you to change some things, and even cancel other vanilla processing from continuing.

 

I have a tutorial on events here: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

 

Events are very powerful because they've made events for most of the common things that modders like to change.  So you can intercept how things render, or how they update, or how they spawn, or how they die, or what they drop, or what they get hurt by, etc.  It is one of the main ways of changing vanilla behavior in cases where a public field or method isn't available from the vanilla class.

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

Link to comment
Share on other sites

for now i will take your advice use a bunch of console statements and see how my handler is working in the game. To be honest im not really sure if it has been registered properly in init. I will go ahead and check out your tutorial too. thank you.

 

my original question is still unanswered though. I dont know anything to use in an event or otherwise that is immediately apparent in the game.

Link to comment
Share on other sites

Maybe you don't understand what the events are.  There are events being fired off all the time by Forge and FML.  Some events like the tick and update events are fired every tick.  Other events are fired when certain things happen -- like an entity death event, or a block harvest event.

 

So if you make a handler that handles a tick event, and it is registered properly, and you put console statements in the handling method, you should see the console statements come out continuously.

 

If you make a handler that handles a block harvest event, then you'd only see console statement when you harvest something in the game.

 

An "event" isn't necessarily something special in the game, rather it is just an indicator about which part of the vanilla code is running and gives you an opportunity to react at that time and possibly modify how the game continues to execute.

 

What event are you trying to handle?

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

Link to comment
Share on other sites

Well ive gotten it working now. The output tags helped alot.

 

I was trying to handle BlockEvent.HarvestDropsEvent on grass. I was using Blocks.grass which it turns out, isnt actually grass. I found this out when i accidently mined the dirt in front of one while i was testing with the tags.

 

I did read through your walkthrough and found it pretty informative. thanks again for being so helpful

Link to comment
Share on other sites

Like he said jabelar said up there, events can be Forge events or, FML events. But, he didn't mention that each of which need to be registered differently.

 

For Forge events you'd do this:

//Under your init method in your main class.
MinecraftForge.EVENT_BUS.register(new YourFancyEventHandler());

 

For FML events you'd do this:

FMLCommonHandler.instance().bus().register(new YourFancyEventHandler());

 

Remember, there are also CLIENT only events like RenderGameOverlay and ClientTickEvent. Those of which basically require you to not input server code into them (pretty obvious XP). Finally, if you ever want to use:

 

Minecraft mc = Minecraft.getMinecraft(); //Getting the instance of Minecraft

 

You CANNOT use this during server side events or, the game will crash.

 

There's my brief event tutorial! I was taught to separate Forge events and FML events into separate classes such as "EventsFML" and "EventsForge". And for client I do "EventsClientFML" and "EventsClientForge".

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Slot Gacor untuk Sensasi Bermain Maksimal Olahraga cepat dan seru dengan slot gacor di OLXTOTO. Rasakan sensasi bermain maksimal dengan mesin slot yang memberikan kemenangan beruntun. Temukan keberuntungan Anda di antara berbagai pilihan slot gacor yang tersedia dan rasakan kegembiraan bermain judi slot yang tak terlupakan. Situs Slot Terpercaya dengan Pilihan Terlengkap OLXTOTO adalah situs slot terpercaya yang menawarkan pilihan terlengkap dalam perjudian online. Nikmati berbagai genre dan tema slot online yang menarik, dari slot klasik hingga slot video yang inovatif. Dipercaya oleh jutaan pemain, OLXTOTO memberikan pengalaman bermain yang aman dan terjamin.   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.  
    • LOGIN DAN DAFTAR DISINI SEKARANG !!!! Blacktogel adalah situs judi slot online yang menjadi pilihan banyak penggemar judi slot gacor di Indonesia. Dengan platform yang sangat user-friendly dan berbagai macam permainan slot yang tersedia, Blacktogel menjadi tempat yang tepat untuk penggemar judi slot online. Dalam artikel ini, kami akan membahas tentang Blacktogel dan keunggulan situs slot gacor online yang disediakan.  
    • Situs bandar slot online Gacor dengan bonus terbesar saat ini sedang menjadi sorotan para pemain judi online. Dengan persaingan yang semakin ketat dalam industri perjudian online, pemain mencari situs yang tidak hanya menawarkan permainan slot yang gacor (sering memberikan kemenangan), tetapi juga bonus terbesar yang bisa meningkatkan peluang menang. Daftar disini : https://gesit.io/googlegopek
    • Situs bandar slot online Gacor dengan bonus terbesar saat ini sedang menjadi sorotan para pemain judi online. Dengan persaingan yang semakin ketat dalam industri perjudian online, pemain mencari situs yang tidak hanya menawarkan permainan slot yang gacor (sering memberikan kemenangan), tetapi juga bonus terbesar yang bisa meningkatkan peluang menang. Daftar disini : https://gesit.io/googlegopek
    • Situs bandar slot online Gacor dengan bonus terbesar saat ini sedang menjadi sorotan para pemain judi online. Dengan persaingan yang semakin ketat dalam industri perjudian online, pemain mencari situs yang tidak hanya menawarkan permainan slot yang gacor (sering memberikan kemenangan), tetapi juga bonus terbesar yang bisa meningkatkan peluang menang. Daftar disini : https://gesit.io/googlegopek
  • Topics

×
×
  • Create New...

Important Information

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