Skip to content

Commit

Permalink
Fix ceiling->wall teleportation
Browse files Browse the repository at this point in the history
I think it looks even better than it did before.
  • Loading branch information
Gaming32 committed Jul 11, 2023
1 parent 353b764 commit a482a66
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/com/fusionflux/portalcubed/mixin/PlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private static boolean doFeetTeleport(Portal portal) {
assert portal.getOtherNormal().isPresent();
final double y = portal.getNormal().y;
final double oy = portal.getOtherNormal().get().y;
return (y > 0 && oy < 0) || (y < 0 && oy > 0);
return (y > 0 && oy < 0) || y < 0;
}

@Unique
Expand Down Expand Up @@ -270,6 +270,7 @@ private void performTeleport(
((basePosition.y()) - portal.position().y()) * invert.y,
((basePosition.z()) - portal.position().z()) * invert.z
);
Vec3 teleportOffsetNoRotate = Vec3.ZERO;
if (portal.getNormal().y < 0 && portal.getOtherNormal().get().y <= 0) {
teleportOffset = teleportOffset.add(
0,
Expand All @@ -278,16 +279,16 @@ private void performTeleport(
),
0
);
teleportOffsetNoRotate = teleportOffsetNoRotate.add(0, -thisEntity.getEyeHeight(), 0);
} else if (portal.getNormal().y > 0 && portal.getOtherNormal().get().y > 0) {
teleportOffset = teleportOffset.add(0, thisEntity.getEyeHeight(), 0);
}
byteBuf.writeDouble(teleportOffset.x);
byteBuf.writeDouble(teleportOffset.y);
byteBuf.writeDouble(teleportOffset.z);
Vec3 teleportOffsetNoRotate = Vec3.ZERO;
if (portal.getOtherNormal().get().y < 0 && portal.getNormal().y <= 0) {
teleportOffsetNoRotate = teleportOffsetNoRotate.add(0, -thisEntity.getEyeHeight(), 0);
}
byteBuf.writeDouble(teleportOffset.x);
byteBuf.writeDouble(teleportOffset.y);
byteBuf.writeDouble(teleportOffset.z);
byteBuf.writeDouble(teleportOffsetNoRotate.x);
byteBuf.writeDouble(teleportOffsetNoRotate.y);
byteBuf.writeDouble(teleportOffsetNoRotate.z);
Expand Down

0 comments on commit a482a66

Please sign in to comment.