13
0
geforkt von Mirrors/Paper

Add item slot convenience methods

Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
Dieser Commit ist enthalten in:
Nassim Jahnke 2020-04-25 23:31:28 +02:00
Ursprung 83b1a9e372
Commit ec2e3991b9
6 geänderte Dateien mit 265 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -78,4 +78,64 @@ public interface AnvilInventory extends Inventory {
*/
@Deprecated(forRemoval = true, since = "1.21")
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
}

Datei anzeigen

@ -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
}

Datei anzeigen

@ -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
}

Datei anzeigen

@ -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
}

Datei anzeigen

@ -30,4 +30,59 @@ public interface SmithingInventory extends Inventory {
*/
@Nullable
Recipe getRecipe();
// Paper start
/**
* 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).
*
* @return input equipment item
*/
default @Nullable ItemStack getInputEquipment() {
return this.getItem(1);
}
/**
* Sets the input equipment (second slot).
*
* @param itemStack item to set
*/
default void setInputEquipment(@Nullable ItemStack itemStack) {
this.setItem(1, itemStack);
}
/**
* Gets the input mineral (third slot).
*
* @return input mineral item
*/
default @Nullable ItemStack getInputMineral() {
return this.getItem(2);
}
/**
* Sets the input mineral (third slot).
*
* @param itemStack item to set
*/
default void setInputMineral(@Nullable ItemStack itemStack) {
this.setItem(2, itemStack);
}
// Paper end
}

Datei anzeigen

@ -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
}