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
All Multipart implementations are expected to extend from BaseMultipart.
Created by covers1624 on 6/6/22.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddDestroyEffects(PartRayTraceResult hit, net.minecraft.client.particle.ParticleEngine engine) Add particles and other effects when a player finishes breaking this part.default voidaddHitEffects(PartRayTraceResult hit, net.minecraft.client.particle.ParticleEngine engine) Add particles and other effects when a player is mining this part.default voidaddLandingEffects(PartRayTraceResult hit, codechicken.lib.vec.Vector3 entity, int numberOfParticles) Add particles and other effects when a player lands on this part.default voidaddRunningEffects(PartRayTraceResult hit, net.minecraft.world.entity.Entity entity) Add particles and other effects when a player runs over this part.default codechicken.lib.capability.CapabilityCachecapCache()Get the globalCapabilityCachefor this block.default voidclick(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.VoxelShapeMaps toBlockBehaviour.getBlockSupportShape(BlockState, BlockGetter, BlockPos).default net.minecraft.world.item.ItemStackReturn theItemStackfor pick-block(usually middle click) function.default net.minecraft.world.phys.shapes.VoxelShapegetCollisionShape(net.minecraft.world.phys.shapes.CollisionContext context) Maps toBlockBehaviour.getCollisionShape(BlockState, BlockGetter, BlockPos, CollisionContext).default Iterable<net.minecraft.world.item.ItemStack> getDrops()Return a list ofItemStacks that should be dropped when this part is destroyed.default floatgetExplosionResistance(net.minecraft.world.level.Explosion explosion) Get the explosion resistance for this part.default net.minecraft.world.phys.shapes.VoxelShapeMaps toBlockBehaviour.getInteractionShape(BlockState, BlockGetter, BlockPos).default intThe light level emitted by this part.default net.neoforged.neoforge.client.model.data.ModelDataCompanion toIBlockEntityExtension.getModelData(), except for this part.default @Nullable net.minecraft.world.level.block.SoundTypegetPlacementSound(net.minecraft.world.item.context.UseOnContext context) Used to get the sound for this part when placed.default codechicken.lib.vec.Cuboid6Gets the bounds of this part for Frustum culling.default net.minecraft.world.phys.shapes.VoxelShapeMaps toBlockBehaviour.getOcclusionShape(BlockState, BlockGetter, BlockPos).default net.minecraft.world.phys.shapes.VoxelShapegetShape(net.minecraft.world.phys.shapes.CollisionContext context) Maps toBlockBehaviour.getShape(BlockState, BlockGetter, BlockPos, CollisionContext).default floatgetStrength(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit) Return a value indicating how hard this part is to break.getType()Returns theMultipartTyperegistry entry for this part.default net.minecraft.world.phys.shapes.VoxelShapegetVisualShape(net.minecraft.world.phys.shapes.CollisionContext context) Maps toBlockBehaviour.getVisualShape(BlockState, BlockGetter, BlockPos, CollisionContext).default voidharvest(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit) Harvest this part, removing it from the containerTileMultipartand dropping any items if necessary.default booleanhasLevel()booleanhasTile()default voidCalled when this part is converted from a normal block or tile, before the original tile has been replaced.default net.minecraft.world.level.Levellevel()Get theLevelthe containerTileMultipartis inside.default voidload(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) Load this part from aCompoundTag.default booleanocclusionTest(MultiPart npart) Perform an occlusion test to determine weather this part andnpartcan 'fit' into this block space.default voidonAdded()Called when this part is added to the block space.default voidonChunkLoad(net.minecraft.world.level.chunk.LevelChunk chunk) Called when the containing chunk is loaded on the server.default voidCalled when the containing chunk is unloaded on the server.default voidCalled when this part is converted from a normal block or tile.default voidonEntityCollision(net.minecraft.world.entity.Entity entity) Called when an entity is within this block space.default voidonEntityStanding(net.minecraft.world.entity.Entity entity) Called when an entity is standing on this block space.default voidonMoved()Called when this part has been moved without a save/load.default voidonNeighborBlockChanged(net.minecraft.core.BlockPos neighbor) Called when a neighbor block changes.default voidonPartChanged(@Nullable MultiPart part) Called when a part is added or removed from this block space.default voidCalled when this part is removed from the block space.default voidCalled when this part joins the world.default voidCalled when this part separates from the world.default net.minecraft.core.BlockPospos()TheBlockPosof the containerTileMultipart.default voidCalled just before this part is actually removed from the container tile.default voidreadDesc(codechicken.lib.data.MCDataInput packet) Fill out this part with the description information contained inpacket.default voidreadUpdate(codechicken.lib.data.MCDataInput packet) Read a packet sent viasendUpdate(java.util.function.Consumer<codechicken.lib.data.MCDataOutput>).default voidsave(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) Save this part to aCompoundTag.default voidCalled when a scheduled tick is executed.default voidscheduleTick(int ticks) Set ascheduledTick()callback for this partticksin the future.default voidsendUpdate(Consumer<codechicken.lib.data.MCDataOutput> func) Send a packet to this part's client-side counterpart.tile()Get the underlyingTileMultipartthis part is inside.default net.minecraft.world.ItemInteractionResultuseItemOn(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.InteractionResultuseWithoutItem(net.minecraft.world.entity.player.Player player, PartRayTraceResult hit) Called on block right-click without an item.default voidwriteDesc(codechicken.lib.data.MCDataOutput packet) Write all the data required to describe a client version of this part to the packet.
-
Method Details
-
tile
Get the underlyingTileMultipartthis 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 theLevelthe containerTileMultipartis inside.- Returns:
- The
Level.
-
hasLevel
default boolean hasLevel()- Returns:
- If this part has a
Levelattached.
-
pos
@Contract(pure=true) default net.minecraft.core.BlockPos pos()TheBlockPosof the containerTileMultipart.- Returns:
- The
BlockPos.
-
capCache
@Contract(pure=true) default codechicken.lib.capability.CapabilityCache capCache()Get the globalCapabilityCachefor this block.- Returns:
- The
CapabilityCache.
-
getType
Returns theMultipartTyperegistry 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 inpacket.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 aCompoundTag.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 aCompoundTag.Only called server-side.
- Parameters:
tag- The tag to read from.
-
sendUpdate
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) Read a packet sent viasendUpdate(java.util.function.Consumer<codechicken.lib.data.MCDataOutput>).- Parameters:
packet- THe packet to read.
-
occlusionTest
Perform an occlusion test to determine weather this part andnpartcan 'fit' into this block space.- Parameters:
npart- The part to run the test against.- Returns:
trueif both this part andnpartare able to share this block space.
-
getShape
default net.minecraft.world.phys.shapes.VoxelShape getShape(net.minecraft.world.phys.shapes.CollisionContext context) Maps toBlockBehaviour.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 toBlockBehaviour.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 toBlockBehaviour.getOcclusionShape(BlockState, BlockGetter, BlockPos).If this shape changes after initial placement, call
TileMultipart.markShapeChange(). -
getInteractionShape
default net.minecraft.world.phys.shapes.VoxelShape getInteractionShape()Maps toBlockBehaviour.getInteractionShape(BlockState, BlockGetter, BlockPos).If this shape changes after initial placement, call
TileMultipart.markShapeChange(). -
getBlockSupportShape
default net.minecraft.world.phys.shapes.VoxelShape getBlockSupportShape()Maps toBlockBehaviour.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 toBlockBehaviour.getVisualShape(BlockState, BlockGetter, BlockPos, CollisionContext).If this shape changes after initial placement, call
TileMultipart.markShapeChange(). -
harvest
Harvest this part, removing it from the containerTileMultipartand dropping any items if necessary.- Parameters:
player- ThePlayerharvesting the part.hit- ThePartRayTraceResulthit result.
-
getDrops
Return a list ofItemStacks that should be dropped when this part is destroyed.- Returns:
- The
ItemStacks.
-
getCloneStack
Return theItemStackfor pick-block(usually middle click) function.- Parameters:
hit- ThePartRayTraceResulthit result.- Returns:
- The
ItemStackpick result.
-
getExplosionResistance
default float getExplosionResistance(net.minecraft.world.level.Explosion explosion) Get the explosion resistance for this part.The explosion resistance for the host
TileMultipartis the maximum explosion resistance for all contained parts.- Parameters:
explosion- TheExplosion.- Returns:
- The resistance.
-
getLightEmission
default int getLightEmission()The light level emitted by this part.- Returns:
- The light level.
-
getStrength
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- ThePartRayTraceResulthit 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
nullfor 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- TheItemStackheld by the player.player- The player that right-clicked the part.hit- ThePartRayTraceResulthit result.hand- TheInteractionHandthe 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- ThePartRayTraceResulthit 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- ThePartRayTraceResulthit result.stack- TheItemStackheld 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- TheEntity.
-
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- TheEntity.
-
onNeighborBlockChanged
default void onNeighborBlockChanged(net.minecraft.core.BlockPos neighbor) Called when a neighbor block changes.- Parameters:
neighbor- The neighbor block.
-
onPartChanged
Called when a part is added or removed from this block space.- Parameters:
part- The part which changed. May benullif multiple parts are changed.
-
scheduledTick
default void scheduledTick()Called when a scheduled tick is executed.- See Also:
-
scheduleTick
default void scheduleTick(int ticks) Set ascheduledTick()callback for this partticksin the future.ticksis 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- ThePartRayTraceResulthit result.engine- TheParticleEngineto 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- ThePartRayTraceResulthit result.engine- TheParticleEngineto 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
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 toIBlockEntityExtension.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.
-