Class MultiblockTileEntityBase<T extends IMultiblockLogic>

java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
forestry.api.core.multiblock.MultiblockTileEntityBase<T>
All Implemented Interfaces:
IMultiblockComponent, net.neoforged.neoforge.attachment.IAttachmentHolder, net.neoforged.neoforge.common.extensions.IBlockEntityExtension

public abstract class MultiblockTileEntityBase<T extends IMultiblockLogic> extends net.minecraft.world.level.block.entity.BlockEntity implements IMultiblockComponent
Base logic class for multiblock-connected tile entities.

After the engine rewrite (plan Phase 2; spec 6, 7) this base no longer delegates to a heavyweight "multiblock logic" object. Instead each member stores its anchorPos (the holder of the shared payload, spec 6.1) and resolves its controller through the MultiblockIndex. The shared-payload persistence, the anchor-only ticker, the legacy/payload stash, the break-vs-unload disambiguation, and the network sync are implemented by the concrete MultiblockTileEntityForestry subclass. This class only holds the common state and the thin IMultiblockLogic accessor.

  • 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

    Nested classes/interfaces inherited from interface forestry.api.core.multiblock.IMultiblockComponent

    IMultiblockComponent.HasInventory
  • 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
    MultiblockTileEntityBase(net.minecraft.world.level.block.entity.BlockEntityType<?> tileEntityType, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, T multiblockLogic)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected void
    decodeDescriptionPacket(net.minecraft.nbt.CompoundTag packetData)
    Reads tile/payload data from the description packet.
    protected void
    encodeDescriptionPacket(net.minecraft.nbt.CompoundTag packetData)
    Writes tile/payload data to the description packet (overridden by the holder to add the controller payload, spec 9).
    net.minecraft.core.BlockPos
     
     
    protected net.minecraft.nbt.CompoundTag
     
    net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket
     
    net.minecraft.nbt.CompoundTag
    getUpdateTag(net.minecraft.core.HolderLookup.Provider registries)
     
    void
    handleUpdateTag(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries)
     
    protected boolean
     
    final void
    onDataPacket(net.minecraft.network.Connection network, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet, net.minecraft.core.HolderLookup.Provider registries)
     
    abstract void
    onMachineAssembled(IMultiblockController multiblockController, net.minecraft.core.BlockPos minCoord, net.minecraft.core.BlockPos maxCoord)
    Called when a machine is fully assembled from the disassembled state, meaning it was constructed by a player/entity action, not by chunks loading.
    abstract void
    Called when the machine is broken for game reasons, e.g.
    void
    setAnchorPos(net.minecraft.core.BlockPos anchorPos)
     
    protected void
    setStash(net.minecraft.nbt.CompoundTag stash)
     
    protected void
    setUnloading(boolean unloading)
     

    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, hasLevel, isRemoved, isValidBlockState, loadAdditional, loadCustomOnly, loadStatic, loadWithComponents, onlyOpCanSetNbt, parseCustomNameSafe, removeComponentsFromTag, removeData, saveAdditional, saveCustomAndMetadata, saveCustomOnly, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setChanged, setComponents, setData, setLevel, setRemoved, syncData, triggerEvent

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

    deserializeAttachments, getData, getExistingDataOrNull, 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, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncData

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

    getModelData, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onLoad, requestModelDataUpdate

    Methods inherited from interface forestry.api.core.multiblock.IMultiblockComponent

    getBlockPos, getOwner
  • Constructor Details

    • MultiblockTileEntityBase

      public MultiblockTileEntityBase(net.minecraft.world.level.block.entity.BlockEntityType<?> tileEntityType, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, T multiblockLogic)
  • Method Details

    • getMultiblockLogic

      public T getMultiblockLogic()
      Specified by:
      getMultiblockLogic in interface IMultiblockComponent
      Returns:
      the multiblock logic for this part
    • getAnchorPos

      @Nullable public net.minecraft.core.BlockPos getAnchorPos()
    • setAnchorPos

      public void setAnchorPos(@Nullable net.minecraft.core.BlockPos anchorPos)
    • getStash

      @Nullable protected net.minecraft.nbt.CompoundTag getStash()
    • setStash

      protected void setStash(@Nullable net.minecraft.nbt.CompoundTag stash)
    • clearStash

      public void clearStash()
    • isUnloading

      protected boolean isUnloading()
    • setUnloading

      protected void setUnloading(boolean unloading)
    • onMachineAssembled

      public abstract void onMachineAssembled(IMultiblockController multiblockController, net.minecraft.core.BlockPos minCoord, net.minecraft.core.BlockPos maxCoord)
      Description copied from interface: IMultiblockComponent
      Called when a machine is fully assembled from the disassembled state, meaning it was constructed by a player/entity action, not by chunks loading. Note that, for non-square machines, the min/max coordinates may not actually be part of the machine! They form an outer bounding box for the whole machine itself.
      Specified by:
      onMachineAssembled in interface IMultiblockComponent
      Parameters:
      multiblockController - The controller to which this part is being assembled
    • onMachineBroken

      public abstract void onMachineBroken()
      Description copied from interface: IMultiblockComponent
      Called when the machine is broken for game reasons, e.g. a player removed a block or an explosion occurred.
      Specified by:
      onMachineBroken in interface IMultiblockComponent
    • getUpdatePacket

      public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket getUpdatePacket()
      Overrides:
      getUpdatePacket in class net.minecraft.world.level.block.entity.BlockEntity
    • getUpdateTag

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

      public final void onDataPacket(net.minecraft.network.Connection network, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet, net.minecraft.core.HolderLookup.Provider registries)
      Specified by:
      onDataPacket in interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
    • handleUpdateTag

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

      protected void encodeDescriptionPacket(net.minecraft.nbt.CompoundTag packetData)
      Writes tile/payload data to the description packet (overridden by the holder to add the controller payload, spec 9).
    • decodeDescriptionPacket

      protected void decodeDescriptionPacket(net.minecraft.nbt.CompoundTag packetData)
      Reads tile/payload data from the description packet.