类 BlockEntityTypeAddBlocksEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.BlockEntityTypeAddBlocksEvent
- 所有已实现的接口:
net.neoforged.fml.event.IModBusEvent
public class BlockEntityTypeAddBlocksEvent
extends net.neoforged.bus.api.Event
implements net.neoforged.fml.event.IModBusEvent
Allows injecting new blocks into a block entity's
BlockEntityType.validBlocks
field in a safe manner.
The class of the newly injected block should share the highest common class that all existing blocks in the targeted validBlocks has.
Please use this event instead of manipulating BlockEntityType
directly.
Example: If the valid blocks list has StandingSignBlock entry and WallSignBlock entry, the common class is SignBlock,
the given block must be a SignBlock or have SignBlock
as a parent class in its hierarchy. Example:
public static void onBlockEntityValidBlocks(BlockEntityTypeAddBlocksEvent event) {
event.modify(BlockEntityType.SIGN, MODDED_SIGN_BLOCK.get());
}
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private void
addValidBlock
(Block block, @Nullable Class<?> baseClass, Set<Block> currentValidBlocks) private static Class
<?> findClosestCommonSuper
(Class<?> superClass, Class<?> childClass) private @Nullable Class
<?> getCommonSuperClassForExistingValidBlocks
(Set<Block> validBlocks) void
modify
(BiPredicate<ResourceKey<BlockEntityType<?>>, BlockEntityType<?>> blockEntityTypeToMatch, Block... blocksToAdd) Will add the given blocks to the matchingBlockEntityType
's set of valid blocks.void
modify
(ResourceKey<BlockEntityType<?>> blockEntityTypeKey, Block... blocksToAdd) Will add the given blocks to theBlockEntityType
's set of valid blocks.void
modify
(BlockEntityType<?> blockEntityType, Block... blocksToAdd) Will add the given blocks to the providedBlockEntityType
's set of valid blocks.
-
字段详细资料
-
memoizedCommonSuperClass
-
-
构造器详细资料
-
BlockEntityTypeAddBlocksEvent
public BlockEntityTypeAddBlocksEvent()
-
-
方法详细资料
-
modify
Will add the given blocks to the providedBlockEntityType
's set of valid blocks. -
modify
Will add the given blocks to theBlockEntityType
's set of valid blocks. -
modify
public void modify(BiPredicate<ResourceKey<BlockEntityType<?>>, BlockEntityType<?>> blockEntityTypeToMatch, Block... blocksToAdd) Will add the given blocks to the matchingBlockEntityType
's set of valid blocks. -
addValidBlock
-
getCommonSuperClassForExistingValidBlocks
-
findClosestCommonSuper
-