Jump to content

Recommended Posts

Posted

I am not asking how you make the player able sleep on your own bed/block, but rather how to make him sleep anywhere. Setting the spawnpoint isn't necessary, just making the player "fall over", have his screen fade to black etc. I think it'd be super unnecssary to create my own method to make the player do this, but I cannot find any other sleep related method besides trySleep in EntityPlayer, but it only allows him to sleep if the block at the specified position is an actual bed. Any ideas?

Posted
6 minutes ago, That_Martin_Guy said:

but it only allows him to sleep if the block at the specified position is an actual bed. Any ideas?

You would need to find a way to remove that check.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Generally...you don't

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You have two three options:

1) Find a way to replace the object that the code is in with your own version of that class. Doing this ranges from medium difficult to almost impossible, depending on the object in question.

2) Core mods, which are heavily discouraged. Do not do this, do not ask for help doing this. If you do not know how to do this no one will tell you.

3) Make a pull request to Forge to insert some kind of event or other modification that will allow a mod to hook into the behavior and override the vanilla mechanic. Then wait six to eight weeks for your PR to get approved.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Core mods don't seem like an option, and I don't think I'd find a way to create a hook for this certain scenario that would benefit anyone other than me and would therefore not be accepted.

17 minutes ago, Draco18s said:

1) Find a way to replace the object that the code is in with your own version of that class. Doing this ranges from medium difficult to almost impossible, depending on the object in question.

That leaves this option. But the method I'm looking for is in EntityPlayer, and I doubt I could override that in a good way without breaking things. So is there any solution here?

Posted
39 minutes ago, ptolemy2002 said:

There is a small chance that you would be able to copy the method to your own class and change it to edit the player externally.

 

I'd do this if I could, but a lot of the things that are done in the method are changing private/protected variables which I do not have access to. I suppose I could in a worst case scenario I could change them with reflection.

Posted
54 minutes ago, ptolemy2002 said:

There is a small chance that you would be able to copy the method to your own class and change it to edit the player externally.

Unfortunately, not for this. If you try to set the player sleeping, they'll unsleep the next time the update code runs, popping them out of the sleeping state in a way that you (as a modder) can't cancel.

 

1 hour ago, That_Martin_Guy said:

That leaves this option. But the method I'm looking for is in EntityPlayer, and I doubt I could override that in a good way without breaking things. So is there any solution here?

You can replace EntityPlayer with a new subclass, but you are correct that it could break things (e.g. conflict with other mods that also replace EntityPlayer, like Galacticraft). There is no way around this, beyond the previously mentioned alternatives.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Possibly you can bookend the player tick event, in the Pre stage record the stuff that is necessary, then undo anything the standard tick does. Also there are probably a couple events related to beds and sleeping that might need handling.

 

Basically Draco18s is saying you need to root through the the code and figure out clever ways to intercept each behavior. Sometimes it is surprisingly easy, sometimes almost impossible. Also depends on your java confidence.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.