Class 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
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.DataComponentInputNested 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, worldPositionFields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEY -
Constructor Summary
ConstructorsConstructorDescriptionTileMultipart(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLandingEffects(codechicken.lib.vec.Vector3 entity, int numberOfParticles) static TileMultipartAdds a part to a block space.voidaddPart_do(MultiPart part) voidaddPart_impl(MultiPart part) voidaddRunningEffects(net.minecraft.world.entity.Entity entity) voidanimateTick(net.minecraft.util.RandomSource random) voidattack(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit) voidBind this part to an internal cache.booleancanAddPart(MultiPart part) booleancanConnectRedstone(int side) static booleancanPlacePart(net.minecraft.world.item.context.UseOnContext context, MultiPart part) booleancanReplacePart(MultiPart oPart, MultiPart nPart) Returns true if oPart can be replaced with nPart (note oPart and nPart may be the exact same object)voidRemove all parts from internal cache.voidcopyFrom(TileMultipart that) This method should be used for copying all the data from the fields in that container tile.static voiddropItem(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level, codechicken.lib.vec.Vector3 pos) voidUtility function for dropping items around the center of this spacevoidentityInside(net.minecraft.world.entity.Entity entity) voidfrom(TileMultipart that) static @Nullable TileMultipartfromNBT(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos, net.minecraft.core.HolderLookup.Provider registries) Creates this tile from an NBT tagnet.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.CapabilityCachenet.minecraft.world.item.ItemStacknet.minecraft.world.phys.shapes.VoxelShapegetCollisionShape(net.minecraft.world.phys.shapes.CollisionContext context) floatgetDestroyProgress(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit) intgetDirectSignal(int side) List<net.minecraft.world.item.ItemStack> getDrops()floatgetExplosionResistance(net.minecraft.world.level.Explosion explosion) net.minecraft.world.phys.shapes.VoxelShapenet.minecraft.world.phys.shapes.VoxelShapenet.minecraft.world.phys.shapes.VoxelShapegetShape(net.minecraft.world.phys.shapes.CollisionContext context) intgetSignal(int side) @Nullable MultiPartgetSlottedPart(int slot) Blank implementation.final net.minecraft.nbt.CompoundTaggetUpdateTag(net.minecraft.core.HolderLookup.Provider registries) net.minecraft.world.phys.shapes.VoxelShapegetVisualShape(net.minecraft.world.phys.shapes.CollisionContext context) booleanBlank implementationstatic voidhandleDescPacket(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 packetvoidhandleUpdateTag(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider lookupProvider) voidharvestPart(PartRayTraceResult hit, net.minecraft.world.entity.player.Player player) voidinternalPartChange(@Nullable MultiPart part) Notifies parts sharing this host of a changebooleanstatic booleanisUnobstructed(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, MultiPart part) voidloadFrom(TileMultipart that) Used to load the newly accuired data from copyFrom.voidloadTo(TileMultipart that) Called after a tile conversion on the old tile.voidMark this block space for a render update.voidvoidmultiPartChange(Collection<MultiPart> parts) Notifies all parts not in the passed collection of a change from all the parts in the collectionvoidnotifyNeighborChange(int side) voidnotifyNeighborChange(net.minecraft.core.Direction side) Helper function for calling a second level notify on a side (eg indirect power from a lever)voidnotifyPartChange(@Nullable MultiPart part) Called by parts when they have changed in some form that affects the world.voidNotifies neighboring blocks that a shape has changedvoidNotifies neighboring blocks that this tile has changedbooleanocclusionTest(Iterable<MultiPart> parts, MultiPart nPart) voidonChunkLoad(net.minecraft.world.level.chunk.LevelChunk chunk) voidvoidonMoved()voidonNeighborBlockChanged(net.minecraft.core.BlockPos pos) voidonNeighborTileChange(net.minecraft.core.BlockPos neighborPos) Blank implementation.voidCalled when the Tile is marked as removed viasetRemoved().voidvoidCalled when a part is added (placement).voidpartRemoved(MultiPart part, int p) Remove this part from internal cache.voidrecalcLight(boolean sky, boolean block) @Nullable TileMultipart@Nullable TileMultipartremPart_impl(MultiPart part) static booleanreplaceable(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 voidsaveAdditional(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) voidCallback for parts to mark the chunk as needs savingvoidsetLevel(net.minecraft.world.level.Level level) voidfinal voidsetValid(boolean b) voidstepOn(net.minecraft.world.entity.Entity entity) tile()voidnet.minecraft.world.ItemInteractionResultuseItemOn(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.player.Player player, PartRayTraceResult hit, net.minecraft.world.InteractionHand hand) net.minecraft.world.InteractionResultuseWithoutItem(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit) voidwriteDesc(codechicken.lib.data.MCDataOutput packet) Writes the description of this tile, and all parts composing it, to packetMethods 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, triggerEventMethods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingData, 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, hasData, removeData, setDataMethods 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
-
from
-
copyFrom
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
Used to load the newly accuired data from copyFrom. -
loadTo
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
Bind this part to an internal cache.Provided for trait overrides, do not call externally.
-
partAdded
Called when a part is added (placement).Provided for trait overrides, do not call externally.
-
partRemoved
Remove this part from internal cache.Provided for trait overrides, do not call externally.
-
getWeakChanges
public boolean getWeakChanges()Blank implementationOverriden by
TTileChangeTile -
onNeighborTileChange
public void onNeighborTileChange(net.minecraft.core.BlockPos neighborPos) Blank implementation.Overriden by
TTileChangeTile -
getSlottedPart
Blank implementation.Overriden by
TSlottedTile -
onRemoved
public void onRemoved()Called when the Tile is marked as removed viasetRemoved().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:
saveAdditionalin classnet.minecraft.world.level.block.entity.BlockEntity
-
getUpdateTag
public final net.minecraft.nbt.CompoundTag getUpdateTag(net.minecraft.core.HolderLookup.Provider registries) - Overrides:
getUpdateTagin classnet.minecraft.world.level.block.entity.BlockEntity
-
handleUpdateTag
public void handleUpdateTag(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider lookupProvider) - Specified by:
handleUpdateTagin interfacenet.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
-
canReplacePart
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
-
addPart_impl
-
addPart_do
-
remPart
-
remPart_impl
-
setValid
public final void setValid(boolean b) -
setRemoved
public void setRemoved()- Overrides:
setRemovedin classnet.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
-
getDrops
-
getCloneStack
-
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:
onChunkUnloadedin interfacenet.neoforged.neoforge.common.extensions.IBlockEntityExtension
-
onChunkLoad
public void onChunkLoad(net.minecraft.world.level.chunk.LevelChunk chunk) - Specified by:
onChunkLoadin interfacecodechicken.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
-
setLevel
public void setLevel(net.minecraft.world.level.Level level) - Overrides:
setLevelin classnet.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
- 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
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
Notifies parts sharing this host of a change -
multiPartChange
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:
setChangedin classnet.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
Utility function for dropping items around the center of this space -
operate
-
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)
-