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 Type Method Description voidafterSubpartBreak(net.minecraft.entity.player.PlayerEntity player, net.minecraft.item.ItemStack tool, Sub subpart)Multipart version ofBlock.afterBreak(World, PlayerEntity, BlockPos, BlockState, BlockEntity, ItemStack).floatcalcSubpartBreakingDelta(Sub subpart)Multipart version ofAbstractBlock.calcBlockBreakingDelta(BlockState, PlayerEntity, BlockView, BlockPos)booleanclearSubpart(Sub subpart)Called instead ofWorld.removeBlock(BlockPos, boolean)inServerPlayerInteractionManager.tryBreakBlock(net.minecraft.util.math.BlockPos).net.minecraft.util.shape.VoxelShapegetSubpartDynamicShape(net.minecraft.util.math.Vec3d hitVec, Sub subpart, float partialTicks)Subpart equivalent toAbstractPart.getDynamicShape(float).java.lang.Class<Sub>getSubpartKeyClass()SubgetTargetedSubpart(net.minecraft.util.math.Vec3d hitVec)default booleanonSubpartBreak(net.minecraft.entity.player.PlayerEntity player, Sub subpart)Multipart version ofBlock.onBreak(World, BlockPos, BlockState, PlayerEntity).voidonSubpartBreakStart(net.minecraft.entity.player.PlayerEntity player, Sub subpart)Multipart version ofAbstractBlock.onBlockBreakStart(BlockState, World, BlockPos, PlayerEntity)voidonSubpartBroken(Sub subpart)Multipart version ofBlock.onBroken(WorldAccess, BlockPos, BlockState)voidplayHitSound(net.minecraft.entity.player.PlayerEntity player, Sub subpart)default booleanspawnBreakingParticles(net.minecraft.util.math.Vec3d hitVec, Sub subpart, net.minecraft.util.math.Direction side)
-
Method Details
-
getSubpartKeyClass
java.lang.Class<Sub> 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
void afterSubpartBreak(net.minecraft.entity.player.PlayerEntity player, net.minecraft.item.ItemStack tool, Sub subpart)Multipart version ofBlock.afterBreak(World, PlayerEntity, BlockPos, BlockState, BlockEntity, ItemStack). -
getSubpartDynamicShape
net.minecraft.util.shape.VoxelShape getSubpartDynamicShape(net.minecraft.util.math.Vec3d hitVec, Sub subpart, float partialTicks)Subpart equivalent toAbstractPart.getDynamicShape(float). If the given part is invalid then this should returnAbstractPart.getDynamicShape(float). -
spawnBreakingParticles
default boolean spawnBreakingParticles(net.minecraft.util.math.Vec3d hitVec, Sub subpart, net.minecraft.util.math.Direction side) -
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
@Environment(CLIENT) void playHitSound(net.minecraft.entity.player.PlayerEntity player, Sub subpart)
-