Posted July 8, 201411 yr NOTE: Before yelling at me for posting such a mention, please keep in mind that I am trying to do this without a full class patch; I found a tutorial for that, but didn't want to create incompatibilities. I am trying to add a sound for when a player sleeps in a bed. Sadly enough, when I was looking at what that would take, it appears an edit to the onBlockActivated function in BlockBed would need to be made, and I don't have very many ideas as to going about and making this change. I do know that you can edit fields with reflection or asms, but this is adding an entire line to a base class, not simply changing a field. Any help would be greatly appreciated. Okay, when using the solution given below, everything works the way it should EXCEPT for the conditional regarding EnumStatus; through tests I have concluded the event always seems to return null for its status. Thoughts? ~zombiepig333
July 8, 201411 yr @SubscribeEvent public void onSleep(PlayerSleepInBedEvent event) { if(event.result == EntityPlayer.EnumStatus.OK) event.entityPlayer.worldObj.playSoundEffect(event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ, "random.successful_hit", 1.0F, 0.1F); }
July 8, 201411 yr Author My god- I forgot to look there. Welp, another derp for me . Haven't really done this kind of stuff before, so thanks for the help- now that I know where all these events are things should be muuuuuuuch easier. Honestly, thanks a ton. I should have looked through more of the documentation before posting this. ~zombiepig333 Edit: Ran into another problem, and I don't think it is of my doing this time. Updated the first post with info.
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.