Skip to content

Commit

Permalink
Add ShiftClick
Browse files Browse the repository at this point in the history
  • Loading branch information
Bun133 committed Mar 30, 2022
1 parent f86847f commit 6a7185e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
2. スニークしながらオフハンドのアイテムを持ち替えます
3. そうするとアイテム一覧が出るのでクリックしてインベントリに加えます

## GUI説明

右側にある弓矢のボタンでページを上下できます。

アイテムをクリックすると1つ、シフトクリックすると1スタックインベントリに加えます。

# コマンド説明

## みんなが使えるコマンド
Expand Down
4 changes: 2 additions & 2 deletions main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.numalab</groupId>
<artifactId>pretend_survival</artifactId>
<version>1.0</version>
<version>1.1</version>
<packaging>jar</packaging>

<name>PretendSurvival</name>
Expand Down Expand Up @@ -173,7 +173,7 @@
<dependency>
<groupId>com.github.Bun133</groupId>
<artifactId>GUIFly</artifactId>
<version>0.1.2</version>
<version>0.1.3</version>
</dependency>
</dependencies>
</project>
8 changes: 8 additions & 0 deletions main/src/main/java/net/numalab/pretend_survival/PSGUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class PSGUI(val psConfig: PSConfig) {
builder.item(x, y) {
stack(itemStack)
click { onClick(it, itemStack) }
shiftClick { onShiftClick(it, itemStack) }
markAsUnMovable()
}
}
Expand All @@ -48,4 +49,11 @@ class PSGUI(val psConfig: PSConfig) {
private fun onClick(e: InventoryClickEvent, itemStack: ItemStack) {
e.whoClicked.inventory.addItem(itemStack)
}

private fun onShiftClick(e: InventoryClickEvent, itemStack: ItemStack) {
val amount = itemStack.type.maxStackSize - 1
if (amount > 0) {
e.whoClicked.inventory.addItem(itemStack.clone().also { it.amount = amount })
}
}
}

0 comments on commit 6a7185e

Please sign in to comment.