Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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);
}
}

  • Author

Nevermind, managed to do it myself :D

Thread can be closed :P

Edited by weeeee

  • 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 ^^

  • 11 months later...
41 minutes ago, thedarkcolour said:

Can't you just check if it is morning/daytime when the event is fired, and do your stuff if it isn't daytime?

@thedarkcolourthe PlayerWakeUpEvent::player entity... getTime always yields the time right before you wake up. So it returns high numbers like 13000 for night. 

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.

 

 

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.