Package org.cyclops.cyclopscore.block
Class BlockWithEntity
java.lang.Object
net.minecraft.world.level.block.state.BlockBehaviour
net.minecraft.world.level.block.Block
net.minecraft.world.level.block.BaseEntityBlock
org.cyclops.cyclopscore.block.BlockWithEntity
- All Implemented Interfaces:
net.minecraft.world.flag.FeatureElement
,net.minecraft.world.level.block.EntityBlock
,net.minecraft.world.level.ItemLike
,net.minecraftforge.common.extensions.IForgeBlock
- Direct Known Subclasses:
BlockWithEntityGui
public class BlockWithEntity
extends net.minecraft.world.level.block.BaseEntityBlock
Base block with a block entity.
By default, the NBT data of block entities will not be persisted,
unless enabled via
isPersistNbt()
.
If so, then the getDroppedItemStackNbt(net.minecraft.world.level.block.state.BlockState, net.minecraft.world.phys.HitResult, net.minecraft.world.level.BlockGetter, net.minecraft.core.BlockPos, net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, org.cyclops.cyclopscore.blockentity.CyclopsBlockEntity)
method will be called
to call CyclopsBlockEntity.writeToItemStack(CompoundTag)
.
This NBT data will automatically be read when placing the block.-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.world.level.block.Block
net.minecraft.world.level.block.Block.BlockStatePairKey
Nested classes/interfaces inherited from class net.minecraft.world.level.block.state.BlockBehaviour
net.minecraft.world.level.block.state.BlockBehaviour.BlockStateBase, net.minecraft.world.level.block.state.BlockBehaviour.OffsetFunction, net.minecraft.world.level.block.state.BlockBehaviour.OffsetType, net.minecraft.world.level.block.state.BlockBehaviour.Properties, net.minecraft.world.level.block.state.BlockBehaviour.StateArgumentPredicate<A extends Object>, net.minecraft.world.level.block.state.BlockBehaviour.StatePredicate
-
Field Summary
Fields inherited from class net.minecraft.world.level.block.Block
BLOCK_STATE_REGISTRY, INDESTRUCTIBLE, INSTANT, stateDefinition, UPDATE_ALL, UPDATE_ALL_IMMEDIATE, UPDATE_CLIENTS, UPDATE_IMMEDIATE, UPDATE_INVISIBLE, UPDATE_KNOWN_SHAPE, UPDATE_LIMIT, UPDATE_MOVE_BY_PISTON, UPDATE_NEIGHBORS, UPDATE_NONE, UPDATE_SUPPRESS_DROPS
Fields inherited from class net.minecraft.world.level.block.state.BlockBehaviour
drops, dynamicShape, explosionResistance, friction, hasCollision, isRandomlyTicking, jumpFactor, properties, requiredFeatures, soundType, speedFactor, UPDATE_SHAPE_ORDER
Fields inherited from interface net.minecraft.world.flag.FeatureElement
FILTERED_REGISTRIES
-
Constructor Summary
ConstructorDescriptionBlockWithEntity
(net.minecraft.world.level.block.state.BlockBehaviour.Properties properties, BiFunction<net.minecraft.core.BlockPos, net.minecraft.world.level.block.state.BlockState, CyclopsBlockEntity> blockEntitySupplier) -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.ItemStack
getCloneItemStack
(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.phys.HitResult target, net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos blockPos, net.minecraft.world.entity.player.Player player) protected net.minecraft.world.item.ItemStack
getDroppedItemStack
(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.phys.HitResult target, net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos blockPos, net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack originalItemStack) Override this method to modify the stack that is dropped.protected net.minecraft.nbt.CompoundTag
getDroppedItemStackNbt
(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.phys.HitResult target, net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos blockPos, net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack itemStack, CyclopsBlockEntity blockEntity) Override this method to modify how NBT is constructed for the item.net.minecraft.world.level.block.RenderShape
getRenderShape
(net.minecraft.world.level.block.state.BlockState state) boolean
If the NBT data of this block entity should be added to the dropped item.net.minecraft.world.level.block.entity.BlockEntity
newBlockEntity
(net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState) void
playerWillDestroy
(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState, net.minecraft.world.entity.player.Player player) Methods inherited from class net.minecraft.world.level.block.BaseEntityBlock
createTickerHelper, getMenuProvider, triggerEvent
Methods inherited from class net.minecraft.world.level.block.Block
animateTick, appendHoverText, asBlock, asItem, box, builtInRegistryHolder, byItem, canSupportCenter, canSupportRigidBlock, canSustainPlant, createBlockStateDefinition, defaultBlockState, destroy, dropFromExplosion, dropResources, dropResources, dropResources, fallOn, getCloneItemStack, getDescriptionId, getDrops, getDrops, getExplosionResistance, getFriction, getId, getJumpFactor, getName, getRenderPropertiesInternal, getShapeForEachState, getSoundType, getSpeedFactor, getStateDefinition, getStateForPlacement, handlePrecipitation, hasDynamicShape, initializeClient, isExceptionForConnection, isFaceFull, isPossibleToRespawnInThis, isRandomlyTicking, isShapeFullBlock, playerDestroy, popExperience, popResource, popResourceFromFace, propagatesSkylightDown, pushEntitiesUp, registerDefaultState, setPlacedBy, shouldRenderFace, spawnDestroyParticles, stateById, stepOn, toString, tryDropExperience, updateEntityAfterFallOn, updateFromNeighbourShapes, updateOrDestroy, updateOrDestroy, wasExploded, withPropertiesOf
Methods inherited from class net.minecraft.world.level.block.state.BlockBehaviour
attack, canBeReplaced, canBeReplaced, canSurvive, defaultDestroyTime, defaultMapColor, entityInside, getAnalogOutputSignal, getBlockSupportShape, getCollisionShape, getDestroyProgress, getDirectSignal, getDrops, getFluidState, getInteractionShape, getLightBlock, getLootTable, getMaxHorizontalOffset, getMaxVerticalOffset, getOcclusionShape, getSeed, getShadeBrightness, getShape, getSignal, getVisualShape, hasAnalogOutputSignal, isAir, isCollisionShapeFullBlock, isOcclusionShapeFullBlock, isPathfindable, isSignalSource, mirror, neighborChanged, onPlace, onProjectileHit, onRemove, randomTick, requiredFeatures, rotate, skipRendering, spawnAfterBreak, tick, updateIndirectNeighbourShapes, updateShape, use, useShapeForLightOcclusion
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minecraft.world.level.block.EntityBlock
getListener, getTicker
Methods inherited from interface net.minecraft.world.flag.FeatureElement
isEnabled
Methods inherited from interface net.minecraftforge.common.extensions.IForgeBlock
addLandingEffects, addRunningEffects, canBeHydrated, canConnectRedstone, canDropFromExplosion, canEntityDestroy, canHarvestBlock, canStickTo, collisionExtendsVertically, getAdjacentBlockPathType, getAppearance, getBeaconColorMultiplier, getBedDirection, getBlockPathType, getEnchantPowerBonus, getExpDrop, getExplosionResistance, getFireSpreadSpeed, getFlammability, getFriction, getLightEmission, getMapColor, getRespawnPosition, getSoundType, getStateAtViewpoint, getToolModifiedState, getWeakChanges, hidesNeighborFace, isBed, isBurning, isConduitFrame, isFertile, isFireSource, isFlammable, isLadder, isPortalFrame, isScaffolding, isSlimeBlock, isStickyBlock, isValidSpawn, makesOpenTrapdoorAboveClimbable, onBlockExploded, onBlockStateChange, onCaughtFire, onDestroyedByPlayer, onNeighborChange, onTreeGrow, rotate, setBedOccupied, shouldCheckWeakPower, shouldDisplayFluidOverlay, supportsExternalFaceHiding
-
Constructor Details
-
BlockWithEntity
public BlockWithEntity(net.minecraft.world.level.block.state.BlockBehaviour.Properties properties, BiFunction<net.minecraft.core.BlockPos, net.minecraft.world.level.block.state.BlockState, CyclopsBlockEntity> blockEntitySupplier)
-
-
Method Details
-
newBlockEntity
@Nullable public net.minecraft.world.level.block.entity.BlockEntity newBlockEntity(net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState) -
getRenderShape
public net.minecraft.world.level.block.RenderShape getRenderShape(net.minecraft.world.level.block.state.BlockState state) - Overrides:
getRenderShape
in classnet.minecraft.world.level.block.BaseEntityBlock
-
getCloneItemStack
public net.minecraft.world.item.ItemStack getCloneItemStack(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.phys.HitResult target, net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos blockPos, net.minecraft.world.entity.player.Player player) -
playerWillDestroy
public void playerWillDestroy(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState, net.minecraft.world.entity.player.Player player) - Overrides:
playerWillDestroy
in classnet.minecraft.world.level.block.Block
-
getDroppedItemStack
protected net.minecraft.world.item.ItemStack getDroppedItemStack(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.phys.HitResult target, net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos blockPos, net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack originalItemStack) Override this method to modify the stack that is dropped.- Parameters:
state
- A block state.target
- The ray trace result.world
- The world.blockPos
- The current position.player
- The player breaking the block.originalItemStack
- The original stack.- Returns:
- The modified stack.
-
getDroppedItemStackNbt
protected net.minecraft.nbt.CompoundTag getDroppedItemStackNbt(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.phys.HitResult target, net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos blockPos, net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack itemStack, CyclopsBlockEntity blockEntity) Override this method to modify how NBT is constructed for the item. By default,CyclopsBlockEntity.writeToItemStack(CompoundTag)
will be called.- Parameters:
state
- A block state.target
- The ray trace result.world
- The world.blockPos
- The current position.player
- The player breaking the block.itemStack
- The item stack.blockEntity
- The block entity to serialize.- Returns:
- The NBT tag that will be added to the item stack.
-
isPersistNbt
public boolean isPersistNbt()If the NBT data of this block entity should be added to the dropped item.- Returns:
- If the NBT data should be added.
-