mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-28 14:44:47 +01:00
Custom replacement for eaten items
This commit is contained in:
parent
97112daade
commit
1e271136de
1 changed files with 24 additions and 0 deletions
|
@ -24,6 +24,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
|
||||||
private boolean isCancelled = false;
|
private boolean isCancelled = false;
|
||||||
private ItemStack item;
|
private ItemStack item;
|
||||||
private final EquipmentSlot hand;
|
private final EquipmentSlot hand;
|
||||||
|
@Nullable private ItemStack replacement; // Paper
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param player the player consuming
|
* @param player the player consuming
|
||||||
|
@ -82,6 +83,29 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
|
||||||
return hand;
|
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
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return this.isCancelled;
|
return this.isCancelled;
|
||||||
|
|
Loading…
Add table
Reference in a new issue