Skip to content

Commit

Permalink
Also check out-of-bounds on player inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Mar 8, 2021
1 parent ffae694 commit d80372e
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;

public class PlayerInventory extends Inventory {
Expand Down Expand Up @@ -55,10 +56,18 @@ public void setCursor(@NonNull GeyserItemStack newCursor, GeyserSession session)
}

public GeyserItemStack getItemInHand() {
if (36 + heldItemSlot > this.size) {
GeyserConnector.getInstance().getLogger().debug("Held item slot was larger than expected!");
return GeyserItemStack.EMPTY;
}
return items[36 + heldItemSlot];
}

public void setItemInHand(@NonNull GeyserItemStack item) {
if (36 + heldItemSlot > this.size) {
GeyserConnector.getInstance().getLogger().debug("Held item slot was larger than expected!");
return;
}
items[36 + heldItemSlot] = item;
}

Expand Down

0 comments on commit d80372e

Please sign in to comment.