mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-08 08:21:50 +01:00
Add experimental ItemStack#consume
This commit is contained in:
parent
6c4cb66737
commit
7fae70ebc1
@ -7,6 +7,7 @@ import net.minestom.server.item.rule.VanillaStackingRule;
|
||||
import net.minestom.server.tag.Tag;
|
||||
import net.minestom.server.tag.TagReadable;
|
||||
import net.minestom.server.utils.NBTUtils;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -105,6 +106,12 @@ public final class ItemStack implements TagReadable, HoverEventSource<HoverEvent
|
||||
return withAmount(intUnaryOperator.applyAsInt(amount));
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
@Contract(value = "_, -> new", pure = true)
|
||||
public @NotNull ItemStack consume(int amount) {
|
||||
return stackingRule.apply(this, currentAmount -> currentAmount - amount);
|
||||
}
|
||||
|
||||
@Contract(value = "_, _ -> new", pure = true)
|
||||
public <T extends ItemMetaBuilder, U extends ItemMetaBuilder.Provider<T>> @NotNull ItemStack withMeta(Class<U> metaType, Consumer<T> metaConsumer) {
|
||||
return builder().meta(metaType, metaConsumer).build();
|
||||
|
Loading…
Reference in New Issue
Block a user