Jump to content

Event when player wakes up


weeeee

Recommended Posts

I want the player to get healed when he wakes up in the morning.

But the PlayerWakeUpEvent also gets triggered when you press the wake up button in bed and don't actually sleep 'till the next day. :L

Does anyone have an idea how I could do that, that the player only gets healed when he stays in the bed? :)

 

@SubscribeEvent
public void PlayerWakeUpEvent(PlayerWakeUpEvent event)
{
    event.entityPlayer.heal(20);
}
}

Link to comment
Share on other sites

  • 3 months later...

Hi @weeeee

 

currently I'm using 1.12.1 and it seems that the event will not be called. How did you manage it?

 

@SubscribeEvent
public void onPlayerWakeUpEvent( PlayerWakeUpEvent event )
{
    MyMod.getLogger().warn( "onPlayerWakeUpEvent" ); //do warn message 'onPlayerWakeUpEvent' in the console
}

 

Currently I'm thinking that this event gets only fired on the client side, or am I wrong?

 

Kind regards,

Pixtar

 

UPDATE / EDIT: weeeee did the same mistake like me. I looked at the Type Hierarchy and saw the little 'S'. The methods needs to be declared as static. Now it's working - on both sides. ^^
(Navigate with Eclipse to the base Event class and right click the class -> Open Type Hierarchy)

 

public static void onPlayerWakeUpEvent( PlayerWakeUpEvent event )

Edited by Pixtar
It's working now ^^
Link to comment
Share on other sites

  • 11 months later...
On 4/15/2018 at 1:06 PM, Pixtar said:

The methods needs to be declared as static.

No. This depends on how you register the event bus subscriber.

Nothing needs to be static.

 

Refer to this post:

 

@fallOut015 As a suggestion, next time please create your own thread; this thread is almost a year old.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

2 hours ago, DavidM said:

No. This depends on how you register the event bus subscriber.

Nothing needs to be static.

 

Refer to this post:

 

@fallOut015 As a suggestion, next time please create your own thread; this thread is almost a year old.

I did. But this person seemed to have an answer to my question

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.