J’ai un peu de mal avec l’approche nécessaire.
ridingEntity correspond à l’entité que l’on est en train de monter, ici un véhicule. (C.f "The entity we are currently riding ")
riddenByEntity correspond à une entité qui est en train d’en monter une autre, ici le joueur. (C.f "The entity that is riding this entity ")
Du coup moi je me mélange tout. Car ridingEntity semble être le joueur.
Du coup si je veux ajouter un passager sur mon entité, je dois pouvoir enregistrer 2 "ridingEntity " dessus.
Pourquoi devoir modifier toutes les fois où ridingEntity apparaît du coup?
Je préfèrerais détecter si mon entité est actuellement toujours montée par un joueur et si oui pouvoir monter dessus mais à une place différente.
En tout cas, voilà ce que je comprend des méthodes qui me semblent concernées (si j’en oublie ça viendra)
| public void updateRidden() |
| { |
| if (this.ridingEntity.isDead) |
| { |
| this.ridingEntity = null; |
| } |
| else |
| { |
| this.motionX = 0.0D; |
| this.motionY = 0.0D; |
| this.motionZ = 0.0D; |
| this.onUpdate(); |
| |
| if (this.ridingEntity != null) |
| { |
| this.ridingEntity.updateRiderPosition(); |
| this.entityRiderYawDelta += (double)(this.ridingEntity.rotationYaw - this.ridingEntity.prevRotationYaw); |
| |
| |
| for (this.entityRiderPitchDelta += (double)(this.ridingEntity.rotationPitch - this.ridingEntity.prevRotationPitch); this.entityRiderYawDelta >= 180.0D; this.entityRiderYawDelta -= 360.0D) |
| { |
| ; |
| } |
| |
| while (this.entityRiderYawDelta < -180.0D) |
| { |
| this.entityRiderYawDelta += 360.0D; |
| } |
| |
| while (this.entityRiderPitchDelta >= 180.0D) |
| { |
| this.entityRiderPitchDelta -= 360.0D; |
| } |
| |
| while (this.entityRiderPitchDelta < -180.0D) |
| { |
| this.entityRiderPitchDelta += 360.0D; |
| } |
| |
| double d0 = this.entityRiderYawDelta * 0.5D; |
| double d1 = this.entityRiderPitchDelta * 0.5D; |
| float f = 10.0F; |
| |
| if (d0 > (double)f) |
| { |
| d0 = (double)f; |
| } |
| |
| if (d0 < (double)(-f)) |
| { |
| d0 = (double)(-f); |
| } |
| |
| if (d1 > (double)f) |
| { |
| d1 = (double)f; |
| } |
| |
| if (d1 < (double)(-f)) |
| { |
| d1 = (double)(-f); |
| } |
| |
| this.entityRiderYawDelta -= d0; |
| this.entityRiderPitchDelta -= d1; |
| } |
| } |
| } |
| |
| public void updateRiderPosition() |
| { |
| if (this.riddenByEntity != null) |
| { |
| this.riddenByEntity.setPosition(this.posX, this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset(), this.posZ); |
| } |
| } |
| |
| public void mountEntity(Entity ent) |
| { |
| this.entityRiderPitchDelta = 0.0D; |
| this.entityRiderYawDelta = 0.0D; |
| |
| if (ent == 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; |
| } |
| |
| if (ent != null) |
| { |
| for (Entity entity1 = ent.ridingEntity; entity1 != null; entity1 = entity1.ridingEntity) |
| { |
| if (entity1 == this) |
| { |
| return; |
| } |
| } |
| } |
| |
| this.ridingEntity = ent; |
| ent.riddenByEntity = this; |
| } |
| } |
Bref, je n’ai pas tout compris et je pense me tromper surtout sur pas mal de choses.