public interface HarvestBlockEvent extends TargetBlockEvent, ChangeEntityExperienceEvent
BlockState
at a Location
is
being harvested and one or more ItemStack
(s) are dropped.Modifier and Type | Method and Description |
---|---|
Collection<ItemStack> |
filterItemStacks(Predicate<ItemStack> predicate)
Filters
ItemStack s within getItemStacks() . |
float |
getDropChance()
Gets the chance the result from
getItemStacks()
will be dropped. |
Collection<ItemStack> |
getItemStacks()
Gets a mutable
Collection which will be dropped after
event resolution. |
float |
getOriginalDropChance()
Gets the original chance unmodified by event changes.
|
Collection<ItemStack> |
getOriginalItemStacks()
Gets a mutable copy of the original
Collection
unaffected by changes to this event. |
void |
setDropChance(float chance)
Sets the chance the result from
getItemStacks()
will drop. |
void |
setItems(Collection<ItemStack> items)
Sets the
Collection that will be dropped after event
resolution. |
getTargetBlock
getExperience, getOriginalExperience, setExperience
getTargetEntity
getCallbacks
isCancelled, setCancelled
getCause
Collection<ItemStack> getOriginalItemStacks()
Collection
unaffected by changes to this event.Collection<ItemStack> getItemStacks()
Collection
which will be dropped after
event resolution.void setItems(Collection<ItemStack> items)
Collection
that will be dropped after event
resolution.items
- The Collection of ItemStackCollection<ItemStack> filterItemStacks(Predicate<ItemStack> predicate)
ItemStack
s within getItemStacks()
.
The ItemStacks remaining in the Collection will be the ones that will
be dropped. This will be the same Collection returned from getItemStacks()
.
predicate
- The predicate to use for filtering.float getOriginalDropChance()
getDropChance()
float getDropChance()
getItemStacks()
will be dropped.
A value of 0.0f means 0% chance of drop whereas 1.0f means 100% chance of drop.
void setDropChance(float chance)
getItemStacks()
will drop.
A value of 0.0f means 0% chance of drop whereas 1.0f means 100% chance of drop. Any value below 0.0f will be grounded at 0 and likewise any value above 1.0f will be capped at 1.0f.
Keep in mind that your chance is not guaranteed; a plugin or mod could change it afterwards. If the desire is to guarantee that the drop won't occur, useCancellable.setCancelled(boolean)
instead (make sure
to pass in true).chance
- The chance