1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-01-31 12:03:27 +01:00

Custom replacement for eaten items

This commit is contained in:
Jedediah Smith 2015-06-21 15:05:21 -04:00
parent 97112daade
commit 1e271136de

View file

@ -24,6 +24,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
private boolean isCancelled = false;
private ItemStack item;
private final EquipmentSlot hand;
@Nullable private ItemStack replacement; // Paper
/**
* @param player the player consuming
@ -82,6 +83,29 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
return hand;
}
// Paper start
/**
* Return the custom item stack that will replace the consumed item, or null if no
* custom replacement has been set (which means the default replacement will be used).
*
* @return The custom item stack that will replace the consumed item or null
*/
@Nullable
public ItemStack getReplacement() {
return this.replacement;
}
/**
* Set a custom item stack to replace the consumed item. Pass null to clear any custom
* stack that has been set and use the default replacement.
*
* @param replacement Replacement item to set, null to clear any custom stack and use default
*/
public void setReplacement(@Nullable ItemStack replacement) {
this.replacement = replacement;
}
// Paper end
@Override
public boolean isCancelled() {
return this.isCancelled;