Skip to content

Commit

Permalink
Fix seat and interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
iam4722202468 committed Aug 18, 2022
1 parent 7f21504 commit ebffcd3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public void dismountEntity(Entity e) {
}

public Set<Entity> getPassengers() {
if (this.seat == null) return Set.of();
return this.seat.getEntity().getPassengers();
}

Expand Down
43 changes: 18 additions & 25 deletions src/main/java/net/worldseed/multipart/ModelBonePart.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

non-sealed class ModelBonePart extends ModelBoneGeneric {
private final ModelEngine.RenderType renderType;
private Pos lastPos = Pos.ZERO;

public ModelBonePart(Point pivot, String name, Point rotation, GenericModel model, ModelEngine.RenderType renderType, LivingEntity forwardTo) {
super(pivot, name, rotation, model);
Expand Down Expand Up @@ -97,9 +96,9 @@ public void setBoneRotation(Point rotation) {
ArmorStandMeta meta = (ArmorStandMeta) this.stand.getEntityMeta();

meta.setHeadRotation(new Vec(
rotation.x(),
0,
-rotation.z()
rotation.x(),
0,
-rotation.z()
));
}

Expand All @@ -122,29 +121,23 @@ public void draw(short tick) {
Point rotation = q.toEulerYZX();

if (renderType == ModelEngine.RenderType.ARMOUR_STAND) {
Pos newPos =
endPos
.div(6.4, 6.4, 6.4)
.add(model.getPosition())
.sub(0, 1.4, 0)
.add(model.getGlobalOffset());

Pos diff = newPos.sub(lastPos).mul(0.5);
this.lastPos = newPos;
stand.teleport(newPos.add(diff).withYaw((float) -rotation.y()));
Pos newPos = endPos
.div(6.4, 6.4, 6.4)
.add(model.getPosition())
.sub(0, 1.4, 0)
.add(model.getGlobalOffset());

stand.teleport(newPos.withYaw((float) -rotation.y()));
setBoneRotation(rotation);
} else if (renderType == ModelEngine.RenderType.SMALL_ARMOUR_STAND) {
Pos newPos =
endPos
.div(6.4, 6.4, 6.4)
.div(1.6)
.add(model.getPosition())
.sub(0, 0.4, 0)
.add(model.getGlobalOffset());

Pos diff = newPos.sub(lastPos).mul(0.5);
this.lastPos = newPos;
stand.teleport(newPos.add(diff).withYaw((float) -rotation.y()));
Pos newPos = endPos
.div(6.4, 6.4, 6.4)
.div(1.6)
.add(model.getPosition())
.sub(0, 0.4, 0)
.add(model.getGlobalOffset());

stand.teleport(newPos.withYaw((float) -rotation.y()));
setBoneRotation(rotation);
} else if (renderType == ModelEngine.RenderType.ZOMBIE) {
// TODO: I think this sends two packets?
Expand Down

0 comments on commit ebffcd3

Please sign in to comment.