Package alexiil.mc.lib.multipart.api
Interface SubdividedPart<Sub>
public interface SubdividedPart<Sub>
Optional interface for
AbstractPart
implementations which can have sub-parts targeted and broken instead of
the whole thing.-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterSubpartBreak
(PlayerEntity player, ItemStack tool, Sub subpart) Multipart version ofBlock.afterBreak(World, PlayerEntity, BlockPos, BlockState, BlockEntity, ItemStack)
.float
calcSubpartBreakingDelta
(Sub subpart) Multipart version ofAbstractBlock.calcBlockBreakingDelta(BlockState, PlayerEntity, BlockView, BlockPos)
boolean
clearSubpart
(Sub subpart) getSubpartDynamicShape
(Vec3d hitVec, Sub subpart, float partialTicks) Subpart equivalent toAbstractPart.getDynamicShape(float, Vec3d)
.getTargetedSubpart
(Vec3d hitVec) default boolean
onSubpartBreak
(PlayerEntity player, Sub subpart) Multipart version ofBlock.onBreak(World, BlockPos, BlockState, PlayerEntity)
.void
onSubpartBreakStart
(PlayerEntity player, Sub subpart) Multipart version ofAbstractBlock.onBlockBreakStart(BlockState, World, BlockPos, PlayerEntity)
void
onSubpartBroken
(Sub subpart) Multipart version ofBlock.onBroken(WorldAccess, BlockPos, BlockState)
void
playHitSound
(PlayerEntity player, Sub subpart) default boolean
spawnBreakingParticles
(Vec3d hitVec, Sub subpart, Direction side)
-
Method Details
-
getSubpartKeyClass
-
onSubpartBreakStart
Multipart version ofAbstractBlock.onBlockBreakStart(BlockState, World, BlockPos, PlayerEntity)
-
calcSubpartBreakingDelta
Multipart version ofAbstractBlock.calcBlockBreakingDelta(BlockState, PlayerEntity, BlockView, BlockPos)
-
onSubpartBreak
Multipart version ofBlock.onBreak(World, BlockPos, BlockState, PlayerEntity)
.- Returns:
- True if this should prevent Block.onBreak from being called afterwards, false otherwise.
-
clearSubpart
Called instead ofWorld.removeBlock(BlockPos, boolean)
inServerPlayerInteractionManager.tryBreakBlock(net.minecraft.util.math.BlockPos)
.Generally this should remove the subpart from this
AbstractPart
, or return false if the whole part needs to be removed from it's container.- Returns:
- True if this should prevent
MultipartContainer.removePart(AbstractPart)
from being called, false otherwise.
-
onSubpartBroken
Multipart version ofBlock.onBroken(WorldAccess, BlockPos, BlockState)
-
afterSubpartBreak
Multipart version ofBlock.afterBreak(World, PlayerEntity, BlockPos, BlockState, BlockEntity, ItemStack)
. -
getSubpartDynamicShape
Subpart equivalent toAbstractPart.getDynamicShape(float, Vec3d)
. If the given part is invalid then this should returnAbstractPart.getDynamicShape(float, Vec3d)
. -
spawnBreakingParticles
-
getTargetedSubpart
- Parameters:
hitVec
- The exact hit position, relative the the world's origin. (So you need to subtract the position of this part to get a position between 0 and 1).- Returns:
- The targeted subpart, or null if the given position doesn't intersect with a subpart.
-
playHitSound
-