2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2022-08-01 16:01:20 +02:00
|
|
|
From: Nassim Jahnke <nassim@njahnke.dev>
|
2021-06-11 14:02:28 +02:00
|
|
|
Date: Sat, 25 Apr 2020 23:31:28 +0200
|
|
|
|
Subject: [PATCH] Add item slot convenience methods
|
|
|
|
|
2024-04-20 20:10:35 +02:00
|
|
|
Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/AnvilInventory.java b/src/main/java/org/bukkit/inventory/AnvilInventory.java
|
2024-08-09 22:05:50 +02:00
|
|
|
index 4f484df010dabf03ac4712996a0fd4d8f3649b59..f1f97a85ec713c05c882d7588f4a3e4a017f4795 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/inventory/AnvilInventory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/inventory/AnvilInventory.java
|
2024-08-09 22:05:50 +02:00
|
|
|
@@ -78,4 +78,64 @@ public interface AnvilInventory extends Inventory {
|
2021-06-11 14:02:28 +02:00
|
|
|
*/
|
2024-08-09 22:05:50 +02:00
|
|
|
@Deprecated(forRemoval = true, since = "1.21")
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
|
|
|
}
|
2024-04-20 20:10:35 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/inventory/CartographyInventory.java b/src/main/java/org/bukkit/inventory/CartographyInventory.java
|
|
|
|
index 29c9b2682b92433f468d434d25d3c2495b5ac91b..d040ecea3a086711acbf5a852def090ba6c51fae 100644
|
|
|
|
--- a/src/main/java/org/bukkit/inventory/CartographyInventory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/inventory/CartographyInventory.java
|
|
|
|
@@ -3,4 +3,25 @@ package org.bukkit.inventory;
|
|
|
|
/**
|
|
|
|
* Interface to the inventory of a Cartography table.
|
|
|
|
*/
|
|
|
|
-public interface CartographyInventory extends Inventory { }
|
|
|
|
+public interface CartographyInventory extends Inventory {
|
|
|
|
+ // Paper begin - add getResult/setResult to CartographyInventory
|
|
|
|
+ /**
|
|
|
|
+ * Check what item is in the result slot of this smithing table.
|
|
|
|
+ *
|
|
|
|
+ * @return the result item
|
|
|
|
+ */
|
|
|
|
+ @org.jetbrains.annotations.Nullable
|
|
|
|
+ default ItemStack getResult() {
|
|
|
|
+ return this.getItem(2); // net.minecraft.world.inventory.CartographyTableMenu.RESULT_SLOT
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Set the item in the result slot of the smithing table
|
|
|
|
+ *
|
|
|
|
+ * @param newResult the new result item
|
|
|
|
+ */
|
|
|
|
+ default void setResult(final @org.jetbrains.annotations.Nullable ItemStack newResult) {
|
|
|
|
+ this.setItem(2, newResult); // net.minecraft.world.inventory.CartographyTableMenu.RESULT_SLOT
|
|
|
|
+ }
|
|
|
|
+ // Paper end - add getResult/setResult to CartographyInventory
|
|
|
|
+}
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2023-06-12 19:04:53 +02:00
|
|
|
index 96d526b7b153e56c9a97de42ce3270b6638510e4..5ed72b7305428f6be98a86fa9aa174d1b8ad4c17 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/inventory/SmithingInventory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/inventory/SmithingInventory.java
|
2023-06-12 19:04:53 +02:00
|
|
|
@@ -30,4 +30,59 @@ public interface SmithingInventory extends Inventory {
|
2021-06-11 14:02:28 +02:00
|
|
|
*/
|
|
|
|
@Nullable
|
|
|
|
Recipe getRecipe();
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ /**
|
2023-06-12 19:04:53 +02:00
|
|
|
+ * Gets the input template (first slot).
|
|
|
|
+ *
|
|
|
|
+ * @return input template item
|
|
|
|
+ */
|
|
|
|
+ default @Nullable ItemStack getInputTemplate() {
|
|
|
|
+ return this.getItem(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets the input template (first slot).
|
|
|
|
+ *
|
|
|
|
+ * @param itemStack item to set
|
|
|
|
+ */
|
|
|
|
+ default void setInputTemplate(@Nullable ItemStack itemStack) {
|
|
|
|
+ this.setItem(0, itemStack);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * Gets the input equipment (second slot).
|
2021-06-11 14:02:28 +02:00
|
|
|
+ *
|
|
|
|
+ * @return input equipment item
|
|
|
|
+ */
|
2023-06-12 19:04:53 +02:00
|
|
|
+ default @Nullable ItemStack getInputEquipment() {
|
|
|
|
+ return this.getItem(1);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2023-06-12 19:04:53 +02:00
|
|
|
+ * Sets the input equipment (second slot).
|
2021-06-11 14:02:28 +02:00
|
|
|
+ *
|
|
|
|
+ * @param itemStack item to set
|
|
|
|
+ */
|
|
|
|
+ default void setInputEquipment(@Nullable ItemStack itemStack) {
|
2023-06-12 19:04:53 +02:00
|
|
|
+ this.setItem(1, itemStack);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2023-06-12 19:04:53 +02:00
|
|
|
+ * Gets the input mineral (third slot).
|
2021-06-11 14:02:28 +02:00
|
|
|
+ *
|
|
|
|
+ * @return input mineral item
|
|
|
|
+ */
|
2023-06-12 19:04:53 +02:00
|
|
|
+ default @Nullable ItemStack getInputMineral() {
|
|
|
|
+ return this.getItem(2);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2023-06-12 19:04:53 +02:00
|
|
|
+ * Sets the input mineral (third slot).
|
2021-06-11 14:02:28 +02:00
|
|
|
+ *
|
|
|
|
+ * @param itemStack item to set
|
|
|
|
+ */
|
|
|
|
+ default void setInputMineral(@Nullable ItemStack itemStack) {
|
2023-06-12 19:04:53 +02:00
|
|
|
+ this.setItem(2, itemStack);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ // 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
|
|
|
|
+}
|