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
    void afterSubpartBreak​(net.minecraft.entity.player.PlayerEntity player, net.minecraft.item.ItemStack tool, Sub subpart)
    Multipart version of Block.afterBreak(World, PlayerEntity, BlockPos, BlockState, BlockEntity, ItemStack).
    float calcSubpartBreakingDelta​(Sub subpart)
    Multipart version of AbstractBlock.calcBlockBreakingDelta(BlockState, PlayerEntity, BlockView, BlockPos)
    boolean clearSubpart​(Sub subpart)
    Called instead of World.removeBlock(BlockPos, boolean) in ServerPlayerInteractionManager.tryBreakBlock(net.minecraft.util.math.BlockPos).
    net.minecraft.util.shape.VoxelShape getSubpartDynamicShape​(net.minecraft.util.math.Vec3d hitVec, Sub subpart, float partialTicks)
    java.lang.Class<Sub> getSubpartKeyClass()  
    Sub getTargetedSubpart​(net.minecraft.util.math.Vec3d hitVec)  
    default boolean onSubpartBreak​(net.minecraft.entity.player.PlayerEntity player, Sub subpart)
    Multipart version of Block.onBreak(World, BlockPos, BlockState, PlayerEntity).
    void onSubpartBreakStart​(net.minecraft.entity.player.PlayerEntity player, Sub subpart)
    Multipart version of AbstractBlock.onBlockBreakStart(BlockState, World, BlockPos, PlayerEntity)
    void onSubpartBroken​(Sub subpart)
    Multipart version of Block.onBroken(WorldAccess, BlockPos, BlockState)
    void playHitSound​(net.minecraft.entity.player.PlayerEntity player, Sub subpart)  
    default boolean spawnBreakingParticles​(net.minecraft.util.math.Vec3d hitVec, Sub subpart, net.minecraft.util.math.Direction side)  
  • Method Details

    • getSubpartKeyClass

      java.lang.Class<Sub> getSubpartKeyClass()
    • onSubpartBreakStart

      void onSubpartBreakStart​(net.minecraft.entity.player.PlayerEntity player, Sub subpart)
      Multipart version of AbstractBlock.onBlockBreakStart(BlockState, World, BlockPos, PlayerEntity)
    • calcSubpartBreakingDelta

      float calcSubpartBreakingDelta​(Sub subpart)
      Multipart version of AbstractBlock.calcBlockBreakingDelta(BlockState, PlayerEntity, BlockView, BlockPos)
    • onSubpartBreak

      default boolean onSubpartBreak​(net.minecraft.entity.player.PlayerEntity player, Sub subpart)
      Multipart version of Block.onBreak(World, BlockPos, BlockState, PlayerEntity).
      Returns:
      True if this should prevent Block.onBreak from being called afterwards, false otherwise.
    • clearSubpart

      boolean clearSubpart​(Sub subpart)
      Called instead of World.removeBlock(BlockPos, boolean) in ServerPlayerInteractionManager.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

      void onSubpartBroken​(Sub subpart)
      Multipart version of Block.onBroken(WorldAccess, BlockPos, BlockState)
    • afterSubpartBreak

      void afterSubpartBreak​(net.minecraft.entity.player.PlayerEntity player, net.minecraft.item.ItemStack tool, Sub subpart)
      Multipart version of Block.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 to AbstractPart.getDynamicShape(float). If the given part is invalid then this should return AbstractPart.getDynamicShape(float).
    • spawnBreakingParticles

      default boolean spawnBreakingParticles​(net.minecraft.util.math.Vec3d hitVec, Sub subpart, net.minecraft.util.math.Direction side)
    • getTargetedSubpart

      @Nullable Sub getTargetedSubpart​(net.minecraft.util.math.Vec3d hitVec)
      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)