Class TileMultipart

java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
codechicken.multipart.block.TileMultipart
All Implemented Interfaces:
codechicken.lib.world.IChunkLoadTile, net.neoforged.neoforge.attachment.IAttachmentHolder, net.neoforged.neoforge.common.extensions.IBlockEntityExtension
Direct Known Subclasses:
TAnimateTickTile, TCapabilityTile, TileMultipartClient, TInventoryTile, TPartialOcclusionTile, TRedstoneTile, TSlottedTile, TTickableTile, TTileChangeTile

public class TileMultipart extends net.minecraft.world.level.block.entity.BlockEntity implements codechicken.lib.world.IChunkLoadTile
The host tile, capable of containing MultiPart instances.
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.world.level.block.entity.BlockEntity

    net.minecraft.world.level.block.entity.BlockEntity.DataComponentInput

    Nested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder

    net.neoforged.neoforge.attachment.AttachmentHolder.AsField
  • Field Summary

    Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity

    level, remove, worldPosition

    Fields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder

    ATTACHMENTS_NBT_KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
    TileMultipart(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addLandingEffects(codechicken.lib.vec.Vector3 entity, int numberOfParticles)
     
    addPart(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, MultiPart part)
    Adds a part to a block space.
    void
     
    void
     
    void
    addRunningEffects(net.minecraft.world.entity.Entity entity)
     
    void
    animateTick(net.minecraft.util.RandomSource random)
     
    void
    attack(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
     
    void
    Bind this part to an internal cache.
    boolean
     
    boolean
     
    static boolean
    canPlacePart(net.minecraft.world.item.context.UseOnContext context, MultiPart part)
     
    boolean
    Returns true if oPart can be replaced with nPart (note oPart and nPart may be the exact same object)
    void
    Remove all parts from internal cache.
    void
    This method should be used for copying all the data from the fields in that container tile.
    static void
    dropItem(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level, codechicken.lib.vec.Vector3 pos)
     
    void
    dropItems(Iterable<net.minecraft.world.item.ItemStack> items)
    Utility function for dropping items around the center of this space
    void
    entityInside(net.minecraft.world.entity.Entity entity)
     
    void
     
    static @Nullable TileMultipart
    fromNBT(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos, net.minecraft.core.HolderLookup.Provider registries)
    Creates this tile from an NBT tag
    net.minecraft.world.phys.shapes.VoxelShape
     
    <T, C> T
    getCapability(net.neoforged.neoforge.capabilities.BlockCapability<T,C> capability, C context)
    Called via our global capability registration.
    codechicken.lib.capability.CapabilityCache
     
    net.minecraft.world.item.ItemStack
     
    net.minecraft.world.phys.shapes.VoxelShape
    getCollisionShape(net.minecraft.world.phys.shapes.CollisionContext context)
     
    float
    getDestroyProgress(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
     
    int
    getDirectSignal(int side)
     
    List<net.minecraft.world.item.ItemStack>
     
    float
    getExplosionResistance(net.minecraft.world.level.Explosion explosion)
     
    net.minecraft.world.phys.shapes.VoxelShape
     
     
    net.minecraft.world.phys.shapes.VoxelShape
     
    net.minecraft.world.phys.shapes.VoxelShape
    getShape(net.minecraft.world.phys.shapes.CollisionContext context)
     
    int
    getSignal(int side)
     
    @Nullable MultiPart
    getSlottedPart(int slot)
    Blank implementation.
    final net.minecraft.nbt.CompoundTag
    getUpdateTag(net.minecraft.core.HolderLookup.Provider registries)
     
    net.minecraft.world.phys.shapes.VoxelShape
    getVisualShape(net.minecraft.world.phys.shapes.CollisionContext context)
     
    boolean
    Blank implementation
    static void
    handleDescPacket(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, codechicken.lib.data.MCDataInput packet)
    Constructs this tile and its parts from a desc packet
    void
    handleUpdateTag(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider lookupProvider)
     
    void
    harvestPart(PartRayTraceResult hit, net.minecraft.world.entity.player.Player player)
     
    void
    internalPartChange(@Nullable MultiPart part)
    Notifies parts sharing this host of a change
    boolean
     
    static boolean
    isUnobstructed(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, MultiPart part)
     
    void
    Used to load the newly accuired data from copyFrom.
    void
    Called after a tile conversion on the old tile.
    void
    Mark this block space for a render update.
    void
     
    void
    Notifies all parts not in the passed collection of a change from all the parts in the collection
    void
     
    void
    notifyNeighborChange(net.minecraft.core.Direction side)
    Helper function for calling a second level notify on a side (eg indirect power from a lever)
    void
    notifyPartChange(@Nullable MultiPart part)
    Called by parts when they have changed in some form that affects the world.
    void
    Notifies neighboring blocks that a shape has changed
    void
    Notifies neighboring blocks that this tile has changed
    boolean
     
    void
    onChunkLoad(net.minecraft.world.level.chunk.LevelChunk chunk)
     
    void
     
    void
     
    void
    onNeighborBlockChanged(net.minecraft.core.BlockPos pos)
     
    void
    onNeighborTileChange(net.minecraft.core.BlockPos neighborPos)
    Blank implementation.
    void
    Called when the Tile is marked as removed via setRemoved().
    void
     
    void
    Called when a part is added (placement).
    void
    partRemoved(MultiPart part, int p)
    Remove this part from internal cache.
    void
    recalcLight(boolean sky, boolean block)
     
    @Nullable TileMultipart
     
    @Nullable TileMultipart
     
    static boolean
    replaceable(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.item.context.UseOnContext context)
    Returns if the block at pos is replaceable (air, vines etc)
    protected void
    saveAdditional(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries)
     
    void
    Callback for parts to mark the chunk as needs saving
    void
    setLevel(net.minecraft.world.level.Level level)
     
    void
     
    final void
    setValid(boolean b)
     
    void
    stepOn(net.minecraft.world.entity.Entity entity)
     
     
    void
     
    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)
     
    net.minecraft.world.InteractionResult
    useWithoutItem(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
     
    void
    writeDesc(codechicken.lib.data.MCDataOutput packet)
    Writes the description of this tile, and all parts composing it, to packet

    Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity

    addEntityType, applyComponents, applyComponentsFromItemStack, applyImplicitComponents, clearRemoved, collectComponents, collectImplicitComponents, components, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPersistentData, getPosFromTag, getType, getUpdatePacket, hasLevel, isRemoved, isValidBlockState, loadAdditional, loadCustomOnly, loadStatic, loadWithComponents, onlyOpCanSetNbt, parseCustomNameSafe, removeComponentsFromTag, removeData, saveCustomAndMetadata, saveCustomOnly, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setComponents, setData, triggerEvent

    Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder

    deserializeAttachments, getData, getExistingData, hasAttachments, hasData, serializeAttachments

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder

    getData, getExistingData, hasData, removeData, setData

    Methods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension

    getModelData, hasCustomOutlineRendering, invalidateCapabilities, onDataPacket, onLoad, requestModelDataUpdate
  • Constructor Details

    • TileMultipart

      public TileMultipart(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
  • Method Details

    • getPartList

      public List<MultiPart> getPartList()
    • from

      public void from(TileMultipart that)
    • copyFrom

      public void copyFrom(TileMultipart that)
      This method should be used for copying all the data from the fields in that container tile. This method will be automatically generated on java tile traits with fields if it is not overridden.
    • loadFrom

      public void loadFrom(TileMultipart that)
      Used to load the newly accuired data from copyFrom.
    • loadTo

      public void loadTo(TileMultipart that)
      Called after a tile conversion on the old tile. At the time of this call, this tile is no longer valid. This is called before receiveFrom is called on the new tile.

      Provided for trait overrides, do not call externally.

      Parameters:
      that - The new tile
    • clearParts

      public void clearParts()
      Remove all parts from internal cache.

      Provided for trait overrides, do not call externally.

    • bindPart

      public void bindPart(MultiPart part)
      Bind this part to an internal cache.

      Provided for trait overrides, do not call externally.

    • partAdded

      public void partAdded(MultiPart part)
      Called when a part is added (placement).

      Provided for trait overrides, do not call externally.

    • partRemoved

      public void partRemoved(MultiPart part, int p)
      Remove this part from internal cache.

      Provided for trait overrides, do not call externally.

    • getWeakChanges

      public boolean getWeakChanges()
      Blank implementation

      Overriden by TTileChangeTile

    • onNeighborTileChange

      public void onNeighborTileChange(net.minecraft.core.BlockPos neighborPos)
      Blank implementation.

      Overriden by TTileChangeTile

    • getSlottedPart

      @Nullable public @Nullable MultiPart getSlottedPart(int slot)
      Blank implementation.

      Overriden by TSlottedTile

    • onRemoved

      public void onRemoved()
      Called when the Tile is marked as removed via setRemoved().

      Provided for trait overrides, do not call externally.

    • getCapability

      @Nullable public <T, C> T getCapability(net.neoforged.neoforge.capabilities.BlockCapability<T,C> capability, C context)
      Called via our global capability registration.

      Implemented by TCapabilityTile

      Parameters:
      capability - The capability.
      context - The capability context.
      Returns:
      The capability instance.
    • saveAdditional

      protected void saveAdditional(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries)
      Overrides:
      saveAdditional in class net.minecraft.world.level.block.entity.BlockEntity
    • getUpdateTag

      public final net.minecraft.nbt.CompoundTag getUpdateTag(net.minecraft.core.HolderLookup.Provider registries)
      Overrides:
      getUpdateTag in class net.minecraft.world.level.block.entity.BlockEntity
    • handleUpdateTag

      public void handleUpdateTag(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider lookupProvider)
      Specified by:
      handleUpdateTag in interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
    • writeDesc

      public void writeDesc(codechicken.lib.data.MCDataOutput packet)
      Writes the description of this tile, and all parts composing it, to packet
    • canAddPart

      public boolean canAddPart(MultiPart part)
    • canReplacePart

      public boolean canReplacePart(MultiPart oPart, MultiPart nPart)
      Returns true if oPart can be replaced with nPart (note oPart and nPart may be the exact same object)

      This function should be used for testing if a part can change it's shape (eg. rotation, expansion, cable connection) For example, to test whether a cable part can connect to it's neighbor: 1. Set the cable part's bounding boxes as if the connection is established 2. Call canReplacePart(part, part) 3. If canReplacePart succeeds, perform connection, else, revert bounding box

    • occlusionTest

      public boolean occlusionTest(Iterable<MultiPart> parts, MultiPart nPart)
    • addPart_impl

      public void addPart_impl(MultiPart part)
    • addPart_do

      public void addPart_do(MultiPart part)
    • remPart

      @Nullable public @Nullable TileMultipart remPart(MultiPart part)
    • remPart_impl

      @Nullable public @Nullable TileMultipart remPart_impl(MultiPart part)
    • setValid

      public final void setValid(boolean b)
    • setRemoved

      public void setRemoved()
      Overrides:
      setRemoved in class net.minecraft.world.level.block.entity.BlockEntity
    • getShape

      public net.minecraft.world.phys.shapes.VoxelShape getShape(net.minecraft.world.phys.shapes.CollisionContext context)
    • getCollisionShape

      public net.minecraft.world.phys.shapes.VoxelShape getCollisionShape(net.minecraft.world.phys.shapes.CollisionContext context)
    • getRenderOcclusionShape

      public net.minecraft.world.phys.shapes.VoxelShape getRenderOcclusionShape()
    • getInteractionShape

      public net.minecraft.world.phys.shapes.VoxelShape getInteractionShape()
    • getBlockSupportShape

      public net.minecraft.world.phys.shapes.VoxelShape getBlockSupportShape()
    • getVisualShape

      public net.minecraft.world.phys.shapes.VoxelShape getVisualShape(net.minecraft.world.phys.shapes.CollisionContext context)
    • harvestPart

      public void harvestPart(PartRayTraceResult hit, net.minecraft.world.entity.player.Player player)
    • getDrops

      public List<net.minecraft.world.item.ItemStack> getDrops()
    • getCloneStack

      public net.minecraft.world.item.ItemStack getCloneStack(PartRayTraceResult hit)
    • getExplosionResistance

      public float getExplosionResistance(net.minecraft.world.level.Explosion explosion)
    • getDestroyProgress

      public float getDestroyProgress(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
    • onChunkUnloaded

      public void onChunkUnloaded()
      Specified by:
      onChunkUnloaded in interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
    • onChunkLoad

      public void onChunkLoad(net.minecraft.world.level.chunk.LevelChunk chunk)
      Specified by:
      onChunkLoad in interface codechicken.lib.world.IChunkLoadTile
    • onMoved

      public void onMoved()
    • useItemOn

      public 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)
    • useWithoutItem

      public net.minecraft.world.InteractionResult useWithoutItem(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
    • attack

      public void attack(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit)
    • setLevel

      public void setLevel(net.minecraft.world.level.Level level)
      Overrides:
      setLevel in class net.minecraft.world.level.block.entity.BlockEntity
    • entityInside

      public void entityInside(net.minecraft.world.entity.Entity entity)
    • stepOn

      public void stepOn(net.minecraft.world.entity.Entity entity)
    • onNeighborBlockChanged

      public void onNeighborBlockChanged(net.minecraft.core.BlockPos pos)
    • canConnectRedstone

      public boolean canConnectRedstone(int side)
    • getDirectSignal

      public int getDirectSignal(int side)
    • getSignal

      public int getSignal(int side)
    • animateTick

      public void animateTick(net.minecraft.util.RandomSource random)
    • isClientTile

      public boolean isClientTile()
    • tile

      public TileMultipart tile()
      Returns:
      The current tile. For traits.
    • addLandingEffects

      public void addLandingEffects(codechicken.lib.vec.Vector3 entity, int numberOfParticles)
    • addRunningEffects

      public void addRunningEffects(net.minecraft.world.entity.Entity entity)
    • notifyTileChange

      public void notifyTileChange()
      Notifies neighboring blocks that this tile has changed
    • notifyShapeChange

      public void notifyShapeChange()
      Notifies neighboring blocks that a shape has changed
    • notifyPartChange

      public void notifyPartChange(@Nullable @Nullable MultiPart part)
      Called by parts when they have changed in some form that affects the world. Notifies neighbor blocks, the world and parts that share this host and recalculates lighting
    • internalPartChange

      public void internalPartChange(@Nullable @Nullable MultiPart part)
      Notifies parts sharing this host of a change
    • multiPartChange

      public void multiPartChange(Collection<MultiPart> parts)
      Notifies all parts not in the passed collection of a change from all the parts in the collection
    • setChanged

      public void setChanged()
      Callback for parts to mark the chunk as needs saving
      Overrides:
      setChanged in class net.minecraft.world.level.block.entity.BlockEntity
    • markRender

      public void markRender()
      Mark this block space for a render update.
    • updateLight

      public void updateLight()
    • recalcLight

      public void recalcLight(boolean sky, boolean block)
    • markShapeChange

      public void markShapeChange()
    • notifyNeighborChange

      public void notifyNeighborChange(net.minecraft.core.Direction side)
      Helper function for calling a second level notify on a side (eg indirect power from a lever)
    • notifyNeighborChange

      public void notifyNeighborChange(int side)
    • dropItems

      public void dropItems(Iterable<net.minecraft.world.item.ItemStack> items)
      Utility function for dropping items around the center of this space
    • operate

      public void operate(Consumer<MultiPart> cons)
    • getCapCache

      public codechicken.lib.capability.CapabilityCache getCapCache()
    • canPlacePart

      public static boolean canPlacePart(net.minecraft.world.item.context.UseOnContext context, MultiPart part)
    • isUnobstructed

      public static boolean isUnobstructed(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, MultiPart part)
    • replaceable

      public static boolean replaceable(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.item.context.UseOnContext context)
      Returns if the block at pos is replaceable (air, vines etc)
    • addPart

      public static TileMultipart addPart(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, MultiPart part)
      Adds a part to a block space. canPlacePart should always be called first. The addition of parts on the client is handled internally.
    • handleDescPacket

      public static void handleDescPacket(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, codechicken.lib.data.MCDataInput packet)
      Constructs this tile and its parts from a desc packet
    • fromNBT

      @Nullable public static @Nullable TileMultipart fromNBT(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos, net.minecraft.core.HolderLookup.Provider registries)
      Creates this tile from an NBT tag
    • dropItem

      public static void dropItem(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level, codechicken.lib.vec.Vector3 pos)