类 BlockDropsEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.level.BlockEvent
net.neoforged.neoforge.event.level.BlockDropsEvent
- 所有已实现的接口:
net.neoforged.bus.api.ICancellableEvent
Fired when a block is broken and the drops have been determined, but before they have been added to the world. This event can be used to manipulate the dropped items and experience.
No guarantees can be made about the block. It will either have already been removed from the world, or will be removed after the event terminates.
If you wish to edit the state of the block in-world, use BlockEvent.BreakEvent
.
-
嵌套类概要
从类继承的嵌套类/接口 net.neoforged.neoforge.event.level.BlockEvent
BlockEvent.BlockToolModificationEvent, BlockEvent.BreakEvent, BlockEvent.EntityMultiPlaceEvent, BlockEvent.EntityPlaceEvent, BlockEvent.FarmlandTrampleEvent, BlockEvent.FluidPlaceBlockEvent, BlockEvent.NeighborNotifyEvent, BlockEvent.PortalSpawnEvent
-
字段概要
字段修饰符和类型字段说明private final @Nullable BlockEntity
private final @Nullable Entity
private final List
<ItemEntity> private int
private final ItemStack
-
构造器概要
构造器构造器说明BlockDropsEvent
(ServerLevel level, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, List<ItemEntity> drops, @Nullable Entity breaker, ItemStack tool) Constructs a new BlockDropsEvent -
方法概要
修饰符和类型方法说明@Nullable BlockEntity
返回 the block entity from the current position, if available。@Nullable Entity
返回 the entity that broke the block, or null if unknown。int
返回 the amount of experience points that will be dropped by the block。getDrops()
Returns a mutable list of item entities that will be dropped by this block.getLevel()
getTool()
返回 the tool used when breaking this block; may be empty。void
setCanceled
(boolean canceled) Cancels this event, preventing any drops from being spawned and preventingBlockBehaviour.spawnAfterBreak(net.minecraft.world.level.block.state.BlockState, net.minecraft.server.level.ServerLevel, net.minecraft.core.BlockPos, net.minecraft.world.item.ItemStack, boolean)
from being called.void
setDroppedExperience
(int experience) Set the amount of experience points that will be dropped by the block.从类继承的方法 net.neoforged.neoforge.event.level.BlockEvent
getPos, getState
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 net.neoforged.bus.api.ICancellableEvent
isCanceled
-
字段详细资料
-
blockEntity
-
drops
-
breaker
-
tool
-
experience
private int experience
-
-
构造器详细资料
-
BlockDropsEvent
public BlockDropsEvent(ServerLevel level, BlockPos pos, BlockState state, @Nullable @Nullable BlockEntity blockEntity, List<ItemEntity> drops, @Nullable @Nullable Entity breaker, ItemStack tool) Constructs a new BlockDropsEvent- 参数:
level
- The level of the broken blockpos
- The position of the broken blockstate
- The state of the broken blockblockEntity
- The block entity of the broken block, if availabledrops
- The list of drops fromBlock.getDrops(net.minecraft.world.level.block.state.BlockState, net.minecraft.server.level.ServerLevel, net.minecraft.core.BlockPos, net.minecraft.world.level.block.entity.BlockEntity)
breaker
- The entity who broke the block, if anytool
- The tool used to break the block. May be empty
-
-
方法详细资料
-
getDrops
Returns a mutable list of item entities that will be dropped by this block.When this event completes successfully, all entities in this list will be added to the world.
- 返回:
- A mutable list of item entities.
- API Note:
- Prefer using
LootModifier
s to add additional loot drops.
-
getBlockEntity
返回 the block entity from the current position, if available。- 返回:
- the block entity from the current position, if available
-
getBreaker
返回 the entity that broke the block, or null if unknown。- 返回:
- the entity that broke the block, or null if unknown
-
getTool
返回 the tool used when breaking this block; may be empty。- 返回:
- the tool used when breaking this block; may be empty
-
setCanceled
public void setCanceled(boolean canceled) Cancels this event, preventing any drops from being spawned and preventingBlockBehaviour.spawnAfterBreak(net.minecraft.world.level.block.state.BlockState, net.minecraft.server.level.ServerLevel, net.minecraft.core.BlockPos, net.minecraft.world.item.ItemStack, boolean)
from being called.Also prevents experience from being spawned.
- 指定者:
setCanceled
在接口中net.neoforged.bus.api.ICancellableEvent
-
getLevel
- 覆盖:
getLevel
在类中BlockEvent
-
getDroppedExperience
public int getDroppedExperience()返回 the amount of experience points that will be dropped by the block。- 返回:
- the amount of experience points that will be dropped by the block
-
setDroppedExperience
public void setDroppedExperience(int experience) Set the amount of experience points that will be dropped by the block. This is the true value, after enchantments have been applied.- 参数:
experience
- The new amount. Must not be negative.- API Note:
- When cancelled, no experience is dropped, regardless of this value.
-