Class BlockWithEntity
- All Implemented Interfaces:
BlockEntityProvider,ItemConvertible,ToggleableFeature
- Direct Known Subclasses:
AbstractBannerBlock,AbstractChestBlock,AbstractFurnaceBlock,AbstractSignBlock,AbstractSkullBlock,BarrelBlock,BeaconBlock,BeehiveBlock,BellBlock,BrewingStandBlock,CampfireBlock,ChiseledBookshelfBlock,CommandBlock,ConduitBlock,DaylightDetectorBlock,DispenserBlock,EnchantingTableBlock,EndGatewayBlock,EndPortalBlock,HopperBlock,JukeboxBlock,LecternBlock,PistonExtensionBlock,SculkCatalystBlock,SculkSensorBlock,SculkShriekerBlock,ShulkerBoxBlock,SpawnerBlock,StructureBlock
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 official cnointermediary net/minecraft/class_2237named net/minecraft/block/BlockWithEntity
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.block.Block
Block.NeighborGroupNested classes/interfaces inherited from class net.minecraft.block.AbstractBlock
AbstractBlock.AbstractBlockState, AbstractBlock.ContextPredicate, AbstractBlock.OffsetType, AbstractBlock.Settings, AbstractBlock.TypedContextPredicate<A> -
Field Summary
Fields inherited from class net.minecraft.block.Block
field_31022, field_31023, field_31024, field_31025, field_31035, FORCE_STATE, MOVED, NO_REDRAW, NOTIFY_ALL, NOTIFY_LISTENERS, NOTIFY_NEIGHBORS, REDRAW_ON_MAIN_THREAD, SKIP_DROPS, SKIP_LIGHTING_UPDATES, STATE_IDS, stateManagerFields inherited from class net.minecraft.block.AbstractBlock
collidable, DIRECTIONS, dynamicBounds, jumpVelocityMultiplier, lootTableId, material, randomTicks, requiredFeatures, resistance, settings, slipperiness, soundGroup, velocityMultiplierFields inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
FEATURE_ENABLED_REGISTRY_KEYS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static <E extends BlockEntity,A extends BlockEntity>
@Nullable BlockEntityTicker<A>checkType(BlockEntityType<A> givenType, BlockEntityType<E> expectedType, BlockEntityTicker<? super E> ticker) Returns the ticker if the given type and expected type are the same, ornullif they are different.createScreenHandlerFactory(BlockState state, World world, BlockPos pos) Returns the screen handler factory ornullif screen handler cannot be created.getRenderType(BlockState state) Returns the block's render type (invisible, animated, model).booleanonSyncedBlockEvent(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.Methods inherited from class net.minecraft.block.Block
afterBreak, appendProperties, appendTooltip, asBlock, asItem, canMobSpawnInside, cannotConnect, createCuboidShape, dropExperience, dropExperienceWhenMined, dropStack, dropStack, dropStacks, dropStacks, dropStacks, dropStacks, getBlastResistance, getBlockFromItem, getDefaultState, getDroppedStacks, getDroppedStacks, getJumpVelocityMultiplier, getName, getPickStack, getPlacementState, getRawIdFromState, getRegistryEntry, getShapesForStates, getSlipperiness, getSoundGroup, getStateFromRawId, getStateManager, getStateWithProperties, getTranslationKey, getVelocityMultiplier, hasDynamicBounds, hasRandomTicks, hasTopRim, isFaceFullSquare, isShapeFullCube, isTranslucent, onBreak, onBroken, onDestroyedByExplosion, onEntityLand, onLandedUpon, onPlaced, onSteppedOn, postProcessState, precipitationTick, pushEntitiesUpBeforeBlockChange, randomDisplayTick, replace, replace, setDefaultState, shouldDrawSide, shouldDropItemsOnExplosion, sideCoversSmallSquare, spawnBreakParticles, toStringMethods inherited from class net.minecraft.block.AbstractBlock
calcBlockBreakingDelta, canBucketPlace, canPathfindThrough, canPlaceAt, canReplace, emitsRedstonePower, getAmbientOcclusionLightLevel, getCameraCollisionShape, getCollisionShape, getComparatorOutput, getCullingShape, getDefaultMapColor, getDroppedStacks, getFluidState, getHardness, getLootTableId, getMaxHorizontalModelOffset, getOpacity, getOutlineShape, getPistonBehavior, getRaycastShape, getRenderingSeed, getRequiredFeatures, getSidesShape, getStateForNeighborUpdate, getStrongRedstonePower, getVerticalModelOffsetMultiplier, getWeakRedstonePower, hasComparatorOutput, hasSidedTransparency, isCullingShapeFullCube, isShapeFullCube, isSideInvisible, mirror, neighborUpdate, onBlockAdded, onBlockBreakStart, onEntityCollision, onProjectileHit, onStacksDropped, onStateReplaced, onUse, prepare, randomTick, rotate, scheduledTickMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.block.BlockEntityProvider
createBlockEntity, getGameEventListener, getTickerMethods inherited from interface net.minecraft.resource.featuretoggle.ToggleableFeature
isEnabled
-
Constructor Details
-
BlockWithEntity
- Mappings:
Namespace Name Mixin selector official <init>Ldaa;<init>(Ldaa$c;)Vintermediary <init>Lnet/minecraft/class_4970;<init>(Lnet/minecraft/class_4970$class_2251;)Vnamed <init>Lnet/minecraft/block/AbstractBlock;<init>(Lnet/minecraft/block/AbstractBlock$Settings;)V
-
-
Method Details
-
getRenderType
Returns the block's render type (invisible, animated, model).- Overrides:
getRenderTypein classAbstractBlock- Returns:
- the block's render type (invisible, animated, model)
- Mappings:
Namespace Name Mixin selector official b_Ldaa;b_(Ldab;)Lcua;intermediary method_9604Lnet/minecraft/class_4970;method_9604(Lnet/minecraft/class_2680;)Lnet/minecraft/class_2464;named getRenderTypeLnet/minecraft/block/AbstractBlock;getRenderType(Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockRenderType;
-
onSyncedBlockEvent
Handles the block event, which is an event specific to a block with an integer ID and data.- Overrides:
onSyncedBlockEventin classAbstractBlock- Returns:
- whether the event was handled successfully
- See Also:
- Mappings:
Namespace Name Mixin selector official aLdaa;a(Ldab;Lcle;Lgp;II)Zintermediary method_9592Lnet/minecraft/class_4970;method_9592(Lnet/minecraft/class_2680;Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;II)Znamed onSyncedBlockEventLnet/minecraft/block/AbstractBlock;onSyncedBlockEvent(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;II)Z
-
createScreenHandlerFactory
@Nullable public @Nullable NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) Returns the screen handler factory ornullif 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
PlayerEntity.openHandledScreen(net.minecraft.screen.NamedScreenHandlerFactory). SeeAnvilBlock.createScreenHandlerFactory(net.minecraft.block.BlockState, net.minecraft.world.World, net.minecraft.util.math.BlockPos)for basic usage.BlockWithEntitydelegates this logic to the block entity implementingNamedScreenHandlerFactory. For example, anyBlockWithEntitywhose block entity extendsLockableContainerBlockEntityneeds 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:
createScreenHandlerFactoryin classAbstractBlock- Returns:
- the screen handler factory or
nullif screen handler cannot be created - See Also:
- Mappings:
Namespace Name Mixin selector official bLdaa;b(Ldab;Lcle;Lgp;)Lbdj;intermediary method_17454Lnet/minecraft/class_4970;method_17454(Lnet/minecraft/class_2680;Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;)Lnet/minecraft/class_3908;named createScreenHandlerFactoryLnet/minecraft/block/AbstractBlock;createScreenHandlerFactory(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/screen/NamedScreenHandlerFactory;
-
checkType
@Nullable protected static <E extends BlockEntity,A extends BlockEntity> @Nullable BlockEntityTicker<A> checkType(BlockEntityType<A> givenType, BlockEntityType<E> expectedType, BlockEntityTicker<? super E> ticker) Returns the ticker if the given type and expected type are the same, ornullif they are different.- Returns:
- the ticker if the given type and expected type are the same, or
nullif they are different - Mappings:
Namespace Name Mixin selector official aLcno;a(Lcxv;Lcxv;Lcxu;)Lcxu;intermediary method_31618Lnet/minecraft/class_2237;method_31618(Lnet/minecraft/class_2591;Lnet/minecraft/class_2591;Lnet/minecraft/class_5558;)Lnet/minecraft/class_5558;named checkTypeLnet/minecraft/block/BlockWithEntity;checkType(Lnet/minecraft/block/entity/BlockEntityType;Lnet/minecraft/block/entity/BlockEntityType;Lnet/minecraft/block/entity/BlockEntityTicker;)Lnet/minecraft/block/entity/BlockEntityTicker;
-