Interface MultiPart

All Known Subinterfaces:
AnimateTickPart, CapabilityProviderPart, EdgePart, FacePart, FaceRedstonePart, IconHitEffectsPart, IMicroOcclusion, IMicroShrinkRender, MaskedRedstonePart, ModelRenderPart, NeighborTileChangePart, NormalOcclusionPart, PartialOcclusionPart, RandomTickPart, RedstonePart, SlottedPart
All Known Implementing Classes:
BaseMultipart, ButtonPart, ButtonPart.AcaciaButtonPart, ButtonPart.BirchButtonPart, ButtonPart.CrimsonButtonPart, ButtonPart.DarkOakButtonPart, ButtonPart.JungleButtonPart, ButtonPart.OakButtonPart, ButtonPart.PolishedBlackstoneButtonPart, ButtonPart.SpruceButtonPart, ButtonPart.StoneButtonPart, ButtonPart.WarpedButtonPart, CornerMicroblockPart, EdgeMicroblockPart, FaceMicroblockPart, HollowMicroblockPart, LeverPart, McSidedStatePart, McStatePart, MicroblockPart, PostMicroblockPart, RedstoneTorchPart, SoulTorchPart, StandardMicroblockPart, TorchPart

public interface MultiPart
Represents a Multipart.

All Multipart implementations are expected to extend from BaseMultipart.

Created by covers1624 on 6/6/22.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    addDestroyEffects(PartRayTraceResult hit, net.minecraft.client.particle.ParticleEngine engine)
    Add particles and other effects when a player finishes breaking this part.
    default void
    addHitEffects(PartRayTraceResult hit, net.minecraft.client.particle.ParticleEngine engine)
    Add particles and other effects when a player is mining this part.
    default void
    addLandingEffects(PartRayTraceResult hit, codechicken.lib.vec.Vector3 entity, int numberOfParticles)
    Add particles and other effects when a player lands on this part.
    default void
    addRunningEffects(PartRayTraceResult hit, net.minecraft.world.entity.Entity entity)
    Add particles and other effects when a player runs over this part.
    default codechicken.lib.capability.CapabilityCache
    Get the global CapabilityCache for this block.
    default void
    click(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit, net.minecraft.world.item.ItemStack stack)
    Called on block left click.
    default net.minecraft.world.phys.shapes.VoxelShape
    Maps to BlockBehaviour.getBlockSupportShape(BlockState, BlockGetter, BlockPos).
    default net.minecraft.world.item.ItemStack
    Return the ItemStack for pick-block(usually middle click) function.
    default net.minecraft.world.phys.shapes.VoxelShape
    getCollisionShape(net.minecraft.world.phys.shapes.CollisionContext context)
    Maps to BlockBehaviour.getCollisionShape(BlockState, BlockGetter, BlockPos, CollisionContext).
    default Iterable<net.minecraft.world.item.ItemStack>
    Return a list of ItemStacks that should be dropped when this part is destroyed.
    default float
    getExplosionResistance(net.minecraft.world.level.Explosion explosion)
    Get the explosion resistance for this part.
    default net.minecraft.world.phys.shapes.VoxelShape
    Maps to BlockBehaviour.getInteractionShape(BlockState, BlockGetter, BlockPos).
    default int
    The light level emitted by this part.
    default net.neoforged.neoforge.client.model.data.ModelData
    Companion to IBlockEntityExtension.getModelData(), except for this part.
    default @Nullable net.minecraft.world.level.block.SoundType
    getPlacementSound(net.minecraft.world.item.context.UseOnContext context)
    Used to get the sound for this part when placed.
    default codechicken.lib.vec.Cuboid6
    Gets the bounds of this part for Frustum culling.
    default net.minecraft.world.phys.shapes.VoxelShape
    Maps to BlockBehaviour.getOcclusionShape(BlockState, BlockGetter, BlockPos).
    default net.minecraft.world.phys.shapes.VoxelShape
    getShape(net.minecraft.world.phys.shapes.CollisionContext context)
    Maps to BlockBehaviour.getShape(BlockState, BlockGetter, BlockPos, CollisionContext).
    default float
    getStrength(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
    Return a value indicating how hard this part is to break.
    Returns the MultipartType registry entry for this part.
    default net.minecraft.world.phys.shapes.VoxelShape
    getVisualShape(net.minecraft.world.phys.shapes.CollisionContext context)
    Maps to BlockBehaviour.getVisualShape(BlockState, BlockGetter, BlockPos, CollisionContext).
    default void
    harvest(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
    Harvest this part, removing it from the container TileMultipart and dropping any items if necessary.
    default boolean
     
    boolean
     
    default void
    Called when this part is converted from a normal block or tile, before the original tile has been replaced.
    default net.minecraft.world.level.Level
    Get the Level the container TileMultipart is inside.
    default void
    load(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries)
    Load this part from a CompoundTag.
    default boolean
    Perform an occlusion test to determine weather this part and npart can 'fit' into this block space.
    default void
    Called when this part is added to the block space.
    default void
    onChunkLoad(net.minecraft.world.level.chunk.LevelChunk chunk)
    Called when the containing chunk is loaded on the server.
    default void
    Called when the containing chunk is unloaded on the server.
    default void
    Called when this part is converted from a normal block or tile.
    default void
    onEntityCollision(net.minecraft.world.entity.Entity entity)
    Called when an entity is within this block space.
    default void
    onEntityStanding(net.minecraft.world.entity.Entity entity)
    Called when an entity is standing on this block space.
    default void
    Called when this part has been moved without a save/load.
    default void
    onNeighborBlockChanged(net.minecraft.core.BlockPos neighbor)
    Called when a neighbor block changes.
    default void
    onPartChanged(@Nullable MultiPart part)
    Called when a part is added or removed from this block space.
    default void
    Called when this part is removed from the block space.
    default void
    Called when this part joins the world.
    default void
    Called when this part separates from the world.
    default net.minecraft.core.BlockPos
    pos()
    The BlockPos of the container TileMultipart.
    default void
    Called just before this part is actually removed from the container tile.
    default void
    readDesc(codechicken.lib.data.MCDataInput packet)
    Fill out this part with the description information contained in packet.
    default void
    readUpdate(codechicken.lib.data.MCDataInput packet)
    default void
    save(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries)
    Save this part to a CompoundTag.
    default void
    Called when a scheduled tick is executed.
    default void
    scheduleTick(int ticks)
    Set a scheduledTick() callback for this part ticks in the future.
    default void
    sendUpdate(Consumer<codechicken.lib.data.MCDataOutput> func)
    Send a packet to this part's client-side counterpart.
    Get the underlying TileMultipart this part is inside.
    default net.minecraft.world.ItemInteractionResult
    useItemOn(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, PartRayTraceResult hit, net.minecraft.world.InteractionHand hand)
    Called on block right-click with an item.
    default net.minecraft.world.InteractionResult
    useWithoutItem(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
    Called on block right-click without an item.
    default void
    writeDesc(codechicken.lib.data.MCDataOutput packet)
    Write all the data required to describe a client version of this part to the packet.
  • Method Details

    • tile

      @Contract(pure=true) TileMultipart tile()
      Get the underlying TileMultipart this part is inside.

      The implementation of this function is INTERNAL, it is expected that all Multiparts extend from BaseMultipart.

      Returns:
      The TileMultipart.
    • hasTile

      boolean hasTile()
      Returns:
      If this part has an attached TileMultipart.
    • level

      @Contract(pure=true) default net.minecraft.world.level.Level level()
      Get the Level the container TileMultipart is inside.
      Returns:
      The Level.
    • hasLevel

      default boolean hasLevel()
      Returns:
      If this part has a Level attached.
    • pos

      @Contract(pure=true) default net.minecraft.core.BlockPos pos()
      The BlockPos of the container TileMultipart.
      Returns:
      The BlockPos.
    • capCache

      @Contract(pure=true) default codechicken.lib.capability.CapabilityCache capCache()
      Get the global CapabilityCache for this block.
      Returns:
      The CapabilityCache.
    • getType

      @Contract(pure=true) MultipartType<?> getType()
      Returns the MultipartType registry entry for this part.
      Returns:
      The MultipartType.
      See Also:
    • writeDesc

      default void writeDesc(codechicken.lib.data.MCDataOutput packet)
      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.

      Parameters:
      packet - The packet to write to.
    • readDesc

      default void readDesc(codechicken.lib.data.MCDataInput packet)
      Fill out this part with the description information contained in packet.

      Companion method to writeDesc(MCDataOutput).

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

      Parameters:
      packet - The packet to read from.
    • save

      default void save(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries)
      Save this part to a CompoundTag.

      Only called server-side.

      Parameters:
      tag - The tag to write to.
    • load

      default void load(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries)
      Load this part from a CompoundTag.

      Only called server-side.

      Parameters:
      tag - The tag to read from.
    • sendUpdate

      default void sendUpdate(Consumer<codechicken.lib.data.MCDataOutput> func)
      Send a packet to this part's client-side counterpart.
      Parameters:
      func - The callback to write the packet data.
    • readUpdate

      default void readUpdate(codechicken.lib.data.MCDataInput packet)
      Parameters:
      packet - THe packet to read.
    • occlusionTest

      default boolean occlusionTest(MultiPart npart)
      Perform an occlusion test to determine weather this part and npart can 'fit' into this block space.
      Parameters:
      npart - The part to run the test against.
      Returns:
      true if both this part and npart are able to share this block space.
    • getShape

      default net.minecraft.world.phys.shapes.VoxelShape getShape(net.minecraft.world.phys.shapes.CollisionContext context)
      Maps to BlockBehaviour.getShape(BlockState, BlockGetter, BlockPos, CollisionContext).

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

    • getCollisionShape

      default net.minecraft.world.phys.shapes.VoxelShape getCollisionShape(net.minecraft.world.phys.shapes.CollisionContext context)
      Maps to BlockBehaviour.getCollisionShape(BlockState, BlockGetter, BlockPos, CollisionContext).

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

    • getRenderOcclusionShape

      default net.minecraft.world.phys.shapes.VoxelShape getRenderOcclusionShape()
      Maps to BlockBehaviour.getOcclusionShape(BlockState, BlockGetter, BlockPos).

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

    • getInteractionShape

      default net.minecraft.world.phys.shapes.VoxelShape getInteractionShape()
      Maps to BlockBehaviour.getInteractionShape(BlockState, BlockGetter, BlockPos).

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

    • getBlockSupportShape

      default net.minecraft.world.phys.shapes.VoxelShape getBlockSupportShape()
      Maps to BlockBehaviour.getBlockSupportShape(BlockState, BlockGetter, BlockPos).

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

    • getVisualShape

      default net.minecraft.world.phys.shapes.VoxelShape getVisualShape(net.minecraft.world.phys.shapes.CollisionContext context)
      Maps to BlockBehaviour.getVisualShape(BlockState, BlockGetter, BlockPos, CollisionContext).

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

    • harvest

      default void harvest(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
      Harvest this part, removing it from the container TileMultipart and dropping any items if necessary.
      Parameters:
      player - The Player harvesting the part.
      hit - The PartRayTraceResult hit result.
    • getDrops

      default Iterable<net.minecraft.world.item.ItemStack> getDrops()
      Return a list of ItemStacks that should be dropped when this part is destroyed.
      Returns:
      The ItemStacks.
    • getCloneStack

      default net.minecraft.world.item.ItemStack getCloneStack(PartRayTraceResult hit)
      Return the ItemStack for pick-block(usually middle click) function.
      Parameters:
      hit - The PartRayTraceResult hit result.
      Returns:
      The ItemStack pick result.
    • getExplosionResistance

      default float getExplosionResistance(net.minecraft.world.level.Explosion explosion)
      Get the explosion resistance for this part.

      The explosion resistance for the host TileMultipart is the maximum explosion resistance for all contained parts.

      Parameters:
      explosion - The Explosion.
      Returns:
      The resistance.
    • getLightEmission

      default int getLightEmission()
      The light level emitted by this part.
      Returns:
      The light level.
    • getStrength

      default float getStrength(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
      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

      Parameters:
      player - The player breaking the block.
      hit - The PartRayTraceResult hit result.
      Returns:
      The block strength.
    • getPlacementSound

      @Nullable default @Nullable net.minecraft.world.level.block.SoundType getPlacementSound(net.minecraft.world.item.context.UseOnContext context)
      Used to get the sound for this part when placed.
      Parameters:
      context - The placement context.
      Returns:
      The sound, or null for no sound.
    • onAdded

      default void onAdded()
      Called when this part is added to the block space.
    • preRemove

      default void preRemove()
      Called just before this part is actually removed from the container tile.
    • onRemoved

      default void onRemoved()
      Called when this part is removed from the block space.
    • onChunkLoad

      default void onChunkLoad(net.minecraft.world.level.chunk.LevelChunk chunk)
      Called when the containing chunk is loaded on the server.
      Parameters:
      chunk - The chunk.
    • onChunkUnload

      default void onChunkUnload()
      Called when the containing chunk is unloaded on the server.
    • onWorldSeparate

      default void onWorldSeparate()
      Called when this part separates from the world.

      This may be due to removal, chunk unload, etc.

      Use this to sync with external data structures.

      Called client and server side.

    • onWorldJoin

      default void onWorldJoin()
      Called when this part joins the world.

      This may be due to placement, chunk load, frames, etc.

      Use this to sync with external data structures.

      Called client and server side.

    • onConverted

      default void onConverted()
      Called when this part is converted from a normal block or tile.

      Only applicable if a converter has been registered.

      See Also:
    • invalidateConvertedTile

      default void invalidateConvertedTile()
      Called when this part is converted from a normal block or tile, before the original tile has been replaced.

      Use this to clear inventories, etc, from the old tile.

      Only applicable if a converter has been registered.

    • onMoved

      default void onMoved()
      Called when this part has been moved without a save/load.
    • useItemOn

      default net.minecraft.world.ItemInteractionResult useItemOn(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, PartRayTraceResult hit, net.minecraft.world.InteractionHand hand)
      Called on block right-click with an item.

      This should not modify the part client-side.

      Parameters:
      stack - The ItemStack held by the player.
      player - The player that right-clicked the part.
      hit - The PartRayTraceResult hit result.
      hand - The InteractionHand the player is using.
      Returns:
      The ItemInteractionResult.
    • useWithoutItem

      default net.minecraft.world.InteractionResult useWithoutItem(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
      Called on block right-click without an item.

      This should not modify the part client-side.

      Parameters:
      player - The player that right-clicked the part.
      hit - The PartRayTraceResult hit result.
      Returns:
      The InteractionResult.
    • click

      default void click(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit, net.minecraft.world.item.ItemStack stack)
      Called on block left click.
      Parameters:
      player - The player who clicked on this part.
      hit - The PartRayTraceResult hit result.
      stack - The ItemStack held by the player.
    • onEntityCollision

      default void onEntityCollision(net.minecraft.world.entity.Entity entity)
      Called when an entity is within this block space.

      The entity may not actually be colliding with this part.

      Parameters:
      entity - The Entity.
    • onEntityStanding

      default void onEntityStanding(net.minecraft.world.entity.Entity entity)
      Called when an entity is standing on this block space.

      The entity may not actually be standing on this part.

      Parameters:
      entity - The Entity.
    • onNeighborBlockChanged

      default void onNeighborBlockChanged(net.minecraft.core.BlockPos neighbor)
      Called when a neighbor block changes.
      Parameters:
      neighbor - The neighbor block.
    • onPartChanged

      default void onPartChanged(@Nullable @Nullable MultiPart part)
      Called when a part is added or removed from this block space.
      Parameters:
      part - The part which changed. May be null if multiple parts are changed.
    • scheduledTick

      default void scheduledTick()
      Called when a scheduled tick is executed.
      See Also:
    • scheduleTick

      default void scheduleTick(int ticks)
      Set a scheduledTick() callback for this part ticks in the future.

      ticks is a world time offset. If the chunk containing this part is not loaded at the time of this scheduled tick, it may fire immediately on load.

      Parameters:
      ticks - The number of ticks in the future to fire the callback.
    • addHitEffects

      default void addHitEffects(PartRayTraceResult hit, net.minecraft.client.particle.ParticleEngine engine)
      Add particles and other effects when a player is mining this part.
      Parameters:
      hit - The PartRayTraceResult hit result.
      engine - The ParticleEngine to spawn particles.
    • addDestroyEffects

      default void addDestroyEffects(PartRayTraceResult hit, net.minecraft.client.particle.ParticleEngine engine)
      Add particles and other effects when a player finishes breaking this part.
      Parameters:
      hit - The PartRayTraceResult hit result.
      engine - The ParticleEngine to spawn particles.
    • addLandingEffects

      default void addLandingEffects(PartRayTraceResult hit, codechicken.lib.vec.Vector3 entity, int numberOfParticles)
      Add particles and other effects when a player lands on this part.
      Parameters:
      hit - The hit directly bellow the entities feet.
      entity - The position of the entity.
      numberOfParticles - The number of particles to spawn.
    • addRunningEffects

      default void addRunningEffects(PartRayTraceResult hit, net.minecraft.world.entity.Entity entity)
      Add particles and other effects when a player runs over this part.

      This is called on both the client and the server.

      Parameters:
      hit - The hit directly bellow the players feet.
      entity - The entity running.
    • getRenderBounds

      default codechicken.lib.vec.Cuboid6 getRenderBounds()
      Gets the bounds of this part for Frustum culling. Bounds are relative to the current part's coordinates.
      Returns:
      The bounds.
    • getModelData

      default net.neoforged.neoforge.client.model.data.ModelData getModelData()
      Companion to IBlockEntityExtension.getModelData(), except for this part.

      Called to obtain any model data for this part.

      Call tile().TileMultipart.markRender() to ask for your model data to be re-queried.

      Returns:
      The model data.