Skip to content

Commit 813d197

Browse files
onebeastchrisKonicai
authored andcommitted
Feature: API to switch items in the offhand/mainhand (#4819)
1 parent 48311f8 commit 813d197

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

api/src/main/java/org/geysermc/geyser/api/entity/EntityData.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,10 @@ public interface EntityData {
8181
* @return whether the movement is locked
8282
*/
8383
boolean isMovementLocked();
84+
85+
/**
86+
* Sends a request to the Java server to switch the items in the main and offhand.
87+
* There is no guarantee of the server accepting the request.
88+
*/
89+
void switchHands();
8490
}

core/src/main/java/org/geysermc/geyser/entity/GeyserEntityData.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,9 @@ public boolean lockMovement(boolean lock, @NonNull UUID owner) {
9696
public boolean isMovementLocked() {
9797
return !movementLockOwners.isEmpty();
9898
}
99+
100+
@Override
101+
public void switchHands() {
102+
session.requestOffhandSwap();
103+
}
99104
}

0 commit comments

Comments
 (0)