Package forestry.api.core.multiblock
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.DataComponentInputNested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
net.neoforged.neoforge.attachment.AttachmentHolder.AsFieldNested 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, worldPositionFields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEY -
Constructor Summary
ConstructorsConstructorDescriptionMultiblockTileEntityBase(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 TypeMethodDescriptionvoidprotected voiddecodeDescriptionPacket(net.minecraft.nbt.CompoundTag packetData) Reads tile/payload data from the description packet.protected voidencodeDescriptionPacket(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.BlockPosprotected net.minecraft.nbt.CompoundTaggetStash()net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacketnet.minecraft.nbt.CompoundTaggetUpdateTag(net.minecraft.core.HolderLookup.Provider registries) voidhandleUpdateTag(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) protected booleanfinal voidonDataPacket(net.minecraft.network.Connection network, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet, net.minecraft.core.HolderLookup.Provider registries) abstract voidonMachineAssembled(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 voidCalled when the machine is broken for game reasons, e.g.voidsetAnchorPos(net.minecraft.core.BlockPos anchorPos) protected voidsetStash(net.minecraft.nbt.CompoundTag stash) protected voidsetUnloading(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, triggerEventMethods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachmentsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncDataMethods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
getModelData, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onLoad, requestModelDataUpdateMethods 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
- Specified by:
getMultiblockLogicin interfaceIMultiblockComponent- 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:IMultiblockComponentCalled 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:
onMachineAssembledin interfaceIMultiblockComponent- Parameters:
multiblockController- The controller to which this part is being assembled
-
onMachineBroken
public abstract void onMachineBroken()Description copied from interface:IMultiblockComponentCalled when the machine is broken for game reasons, e.g. a player removed a block or an explosion occurred.- Specified by:
onMachineBrokenin interfaceIMultiblockComponent
-
getUpdatePacket
public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket getUpdatePacket()- Overrides:
getUpdatePacketin classnet.minecraft.world.level.block.entity.BlockEntity
-
getUpdateTag
public net.minecraft.nbt.CompoundTag getUpdateTag(net.minecraft.core.HolderLookup.Provider registries) - Overrides:
getUpdateTagin classnet.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:
onDataPacketin interfacenet.neoforged.neoforge.common.extensions.IBlockEntityExtension
-
handleUpdateTag
public void handleUpdateTag(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) - Specified by:
handleUpdateTagin interfacenet.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.
-