Posted January 4, 20187 yr 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); } }
January 4, 20187 yr Author Nevermind, managed to do it myself Thread can be closed Edited January 4, 20187 yr by weeeee
April 15, 20187 yr 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 April 15, 20187 yr by Pixtar It's working now ^^
April 5, 20196 yr Can't you just check if it is morning/daytime when the event is fired, and do your stuff if it isn't daytime?
April 5, 20196 yr 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.
April 5, 20196 yr 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 April 5, 20196 yr 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.
April 5, 20196 yr 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.