Class McStatePart

java.lang.Object
codechicken.multipart.api.part.BaseMultipart
codechicken.multipart.minecraft.McStatePart
All Implemented Interfaces:
IconHitEffectsPart, ModelRenderPart, MultiPart, NormalOcclusionPart
Direct Known Subclasses:
McSidedStatePart

public abstract class McStatePart extends BaseMultipart implements NormalOcclusionPart, ModelRenderPart, IconHitEffectsPart
  • Field Details

    • state

      public net.minecraft.world.level.block.state.BlockState state
  • Constructor Details

    • McStatePart

      public McStatePart()
    • McStatePart

      public McStatePart(net.minecraft.world.level.block.state.BlockState state)
  • Method Details

    • defaultBlockState

      public abstract net.minecraft.world.level.block.state.BlockState defaultBlockState()
    • getDropStack

      public abstract net.minecraft.world.item.ItemStack getDropStack()
    • getDrops

      public Iterable<net.minecraft.world.item.ItemStack> getDrops()
      Description copied from interface: MultiPart
      Return a list of ItemStacks that should be dropped when this part is destroyed.
      Specified by:
      getDrops in interface MultiPart
      Returns:
      The ItemStacks.
    • getCloneStack

      public net.minecraft.world.item.ItemStack getCloneStack(PartRayTraceResult hit)
      Description copied from interface: MultiPart
      Return the ItemStack for pick-block(usually middle click) function.
      Specified by:
      getCloneStack in interface MultiPart
      Parameters:
      hit - The PartRayTraceResult hit result.
      Returns:
      The ItemStack pick result.
    • save

      public void save(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries)
      Description copied from interface: MultiPart
      Save this part to a CompoundTag.

      Only called server-side.

      Specified by:
      save in interface MultiPart
      Parameters:
      tag - The tag to write to.
    • load

      public void load(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries)
      Description copied from interface: MultiPart
      Load this part from a CompoundTag.

      Only called server-side.

      Specified by:
      load in interface MultiPart
      Parameters:
      tag - The tag to read from.
    • writeDesc

      public void writeDesc(codechicken.lib.data.MCDataOutput packet)
      Description copied from interface: MultiPart
      Write all the data required to describe a client version of this part to the packet.

      Called server-side, when a client loads a part for the first time.

      Specified by:
      writeDesc in interface MultiPart
      Parameters:
      packet - The packet to write to.
    • readDesc

      public void readDesc(codechicken.lib.data.MCDataInput packet)
      Description copied from interface: MultiPart
      Fill out this part with the description information contained in packet.

      Companion method to MultiPart.writeDesc(MCDataOutput).

      Called client-side when the client loads this part for the first time.

      Specified by:
      readDesc in interface MultiPart
      Parameters:
      packet - The packet to read from.
    • getCurrentState

      public net.minecraft.world.level.block.state.BlockState getCurrentState()
      Specified by:
      getCurrentState in interface ModelRenderPart
    • setStateOnPlacement

      @Nullable public @Nullable MultiPart setStateOnPlacement(net.minecraft.world.item.context.BlockPlaceContext context)
    • getStrength

      public float getStrength(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
      Description copied from interface: MultiPart
      Return a value indicating how hard this part is to break.

      By default, MC calculates this as (sudo code): player.digSpeedZeroToOne / block.hardness / canHarvest ? 30 : 100

      Specified by:
      getStrength in interface MultiPart
      Parameters:
      player - The player breaking the block.
      hit - The PartRayTraceResult hit result.
      Returns:
      The block strength.
    • getLightEmission

      public int getLightEmission()
      Description copied from interface: MultiPart
      The light level emitted by this part.
      Specified by:
      getLightEmission in interface MultiPart
      Returns:
      The light level.
    • getShape

      public net.minecraft.world.phys.shapes.VoxelShape getShape(net.minecraft.world.phys.shapes.CollisionContext context)
      Description copied from interface: MultiPart
      Maps to BlockBehaviour.getShape(BlockState, BlockGetter, BlockPos, CollisionContext).

      If this shape changes after initial placement, call TileMultipart.markShapeChange().

      Specified by:
      getShape in interface MultiPart
    • getCollisionShape

      public net.minecraft.world.phys.shapes.VoxelShape getCollisionShape(net.minecraft.world.phys.shapes.CollisionContext context)
      Description copied from interface: MultiPart
      Maps to BlockBehaviour.getCollisionShape(BlockState, BlockGetter, BlockPos, CollisionContext).

      If this shape changes after initial placement, call TileMultipart.markShapeChange().

      Specified by:
      getCollisionShape in interface MultiPart
    • getRenderOcclusionShape

      public net.minecraft.world.phys.shapes.VoxelShape getRenderOcclusionShape()
      Description copied from interface: MultiPart
      Maps to BlockBehaviour.getOcclusionShape(BlockState, BlockGetter, BlockPos).

      If this shape changes after initial placement, call TileMultipart.markShapeChange().

      Specified by:
      getRenderOcclusionShape in interface MultiPart
    • getInteractionShape

      public net.minecraft.world.phys.shapes.VoxelShape getInteractionShape()
      Description copied from interface: MultiPart
      Maps to BlockBehaviour.getInteractionShape(BlockState, BlockGetter, BlockPos).

      If this shape changes after initial placement, call TileMultipart.markShapeChange().

      Specified by:
      getInteractionShape in interface MultiPart
    • getOcclusionShape

      public net.minecraft.world.phys.shapes.VoxelShape getOcclusionShape()
      Specified by:
      getOcclusionShape in interface NormalOcclusionPart
    • getBlockSupportShape

      public net.minecraft.world.phys.shapes.VoxelShape getBlockSupportShape()
      Description copied from interface: MultiPart
      Maps to BlockBehaviour.getBlockSupportShape(BlockState, BlockGetter, BlockPos).

      If this shape changes after initial placement, call TileMultipart.markShapeChange().

      Specified by:
      getBlockSupportShape in interface MultiPart
    • getVisualShape

      public net.minecraft.world.phys.shapes.VoxelShape getVisualShape(net.minecraft.world.phys.shapes.CollisionContext context)
      Description copied from interface: MultiPart
      Maps to BlockBehaviour.getVisualShape(BlockState, BlockGetter, BlockPos, CollisionContext).

      If this shape changes after initial placement, call TileMultipart.markShapeChange().

      Specified by:
      getVisualShape in interface MultiPart
    • occlusionTest

      public boolean occlusionTest(MultiPart nPart)
      Description copied from interface: MultiPart
      Perform an occlusion test to determine weather this part and npart can 'fit' into this block space.
      Specified by:
      occlusionTest in interface MultiPart
      Specified by:
      occlusionTest in interface NormalOcclusionPart
      Parameters:
      nPart - The part to run the test against.
      Returns:
      true if both this part and npart are able to share this block space.
    • getPlacementSound

      public net.minecraft.world.level.block.SoundType getPlacementSound(net.minecraft.world.item.context.UseOnContext context)
      Description copied from interface: MultiPart
      Used to get the sound for this part when placed.
      Specified by:
      getPlacementSound in interface MultiPart
      Parameters:
      context - The placement context.
      Returns:
      The sound, or null for no sound.
    • getBounds

      public codechicken.lib.vec.Cuboid6 getBounds()
      Specified by:
      getBounds in interface IconHitEffectsPart
    • getBreakingIcon

      public net.minecraft.client.renderer.texture.TextureAtlasSprite getBreakingIcon(PartRayTraceResult hit)
      Specified by:
      getBreakingIcon in interface IconHitEffectsPart
    • getBrokenIcon

      public net.minecraft.client.renderer.texture.TextureAtlasSprite getBrokenIcon(int side)
      Specified by:
      getBrokenIcon in interface IconHitEffectsPart