Skip to content

Commit

Permalink
Fix stock placing upsidedown
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Dec 12, 2023
1 parent d386063 commit 4e438de
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import cam72cam.immersiverailroading.registry.EntityRollingStockDefinition;
import cam72cam.mod.entity.Player;
import cam72cam.immersiverailroading.thirdparty.trackapi.ITrack;
import cam72cam.mod.util.DegreeFuncs;
import cam72cam.mod.world.World;
import cam72cam.mod.item.ClickResult;
import cam72cam.mod.item.ItemStack;
Expand Down Expand Up @@ -63,9 +64,11 @@ public static ClickResult placeStock(Player player, Player.Hand hand, World worl
Vec3d rear = centerte.getNextPosition(center, VecUtil.fromWrongYaw(rearDistance, yaw));

moveable.setRotationYaw(VecUtil.toWrongYaw(front.subtract(rear)));
float pitch = (-VecUtil.toPitch(front.subtract(rear)) - 90) % 180;
float pitch = (-VecUtil.toPitch(front.subtract(rear)) - 90);
if (DegreeFuncs.delta(pitch, 0) > 90) {
pitch = 180 - pitch;
}
moveable.setRotationPitch(pitch);
System.out.println(pitch);

moveable.setPosition(rear.add(front.subtract(rear).scale(frontDistance / (frontDistance - rearDistance))));

Expand Down

0 comments on commit 4e438de

Please sign in to comment.