Class BlockWithEntity
- All Implemented Interfaces:
BlockEntityProvider
,ItemConvertible
,ToggleableFeature
- Direct Known Subclasses:
AbstractBannerBlock
,AbstractChestBlock
,AbstractFurnaceBlock
,AbstractSignBlock
,AbstractSkullBlock
,BarrelBlock
,BeaconBlock
,BeehiveBlock
,BellBlock
,BrewingStandBlock
,BrushableBlock
,CampfireBlock
,ChiseledBookshelfBlock
,CommandBlock
,ConduitBlock
,CrafterBlock
,DaylightDetectorBlock
,DecoratedPotBlock
,DispenserBlock
,EnchantingTableBlock
,EndGatewayBlock
,EndPortalBlock
,HopperBlock
,JukeboxBlock
,LecternBlock
,PistonExtensionBlock
,SculkCatalystBlock
,SculkSensorBlock
,SculkShriekerBlock
,ShulkerBoxBlock
,SpawnerBlock
,StructureBlock
,TrialSpawnerBlock
,VaultBlock
BlockEntity
.
While blocks with block entity only have to implement BlockEntityProvider
and do not have to subclass this, it overrides several methods to delegate its logic
to the block entity. However, it is generally easier to just implement
BlockEntityProvider
.
Subclasses must override getRenderType(net.minecraft.block.BlockState)
to render the
block entity. By default, all block entities are rendered invisible, which is not
intended in most, if not all, cases.
- See Also:
- Mappings:
Namespace Name named net/minecraft/block/BlockWithEntity
intermediary net/minecraft/class_2237
official den
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.block.Block
Block.NeighborGroup
Nested classes/interfaces inherited from class net.minecraft.block.AbstractBlock
AbstractBlock.AbstractBlockState, AbstractBlock.ContextPredicate, AbstractBlock.Offsetter, AbstractBlock.OffsetType, AbstractBlock.Settings, AbstractBlock.TypedContextPredicate<A>
-
Field Summary
Fields inherited from class net.minecraft.block.Block
CODEC, field_31023, field_31024, field_31025, field_31035, FORCE_STATE, MOVED, NO_REDRAW, NOTIFY_ALL, NOTIFY_ALL_AND_REDRAW, NOTIFY_LISTENERS, NOTIFY_NEIGHBORS, REDRAW_ON_MAIN_THREAD, SKIP_DROPS, STATE_IDS, stateManager
Fields inherited from class net.minecraft.block.AbstractBlock
collidable, DIRECTIONS, dynamicBounds, jumpVelocityMultiplier, lootTableKey, randomTicks, requiredFeatures, resistance, settings, slipperiness, soundGroup, velocityMultiplier
Fields inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
FEATURE_ENABLED_REGISTRY_KEYS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable NamedScreenHandlerFactory
createScreenHandlerFactory
(BlockState state, World world, BlockPos pos) Returns the screen handler factory ornull
if screen handler cannot be created.protected abstract com.mojang.serialization.MapCodec
<? extends BlockWithEntity> getCodec()
protected BlockRenderType
getRenderType
(BlockState state) Returns the block's render type (invisible, animated, model).protected boolean
onSyncedBlockEvent
(BlockState state, World world, BlockPos pos, int type, int data) Handles the block event, which is an event specific to a block with an integer ID and data.protected static <E extends BlockEntity,
A extends BlockEntity>
@Nullable BlockEntityTicker<A> validateTicker
(BlockEntityType<A> givenType, BlockEntityType<E> expectedType, BlockEntityTicker<? super E> ticker) Returns the ticker if the given type and expected type are the same, ornull
if they are different.Methods inherited from class net.minecraft.block.Block
afterBreak, appendProperties, appendTooltip, asBlock, asItem, canMobSpawnInside, cannotConnect, createCuboidShape, dropExperience, dropExperienceWhenMined, dropStack, dropStack, dropStacks, dropStacks, dropStacks, getBlastResistance, getBlockFromItem, getDefaultState, getDroppedStacks, getDroppedStacks, getJumpVelocityMultiplier, getName, getPickStack, getPlacementState, getRawIdFromState, getRegistryEntry, getShapesForStates, getSlipperiness, getStateFromRawId, getStateManager, getStateWithProperties, getTranslationKey, getVelocityMultiplier, hasDynamicBounds, hasTopRim, isFaceFullSquare, isShapeFullCube, onBreak, onBroken, onDestroyedByExplosion, onEntityLand, onLandedUpon, onPlaced, onSteppedOn, postProcessState, precipitationTick, pushEntitiesUpBeforeBlockChange, randomDisplayTick, replace, replace, setDefaultState, shouldDrawSide, shouldDropItemsOnExplosion, sideCoversSmallSquare, spawnBreakParticles, toString
Methods inherited from class net.minecraft.block.AbstractBlock
calcBlockBreakingDelta, canBucketPlace, canPathfindThrough, canPlaceAt, canReplace, createCodec, createSettingsCodec, emitsRedstonePower, getAmbientOcclusionLightLevel, getCameraCollisionShape, getCollisionShape, getComparatorOutput, getCullingShape, getDefaultMapColor, getDroppedStacks, getFluidState, getHardness, getLootTableKey, getMaxHorizontalModelOffset, getOpacity, getOutlineShape, getRaycastShape, getRenderingSeed, getRequiredFeatures, getSettings, getSidesShape, getSoundGroup, getStateForNeighborUpdate, getStrongRedstonePower, getVerticalModelOffsetMultiplier, getWeakRedstonePower, hasComparatorOutput, hasRandomTicks, hasSidedTransparency, isCullingShapeFullCube, isShapeFullCube, isSideInvisible, isTransparent, mirror, neighborUpdate, onBlockAdded, onBlockBreakStart, onEntityCollision, onExploded, onProjectileHit, onStacksDropped, onStateReplaced, onUse, onUseWithItem, prepare, randomTick, rotate, scheduledTick
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minecraft.block.BlockEntityProvider
createBlockEntity, getGameEventListener, getTicker
Methods inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
isEnabled
-
Constructor Details
-
BlockWithEntity
- Mappings:
Namespace Name Mixin selector named <init>
Lnet/minecraft/block/AbstractBlock;<init>(Lnet/minecraft/block/AbstractBlock$Settings;)V
intermediary <init>
Lnet/minecraft/class_4970;<init>(Lnet/minecraft/class_4970$class_2251;)V
official <init>
Ldsd;<init>(Ldsd$d;)V
-
-
Method Details
-
getCodec
- Overrides:
getCodec
in classBlock
- Mappings:
Namespace Name Mixin selector named getCodec
Lnet/minecraft/block/AbstractBlock;getCodec()Lcom/mojang/serialization/MapCodec;
intermediary method_53969
Lnet/minecraft/class_4970;method_53969()Lcom/mojang/serialization/MapCodec;
official a
Ldsd;a()Lcom/mojang/serialization/MapCodec;
-
getRenderType
Returns the block's render type (invisible, animated, model).- Overrides:
getRenderType
in classAbstractBlock
- Returns:
- the block's render type (invisible, animated, model)
- See Also:
- API Note:
BlockWithEntity
overrides this to returnBlockRenderType.INVISIBLE
; therefore, custom blocks extending that class must override it again to render the block.- Mappings:
Namespace Name Mixin selector named getRenderType
Lnet/minecraft/block/AbstractBlock;getRenderType(Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockRenderType;
intermediary method_9604
Lnet/minecraft/class_4970;method_9604(Lnet/minecraft/class_2680;)Lnet/minecraft/class_2464;
official a_
Ldsd;a_(Ldse;)Ldlh;
-
onSyncedBlockEvent
protected boolean onSyncedBlockEvent(BlockState state, World world, BlockPos pos, int type, int data) Handles the block event, which is an event specific to a block with an integer ID and data.- Overrides:
onSyncedBlockEvent
in classAbstractBlock
- Returns:
- whether the event was handled successfully
- See Also:
- Mappings:
Namespace Name Mixin selector named onSyncedBlockEvent
Lnet/minecraft/block/AbstractBlock;onSyncedBlockEvent(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;II)Z
intermediary method_9592
Lnet/minecraft/class_4970;method_9592(Lnet/minecraft/class_2680;Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;II)Z
official a
Ldsd;a(Ldse;Ldca;Liz;II)Z
-
createScreenHandlerFactory
@Nullable protected @Nullable NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) Returns the screen handler factory ornull
if screen handler cannot be created.This method should be overridden for blocks with screen handlers, such as anvils. The created screen handler is usually passed to
invalid reference
PlayerEntity#openHandledScreen
AnvilBlock.createScreenHandlerFactory(net.minecraft.block.BlockState, net.minecraft.world.World, net.minecraft.util.math.BlockPos)
for basic usage.BlockWithEntity
delegates this logic to the block entity implementingNamedScreenHandlerFactory
. For example, anyBlockWithEntity
whose block entity extendsLockableContainerBlockEntity
needs to overrideLockableContainerBlockEntity.createScreenHandler(int, net.minecraft.entity.player.PlayerInventory)
instead of this method.This method is called on both the logical client and logical server, so take caution when overriding this method. The logical side can be checked using
World.isClient
.- Overrides:
createScreenHandlerFactory
in classAbstractBlock
- Returns:
- the screen handler factory or
null
if screen handler cannot be created - See Also:
- Mappings:
Namespace Name Mixin selector named createScreenHandlerFactory
Lnet/minecraft/block/AbstractBlock;createScreenHandlerFactory(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/screen/NamedScreenHandlerFactory;
intermediary method_17454
Lnet/minecraft/class_4970;method_17454(Lnet/minecraft/class_2680;Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;)Lnet/minecraft/class_3908;
official b
Ldsd;b(Ldse;Ldca;Liz;)Lbra;
-
validateTicker
@Nullable protected static <E extends BlockEntity,A extends BlockEntity> @Nullable BlockEntityTicker<A> validateTicker(BlockEntityType<A> givenType, BlockEntityType<E> expectedType, BlockEntityTicker<? super E> ticker) Returns the ticker if the given type and expected type are the same, ornull
if they are different.- Returns:
- the ticker if the given type and expected type are the same, or
null
if they are different - Mappings:
Namespace Name Mixin selector named validateTicker
Lnet/minecraft/block/BlockWithEntity;validateTicker(Lnet/minecraft/block/entity/BlockEntityType;Lnet/minecraft/block/entity/BlockEntityType;Lnet/minecraft/block/entity/BlockEntityTicker;)Lnet/minecraft/block/entity/BlockEntityTicker;
intermediary method_31618
Lnet/minecraft/class_2237;method_31618(Lnet/minecraft/class_2591;Lnet/minecraft/class_2591;Lnet/minecraft/class_5558;)Lnet/minecraft/class_5558;
official a
Lden;a(Ldpl;Ldpl;Ldpk;)Ldpk;
-