Jump to content

[1.8][SOLVED] question about @SubscribeEvent


Chewiie88

Recommended Posts

Hello.

I been working on a code all day and looking up information about modding in forge.

I run in to a problem and i dont know can i have 2 @SubscribeEvent methods in the same class?

 

what im doing is a way to check if the player breaks a block and the what tool the player use.

After that i want to check what item the player gets so i can set what exp he will get from it.

 

Im working on a Adveture mod and im adding skills for mining, lumbering e.t.c

Do i have to have 2 methods? Feels wrong. I want to do the check what block the player picksup in my onBlockBreak method.

 

I feel lost at the moment any ideas?

if you want to see my code just ask and i add it.

 

No code is needed just a hint of direction so i can find out more about forge and learn more.

 

Link to comment
Share on other sites

Hi, it depends on what your doing, I believe the way it works is - when you register your events you can have multiple client side events in the same class and register them through your client proxy and vice versa with server side events (I may be wrong on registering them in sperate classes based on server / client side, but I do know for a fact you can use multiple events in same class). It would be redundant if you used multiple events that are exaclty the same with different method names, however. Hope that helps, here's a piece of info on events including a almost full, if not full, kist of events:

http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

@grand_mind1

What im planing on doing is this.

When the player digs dirt he gets x amount of xp depending on what tool he has.

 

So what i was thinking first was to do a if statement on what tool the player using when he breaks the block. That part works. then in lets say

if

	
if(hand.getItem() == Items.wooden_shovel){
}

 

I put an if statement on the different blocks and from there i send do the exp calculation of how mutch exp the player gets.

But the problem is i dont know how i should get what type of block the player breaks. So i thought that if i check then use the ItemPickupEvent to check what item the player picked up. But i can be on the complete wrong way on coding this. There might be a easier way of doing this.

 

Hope i explained good on what i was coding and what i have problem with.

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



×
×
  • Create New...

Important Information

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