Posted August 23, 201411 yr Hi! I have question: How make the entity mountable to drive with passenger? Thanks, for help Sokaya
August 23, 201411 yr The best tutorial is located in the horse/pig/minecart classes. Furthermore you can even call from your entity this.ismountable(); so have a look through those classes, see what methods they call to place the player in what position (particular the right click since that's how a player interacts to mount) and you should be golden.
August 23, 201411 yr Author Not what I meant. I want on 1 mountable can sit 2 passenger and they have small interval between them.
August 23, 201411 yr That is an entirely different question. In any case this should help you: the EntityHorse class has this neat method which should help you update the rider position. public void updateRiderPosition() { super.updateRiderPosition(); if (this.prevRearingAmount > 0.0F) { float f = MathHelper.sin(this.renderYawOffset * (float)Math.PI / 180.0F); float f1 = MathHelper.cos(this.renderYawOffset * (float)Math.PI / 180.0F); float f2 = 0.7F * this.prevRearingAmount; float f3 = 0.15F * this.prevRearingAmount; this.riddenByEntity.setPosition(this.posX + (double)(f2 * f), this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset() + (double)f3, this.posZ - (double)(f2 * f1)); if (this.riddenByEntity instanceof EntityLivingBase) { ((EntityLivingBase)this.riddenByEntity).renderYawOffset = this.renderYawOffset; } } } And the entity class(meant for the player) has these: /** * Returns the Y offset from the entity's position for any entity riding this one. */ public double getMountedYOffset() { return (double)this.height * 0.75D; } /** * Called when a player mounts an entity. e.g. mounts a pig, mounts a boat. */ public void mountEntity(Entity par1Entity) { this.entityRiderPitchDelta = 0.0D; this.entityRiderYawDelta = 0.0D; if (par1Entity == null) { if (this.ridingEntity != null) { this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.boundingBox.minY + (double)this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch); this.ridingEntity.riddenByEntity = null; } this.ridingEntity = null; } else { if (this.ridingEntity != null) { this.ridingEntity.riddenByEntity = null; } this.ridingEntity = par1Entity; par1Entity.riddenByEntity = this; } } So basically just check if there is already someone on the horse and adjust the player position on that basis. Also, don't forget you will need to override the original /** The entity that is riding this entity */ public Entity riddenByEntity; in the horse class to an array or list to allow more than one entity to ride the same horse. Also don't forget to adjust any checks that happen if there is already someone riding the horse to allow two players instead of just one. I hope this helps.
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.