Schnittstelle EntityBlockProvider
- Alle Superschnittstellen:
net.minecraft.world.level.block.EntityBlock
- Alle bekannten Implementierungsklassen:
UEntityBlock
public interface EntityBlockProvider
extends net.minecraft.world.level.block.EntityBlock
Provides a convenience way to implement block entities for blocks.
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungnet.minecraft.world.level.block.entity.BlockEntityType<?> blockEntityType(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) Returns theBlockEntityTypethat is used for creating theBlockEntitywhennewBlockEntity(BlockPos, BlockState)is invoked.default <T extends net.minecraft.world.level.block.entity.BlockEntity>
Optional<T> getBlockEntity(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos) Returns a optional with can contain theBlockEntityat that give position if theBlockEntityTypeis correct.default net.minecraft.world.level.block.entity.BlockEntitynewBlockEntity(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) Returns a newBlockEntityfor the giveBlockPosandBlockState.default net.minecraft.world.InteractionResultopenMenu(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player) Opens the menu that is specified in the block entity withMenuConstructor.default net.minecraft.world.InteractionResultopenMenu(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player, boolean canOpenWhenSecondaryUse) Opens the menu that is specified in the block entity withMenuConstructor.Von Schnittstelle geerbte Methoden net.minecraft.world.level.block.EntityBlock
getListener, getTicker
-
Methodendetails
-
blockEntityType
net.minecraft.world.level.block.entity.BlockEntityType<?> blockEntityType(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) Returns theBlockEntityTypethat is used for creating theBlockEntitywhennewBlockEntity(BlockPos, BlockState)is invoked. Can return null if for the current state or position no block entity should be created.- Parameter:
pos- Position of the blockstate- Block state
-
newBlockEntity
default net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) Returns a newBlockEntityfor the giveBlockPosandBlockState.
The default implementation creates a newBlockEntityby using theblockEntityType(BlockPos, BlockState)method and invokeBlockEntityType.create(BlockPos, BlockState)Can return null if no block entity should be created for that position or state.- Angegeben von:
newBlockEntityin Schnittstellenet.minecraft.world.level.block.EntityBlock- Parameter:
pos- Position of the blockstate- Block state
-
getBlockEntity
default <T extends net.minecraft.world.level.block.entity.BlockEntity> Optional<T> getBlockEntity(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos) Returns a optional with can contain theBlockEntityat that give position if theBlockEntityTypeis correct. Otherwise returns an empty optional.- Typparameter:
T- Block entity- Parameter:
level- Levelpos- Position of the block- Gibt zurück:
- Optional with the block entity
-
openMenu
default net.minecraft.world.InteractionResult openMenu(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player) Opens the menu that is specified in the block entity withMenuConstructor. If the block entity implementsMenuSyncedBlockEntitythen theMenuSyncedBlockEntity.sendInitialMenuDataToClient(FriendlyByteBuf)is called and the data will be send to the client. The container cannot be opened when secondary use is active.- Parameter:
level- Levelpos- The block entities positionplayer- The player that opens the block entity- Gibt zurück:
InteractionResultif the container could be opened
-
openMenu
default net.minecraft.world.InteractionResult openMenu(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player, boolean canOpenWhenSecondaryUse) Opens the menu that is specified in the block entity withMenuConstructor. If the block entity implementsMenuSyncedBlockEntitythen theMenuSyncedBlockEntity.sendInitialMenuDataToClient(FriendlyByteBuf)is called and the data will be send to the client.- Parameter:
level- Levelpos- The block entities positionplayer- The player that opens the block entitycanOpenWhenSecondaryUse- If the container can be opened when secondary use is active- Gibt zurück:
InteractionResultif the container could be opened
-