Jump to content

[1.7.10] Editing Bed Behavior without Base Edits


zombiepig333

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

My god- I forgot to look there.  Welp, another derp for me :P.  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.

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.