diff --git a/src/main/java/net/worldseed/multipart/model_bones/bone_types/RideableBone.java b/src/main/java/net/worldseed/multipart/model_bones/bone_types/RideableBone.java index b7bdd123..6cc8f96a 100644 --- a/src/main/java/net/worldseed/multipart/model_bones/bone_types/RideableBone.java +++ b/src/main/java/net/worldseed/multipart/model_bones/bone_types/RideableBone.java @@ -6,7 +6,29 @@ import java.util.List; public interface RideableBone extends ModelBone { + /** + * Allows to set the seat rotation independent of the model rotation. + * @param followModelRotation if the seat should rotate with the model + */ + void setFollowModelRotation(boolean followModelRotation); + + /** + * @return if the seat is rotating independently of the model. + */ + boolean isFollowModelRotation(); + + /** + * Delegator of {@link Entity#addPassenger(Entity)} + */ void addPassenger(Entity entity); + + /** + * Delegator of {@link Entity#addPassenger(Entity)} + */ void removePassenger(Entity entity); + + /** + * Delegator of {@link Entity#addPassenger(Entity)} + */ List getPassengers(); } diff --git a/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneSeat.java b/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneSeat.java index c683c7af..c8f3ac1d 100644 --- a/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneSeat.java +++ b/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneSeat.java @@ -22,6 +22,8 @@ public class ModelBoneSeat extends ModelBoneImpl implements RideableBone { + private boolean followModelRotation = true; + public ModelBoneSeat(Point pivot, String name, Point rotation, GenericModel model, float scale) { super(pivot, name, rotation, model, scale); @@ -137,11 +139,25 @@ public void draw() { this.children.forEach(ModelBone::draw); if (this.offset == null) return; - Pos found = calculatePosition(); + Pos target = calculatePosition(); + if(!followModelRotation) { + Pos standPos = stand.getPosition(); + target = new Pos( + target.x(), target.y(), target.z(), + standPos.yaw(), standPos.pitch() + ); + } + stand.teleport(target); + } + + @Override + public void setFollowModelRotation(boolean followModelRotation) { + this.followModelRotation = followModelRotation; + } - // TODO: needed by minestom? - stand.setView(found.yaw(), found.pitch()); - stand.teleport(found); + @Override + public boolean isFollowModelRotation() { + return followModelRotation; } @Override