Skip to content

Commit 7a4a90c

Browse files
committed
Update getRelativeOffset to handle YAW directly and use smart math.
Version bump Beta-1.0.2
1 parent 018cc1f commit 7a4a90c

File tree

8 files changed

+13
-19
lines changed

8 files changed

+13
-19
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.

build/tmp/jar/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Manifest-Version: 1.0
22
Implementation-Title: InteractiveMenuAPI
3-
Implementation-Version: beta-1.0.0
3+
Implementation-Version: beta-1.0.1
44

src/main/java/dev/arctic/interactivemenuapi/objects/Element.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,17 @@ public void cleanup() {
7272
}
7373
}
7474

75-
protected Vector getAdjustedOffset(Location anchorLocation, Vector offset, float yaw) {
76-
yaw = (yaw % 360 + 360) % 360;
77-
78-
double x = offset.getX();
79-
double y = offset.getY();
80-
double z = offset.getZ();
81-
82-
if (yaw >= 315 || yaw < 45) {
83-
return new Vector(x, y, z);
84-
} else if (yaw >= 45 && yaw < 135) {
85-
return new Vector(-z, y, x);
86-
} else if (yaw >= 135 && yaw < 225) {
87-
return new Vector(-x, y, -z);
88-
} else {
89-
return new Vector(z, y, -x);
90-
}
75+
protected Vector getAdjustedOffset(Vector offset, float yaw) {
76+
// No yaw normalization; handle yaw directly as needed.
77+
double radians = Math.toRadians(yaw);
78+
79+
double cos = Math.cos(radians);
80+
double sin = Math.sin(radians);
81+
82+
double x = offset.getX() * cos - offset.getZ() * sin;
83+
double z = offset.getX() * sin + offset.getZ() * cos;
84+
85+
return new Vector(x, offset.getY(), z);
9186
}
9287

9388
public void setExternalFunction(BiConsumer<Player, Object> onInteract) {

src/main/java/dev/arctic/interactivemenuapi/objects/Menu.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ public void run() {
8989

9090
public void clearMenu() {
9191
for (Division division : divisions) {
92-
plugin.getLogger().warning("Cleaning up division!");
9392
division.cleanup();
9493
}
9594
divisions.clear();

src/main/java/dev/arctic/interactivemenuapi/objects/elements/DisplayElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void setCurrentLocation(Location currentLocation) {
132132

133133
@Override
134134
public void updateLocation(Location startLocation) {
135-
Location newLocation = startLocation.clone().add(getAdjustedOffset(startLocation, offset, startLocation.getYaw()));
135+
Location newLocation = startLocation.clone().add(getAdjustedOffset(offset, startLocation.getYaw()));
136136

137137
interactionEntity.teleport(newLocation);
138138
displayEntity.teleport(newLocation.add(0,0.5,0));

0 commit comments

Comments
 (0)