summaryrefslogtreecommitdiffhomepage
path: root/patches/api/0192-Add-item-slot-convenience-methods.patch
blob: abad4883edad08a465aae3a81e280c5cb430f1d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <nassim@njahnke.dev>
Date: Sat, 25 Apr 2020 23:31:28 +0200
Subject: [PATCH] Add item slot convenience methods


diff --git a/src/main/java/org/bukkit/inventory/AnvilInventory.java b/src/main/java/org/bukkit/inventory/AnvilInventory.java
index 52519cd877017704b53d36088d4d4c28f8f27397..c60be4fd24c7fdf65251dd6169e5e1ac3b588d95 100644
--- a/src/main/java/org/bukkit/inventory/AnvilInventory.java
+++ b/src/main/java/org/bukkit/inventory/AnvilInventory.java
@@ -63,4 +63,64 @@ public interface AnvilInventory extends Inventory {
      * @param levels the maximum experience cost
      */
     void setMaximumRepairCost(int levels);
+
+    // Paper start
+    /**
+     * Gets the item in the left input slot.
+     *
+     * @return item in the first slot
+     */
+    @Nullable
+    default ItemStack getFirstItem() {
+        return getItem(0);
+    }
+
+    /**
+     * Sets the item in the left input slot.
+     *
+     * @param firstItem item to set
+     */
+    default void setFirstItem(@Nullable ItemStack firstItem) {
+        setItem(0, firstItem);
+    }
+
+    /**
+     * Gets the item in the right input slot.
+     *
+     * @return item in the second slot
+     */
+    @Nullable
+    default ItemStack getSecondItem() {
+        return getItem(1);
+    }
+
+    /**
+     * Sets the item in the right input slot.
+     *
+     * @param secondItem item to set
+     */
+    default void setSecondItem(@Nullable ItemStack secondItem) {
+        setItem(1, secondItem);
+    }
+
+    /**
+     * Gets the item in the result slot.
+     *
+     * @return item in the result slot
+     */
+    @Nullable
+    default ItemStack getResult() {
+        return getItem(2);
+    }
+
+    /**
+     * Sets the item in the result slot.
+     * Note that the client might not be able to take out the item if it does not match the input items.
+     *
+     * @param result item to set
+     */
+    default void setResult(@Nullable ItemStack result) {
+        setItem(2, result);
+    }
+    // Paper end
 }
diff --git a/src/main/java/org/bukkit/inventory/GrindstoneInventory.java b/src/main/java/org/bukkit/inventory/GrindstoneInventory.java
index 9048892c8768c6b4d6cea03da73339f13bfbe82e..1c750108f55a0a31ad23433b333e0ea486a63ff2 100644
--- a/src/main/java/org/bukkit/inventory/GrindstoneInventory.java
+++ b/src/main/java/org/bukkit/inventory/GrindstoneInventory.java
@@ -1,6 +1,68 @@
 package org.bukkit.inventory;
 
+import org.jetbrains.annotations.Nullable; // Paper
+
 /**
  * Interface to the inventory of a Grindstone.
  */
-public interface GrindstoneInventory extends Inventory { }
+public interface GrindstoneInventory extends Inventory {
+
+    // Paper start
+    /**
+     * Gets the upper input item.
+     *
+     * @return upper input item
+     */
+    @Nullable
+    default ItemStack getUpperItem() {
+        return getItem(0);
+    }
+
+    /**
+     * Sets the upper input item.
+     *
+     * @param upperItem item to set
+     */
+    default void setUpperItem(@Nullable ItemStack upperItem) {
+        setItem(0, upperItem);
+    }
+
+    /**
+     * Gets the lower input item.
+     *
+     * @return lower input item
+     */
+    @Nullable
+    default ItemStack getLowerItem() {
+        return getItem(1);
+    }
+
+    /**
+     * Sets the lower input item.
+     *
+     * @param lowerItem item to set
+     */
+    default void setLowerItem(@Nullable ItemStack lowerItem) {
+        setItem(1, lowerItem);
+    }
+
+    /**
+     * Gets the result.
+     *
+     * @return result
+     */
+    @Nullable
+    default ItemStack getResult() {
+        return getItem(2);
+    }
+
+    /**
+     * Sets the result.
+     *
+     * @param result item to set
+     */
+    default void setResult(@Nullable ItemStack result) {
+        setItem(2, result);
+    }
+    // Paper end
+}
diff --git a/src/main/java/org/bukkit/inventory/LecternInventory.java b/src/main/java/org/bukkit/inventory/LecternInventory.java
index 4a0c43acc2714e095973eb78536041bb1a179ddc..acf2244f77133df53eb5f862c8e713c85192f13d 100644
--- a/src/main/java/org/bukkit/inventory/LecternInventory.java
+++ b/src/main/java/org/bukkit/inventory/LecternInventory.java
@@ -11,4 +11,25 @@ public interface LecternInventory extends Inventory {
     @Nullable
     @Override
     public Lectern getHolder();
+
+    // Paper start
+    /**
+     * Gets the lectern's held book.
+     *
+     * @return book set in the lectern
+     */
+    @Nullable
+    default ItemStack getBook() {
+        return getItem(0);
+    }
+
+    /**
+     * Sets the lectern's held book.
+     *
+     * @param book the new book
+     */
+    default void setBook(@Nullable ItemStack book) {
+        setItem(0, book);
+    }
+    // Paper end
 }
diff --git a/src/main/java/org/bukkit/inventory/SmithingInventory.java b/src/main/java/org/bukkit/inventory/SmithingInventory.java
index 96d526b7b153e56c9a97de42ce3270b6638510e4..a41ca6bd2672db2810dd70c4925b84a4f081af05 100644
--- a/src/main/java/org/bukkit/inventory/SmithingInventory.java
+++ b/src/main/java/org/bukkit/inventory/SmithingInventory.java
@@ -30,4 +30,44 @@ public interface SmithingInventory extends Inventory {
      */
     @Nullable
     Recipe getRecipe();
+
+    // Paper start
+    /**
+     * Gets the input equipment (first slot).
+     *
+     * @return input equipment item
+     */
+    @Nullable
+    default ItemStack getInputEquipment() {
+        return getItem(0);
+    }
+
+    /**
+     * Sets the input equipment (first slot).
+     *
+     * @param itemStack item to set
+     */
+    default void setInputEquipment(@Nullable ItemStack itemStack) {
+        setItem(0, itemStack);
+    }
+
+    /**
+     * Gets the input mineral (second slot).
+     *
+     * @return input mineral item
+     */
+    @Nullable
+    default ItemStack getInputMineral() {
+        return getItem(1);
+    }
+
+    /**
+     * Sets the input mineral (second slot).
+     *
+     * @param itemStack item to set
+     */
+    default void setInputMineral(@Nullable ItemStack itemStack) {
+        setItem(1, itemStack);
+    }
+    // Paper end
 }
diff --git a/src/main/java/org/bukkit/inventory/StonecutterInventory.java b/src/main/java/org/bukkit/inventory/StonecutterInventory.java
index dbb034fae3b8bfaf40e6341460e274c21e321a3b..e7a8e7188bf8b9840de56dc80c2b79d64a9389cb 100644
--- a/src/main/java/org/bukkit/inventory/StonecutterInventory.java
+++ b/src/main/java/org/bukkit/inventory/StonecutterInventory.java
@@ -1,6 +1,49 @@
 package org.bukkit.inventory;
 
+import org.jetbrains.annotations.Nullable; // Paper
+
 /**
  * Interface to the inventory of a Stonecutter.
  */
-public interface StonecutterInventory extends Inventory { }
+public interface StonecutterInventory extends Inventory {
+
+    // Paper start
+    /**
+     * Gets the input item.
+     *
+     * @return input item
+     */
+    @Nullable
+    default ItemStack getInputItem() {
+        return getItem(0);
+    }
+
+    /**
+     * Sets the input item.
+     *
+     * @param itemStack item to set
+     */
+    default void setInputItem(@Nullable ItemStack itemStack) {
+        setItem(0, itemStack);
+    }
+
+    /**
+     * Gets the result item.
+     *
+     * @return result
+     */
+    @Nullable
+    default ItemStack getResult() {
+        return getItem(1);
+    }
+
+    /**
+     * Sets the result item.
+     *
+     * @param itemStack item to set
+     */
+    default void setResult(@Nullable ItemStack itemStack) {
+        setItem(1, itemStack);
+    }
+    // Paper end
+}