Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Entity> getPassengers();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down