Jump to content

[1.8] [Solved] Entity can mount w/o sitting?


Eetmorchikn

Recommended Posts

This is more of a question of possibility than a question about the code, but I seem to have reached an impasse in creating an entity that we will call EntityBetterBoat.

 

I have the class EntityBetterBoat extend Entity, and I slapped the code from the EntityBoat class in there for easy modification to physics elements and such.

 

And now for the question: Can an EntityPlayer mount and ride a boat, with all of the same characteristics of movement, except EntityPlayer is standing....??

 

@Override

public boolean shouldRiderSit() { return false;}

 

Overriding the shouldRiderSit() method makes the Entity riding it stand, but the movement is not registered.. Tying to move the boat while riding and standing makes the EntityPlayer try to walk, instead of doing what it normally does, moving the boat..

Thus, the entities shake while trying to move and even the Yaw and Pitch of the camera are stuck, only updating on large movements of the mouse.

 

I'm guessing that what's going is:

The EntityPlayer class is updating its position based on the position of the boat.

The boat is waiting for action from the Player

Pressing WASD keys is still trying to move the player and not checking for a ridden Entity..

 

"I'm guessing"

 

SO.... Does fixing this problem involve modifying base classes? How should I approach this...?

 

Should you need code for reference I will supply it.

I may have over-thunk it...

Link to comment
Share on other sites

I have the same issue with my parachute mod. Unfortunately isRiding and shouldRiderSit are coupled to the motion packet code. Movement doesn't get updated if shouldRiderSit returns false. I thought the idea was to render a sitting player only but that's not how it works, as of 1.6.x. Post back if you find a solution.

Link to comment
Share on other sites

I have the same issue with my parachute mod. Unfortunately isRiding and shouldRiderSit are coupled to the motion packet code. Movement doesn't get updated if shouldRiderSit returns false. I thought the idea was to render a sitting player only but that's not how it works, as of 1.6.x. Post back if you find a solution.

 

I FOUND A SOLUTION!!

Turns out theres this nifty thing called the Render Player API (RPAPI) that gives you access to the Render Player, and Model Player classes!

You can download the API here:

http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1283669-1-8-api-render-player-api

 

I'm using the 1.8 "core" version and it seems to be working fine with forge. To make the player render standing while mounted, I simply copied and overrode the  setRotationAngles method, commenting out the part where the rotations are added to the player's legs.

 

public class SMModelPlayerBase extends ModelPlayerBase {

public SMModelPlayerBase(ModelPlayerAPI arg0) {
	super(arg0);
}

@Override
public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_)
{
	if(modelPlayer != null){

		this.modelPlayer.bipedHead.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI);
		this.modelPlayer.bipedHead.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI);
		this.modelPlayer.bipedRightArm.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 2.0F * p_78087_2_ * 0.5F;
		this.modelPlayer.bipedLeftArm.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 2.0F * p_78087_2_ * 0.5F;
		this.modelPlayer.bipedRightArm.rotateAngleZ = 0.0F;
		this.modelPlayer.bipedLeftArm.rotateAngleZ = 0.0F;
		this.modelPlayer.bipedRightLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.4F * p_78087_2_;
		this.modelPlayer.bipedLeftLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 1.4F * p_78087_2_;
		this.modelPlayer.bipedRightLeg.rotateAngleY = 0.0F;
		this.modelPlayer.bipedLeftLeg.rotateAngleY = 0.0F;

		/* > HEHEHEHEH!
                        if (this.modelPlayer.isRiding)
                        {
                            this.modelPlayer.bipedRightArm.rotateAngleX += -((float)Math.PI / 5F);
                            this.modelPlayer.bipedLeftArm.rotateAngleX += -((float)Math.PI / 5F);
                            this.modelPlayer.bipedRightLeg.rotateAngleX = -((float)Math.PI * 2F / 5F);
                            this.modelPlayer.bipedLeftLeg.rotateAngleX = -((float)Math.PI * 2F / 5F);
                            this.modelPlayer.bipedRightLeg.rotateAngleY = ((float)Math.PI / 10F);
                            this.modelPlayer.bipedLeftLeg.rotateAngleY = -((float)Math.PI / 10F);
                        }
		 */

		..... *rest of the original code* 
}
}

 

Theres also a nasty Nullpointer that gets thrown by gradle when someone else views your player or you view yourself in third person, so make sure you also add that != null check surrounding the original code, like I did.

 

Thanks for the reply! good luck.

I may have over-thunk it...

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.