Interface IPart

All Superinterfaces:
net.minecraft.world.Clearable, ICustomCableConnection
All Known Subinterfaces:
ICablePart, IMonitorPart, IStorageMonitorPart

public interface IPart extends ICustomCableConnection, net.minecraft.world.Clearable
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    addAdditionalDrops(List<net.minecraft.world.item.ItemStack> drops, boolean wrenched)
    Add additional drops to the drop list (the contents of the part, but not the part itself).
    default void
    addEntityCrashInfo(net.minecraft.CrashReportCategory section)
    This will be used by the core to add information about this part to a crash report if it is attached to a host that caused a crash during tick processing.
    default void
    addPartDrop(List<net.minecraft.world.item.ItemStack> drops, boolean wrenched)
    Add the stack of the part itself to the drop list.
    default void
    called when your part is being added to the world.
    default void
    animateTick(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource r)
    same as Block.animateTick, for but parts.
    default boolean
    Used to determine which parts can be placed on what cables.
    default boolean
     
    default void
    Clears the contents of the part, which would otherwise be dropped by addAdditionalDrops(java.util.List<net.minecraft.world.item.ItemStack>, boolean).
    default void
    exportSettings(appeng.util.SettingsFrom mode, net.minecraft.core.component.DataComponentMap.Builder builder)
    Exports settings for attaching it to a memory card or item stack.
    void
    add your collision information to the list.
    float
     
    default AECableType
    This method may be implemented by a part to request a specific type of cable connection for rendering.
    default AECableType
    This method controls the cable type that is returned for IInWorldGridNodeHost.getCableConnectionType(Direction) by the part host for the side this part is on.
    default @Nullable IGridNode
    used for tunnels.
    @Nullable IGridNode
    get the Grid Node for the Bus, be sure your IGridBlock is NOT isWorldAccessible, if it is your going to cause crashes.
    default int
     
    default net.neoforged.neoforge.client.model.data.ModelData
    Additional model data to be passed to the models for rendering this part.
    Gets the item from which this part was created.
    default IPartModel
    This method is used when a chunk is rebuilt to determine how this part should be rendered.
    default void
    importSettings(appeng.util.SettingsFrom mode, net.minecraft.core.component.DataComponentMap input, @Nullable net.minecraft.world.entity.player.Player player)
    Depending on the mode, different settings will be accepted.
    default boolean
    isLadder(net.minecraft.world.entity.LivingEntity entity)
    does this part act like a ladder?
    default int
     
    default int
     
    default boolean
     
    default boolean
    onClicked(net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.Vec3 pos)
    Called when you left click the part, very similar to Block.onBlockClicked a
    default void
    onEntityCollision(net.minecraft.world.entity.Entity entity)
    called when an entity collides with the bus.
    default void
    onNeighborChanged(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos neighbor)
    a block around the bus's host has been changed.
    default void
    onPlacement(net.minecraft.world.entity.player.Player player)
    Called when placed in the world by a player, this happens before addWorld.
    default boolean
    onShiftClicked(net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.Vec3 pos)
    Called when you shift-left click the part, very similar to Block.onBlockClicked
    default void
    onUpdateShape(net.minecraft.core.Direction side)
    The block state in a block adjacent to the part host may have changed.
    default boolean
    onUseItemOn(net.minecraft.world.item.ItemStack heldItem, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.Vec3 pos)
    Called when a player right-clicks the part with an item in hand.
    default boolean
    onUseWithoutItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.Vec3 pos)
    Called when a player right-clicks the part without an item in hand.
    default void
    readFromNBT(net.minecraft.nbt.CompoundTag data, net.minecraft.core.HolderLookup.Provider registries)
    Read the previously written NBT Data.
    default boolean
    readFromStream(net.minecraft.network.RegistryFriendlyByteBuf data)
    read data from bus packet.
    default void
    readVisualStateFromNBT(net.minecraft.nbt.CompoundTag data)
    Used to store the state that is synchronized to clients for the visual appearance of this part as NBT.
    default void
    called when your part is being removed from the world.
    default void
    renderDynamic(float partialTicks, com.mojang.blaze3d.vertex.PoseStack poseStack, net.minecraft.client.renderer.MultiBufferSource buffers, int combinedLightIn, int combinedOverlayIn)
    Render dynamic portions of this part, as part of the cable bus TESR.
    default boolean
    return true only if your part require dynamic rendering, must be consistent.
    void
    setPartHostInfo(@Nullable net.minecraft.core.Direction side, IPartHost host, net.minecraft.world.level.block.entity.BlockEntity blockEntity)
    called by the Part host to keep your part informed.
    default void
    writeToNBT(net.minecraft.nbt.CompoundTag data, net.minecraft.core.HolderLookup.Provider registries)
    Write the part information for saving.
    default void
    writeToStream(net.minecraft.network.RegistryFriendlyByteBuf data)
    Write variable data that should be synchronized to clients to the synchronization packet.
    default void
    writeVisualStateToNBT(net.minecraft.nbt.CompoundTag data)
    Used to store the state that is synchronized to clients for the visual appearance of this part as NBT.
  • Method Details

    • getPartItem

      IPartItem<?> getPartItem()
      Gets the item from which this part was created. Will be used to save and load this part from NBT Data or to Packets when synchronizing it with the client. It will also be used to drop the part when it is dismantled or broken.
      Returns:
      The item from which this part was placed.
    • renderDynamic

      default void renderDynamic(float partialTicks, com.mojang.blaze3d.vertex.PoseStack poseStack, net.minecraft.client.renderer.MultiBufferSource buffers, int combinedLightIn, int combinedOverlayIn)
      Render dynamic portions of this part, as part of the cable bus TESR. This part has to return true for requireDynamicRender() in order for this method to be called.
    • requireDynamicRender

      default boolean requireDynamicRender()
      return true only if your part require dynamic rendering, must be consistent.
      Returns:
      true to enable renderDynamic(float, com.mojang.blaze3d.vertex.PoseStack, net.minecraft.client.renderer.MultiBufferSource, int, int)
    • isSolid

      default boolean isSolid()
      Returns:
      if the bus has a solid side, and you can place random stuff on it like torches or levers
    • canConnectRedstone

      default boolean canConnectRedstone()
      Returns:
      true if this part can connect to redstone
    • writeToNBT

      default void writeToNBT(net.minecraft.nbt.CompoundTag data, net.minecraft.core.HolderLookup.Provider registries)
      Write the part information for saving. This information will be saved alongside the getPartItem() to save settings, inventory or other values to the world.
      Parameters:
      data - to be written nbt data
      registries -
    • readFromNBT

      default void readFromNBT(net.minecraft.nbt.CompoundTag data, net.minecraft.core.HolderLookup.Provider registries)
      Read the previously written NBT Data. this is the mirror for writeToNBT(net.minecraft.nbt.CompoundTag, net.minecraft.core.HolderLookup.Provider).
      Parameters:
      data - to be read nbt data
      registries -
    • exportSettings

      default void exportSettings(appeng.util.SettingsFrom mode, net.minecraft.core.component.DataComponentMap.Builder builder)
      Exports settings for attaching it to a memory card or item stack.
      Parameters:
      mode - The purpose to export settings for.
      builder - The map to write the settings to. Written settings must be part of the exported settings tag.
    • importSettings

      default void importSettings(appeng.util.SettingsFrom mode, net.minecraft.core.component.DataComponentMap input, @Nullable @Nullable net.minecraft.world.entity.player.Player player)
      Depending on the mode, different settings will be accepted.
      Parameters:
      input - source of settings
      player - the (optional) player who is importing the settings
    • getLightLevel

      default int getLightLevel()
      Returns:
      get the amount of light produced by the bus
    • isLadder

      default boolean isLadder(net.minecraft.world.entity.LivingEntity entity)
      does this part act like a ladder?
      Parameters:
      entity - climbing entity
      Returns:
      true if entity can climb
    • onNeighborChanged

      default void onNeighborChanged(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos neighbor)
      a block around the bus's host has been changed.
      See Also:
      • IBlockExtension.onNeighborChange(net.minecraft.world.level.block.state.BlockState, net.minecraft.world.level.LevelReader, net.minecraft.core.BlockPos, net.minecraft.core.BlockPos)
    • onUpdateShape

      default void onUpdateShape(net.minecraft.core.Direction side)
      The block state in a block adjacent to the part host may have changed. Note that this may be called quite often and should not lead to immediate block notifications. Any action resulting from this notification should be delayed until at least the end of tick.

      It is the parts responsibility to only react to changes on sides that are relevant for it.

      See Also:
      • BlockBehaviour.updateShape(net.minecraft.world.level.block.state.BlockState, net.minecraft.core.Direction, net.minecraft.world.level.block.state.BlockState, net.minecraft.world.level.LevelAccessor, net.minecraft.core.BlockPos, net.minecraft.core.BlockPos)
    • isProvidingStrongPower

      default int isProvidingStrongPower()
      Returns:
      output redstone on facing side
    • isProvidingWeakPower

      default int isProvidingWeakPower()
      Returns:
      output redstone on facing side
    • writeToStream

      default void writeToStream(net.minecraft.network.RegistryFriendlyByteBuf data)
      Write variable data that should be synchronized to clients to the synchronization packet.
      Parameters:
      data - to be written data
    • writeVisualStateToNBT

      @Experimental default void writeVisualStateToNBT(net.minecraft.nbt.CompoundTag data)
      Used to store the state that is synchronized to clients for the visual appearance of this part as NBT. This is only used to store this state for tools such as Create Ponders in Structure NBT. Actual synchronization uses writeToStream(RegistryFriendlyByteBuf) and readFromStream(RegistryFriendlyByteBuf). Any data that is saved to the NBT tag in writeToNBT(CompoundTag, HolderLookup.Provider) does not need to be saved here again.

      The data saved should be equivalent to the data sent to the client in writeToStream(net.minecraft.network.RegistryFriendlyByteBuf).

      Please note that this may both be called on the client-side (i.e. when using Create Ponder) and on the server-side when saving structures with a structure block. To not lose the previously saved data in PonderJS, you need to write back the data you read in readVisualStateFromNBT(net.minecraft.nbt.CompoundTag) if the current level is a client-side level.

    • readFromStream

      default boolean readFromStream(net.minecraft.network.RegistryFriendlyByteBuf data)
      read data from bus packet.
      Parameters:
      data - to be read data
      Returns:
      true will re-draw the part.
    • readVisualStateFromNBT

      @Experimental default void readVisualStateFromNBT(net.minecraft.nbt.CompoundTag data)
      Used to store the state that is synchronized to clients for the visual appearance of this part as NBT. This is only used to store this state for tools such as Create Ponders in Structure NBT. Actual synchronization uses writeToStream(RegistryFriendlyByteBuf) and readFromStream(RegistryFriendlyByteBuf). Any data that is saved to the NBT tag in writeToNBT(CompoundTag, HolderLookup.Provider) already does not need to be saved here again.
    • getGridNode

      @Nullable @Nullable IGridNode getGridNode()
      get the Grid Node for the Bus, be sure your IGridBlock is NOT isWorldAccessible, if it is your going to cause crashes.

      or null if you don't have a grid node.

      Returns:
      grid node
    • onEntityCollision

      default void onEntityCollision(net.minecraft.world.entity.Entity entity)
      called when an entity collides with the bus.
      Parameters:
      entity - colliding entity
    • removeFromWorld

      default void removeFromWorld()
      called when your part is being removed from the world.
    • addToWorld

      default void addToWorld()
      called when your part is being added to the world.
    • getExternalFacingNode

      @Nullable default @Nullable IGridNode getExternalFacingNode()
      used for tunnels.
      Returns:
      a grid node that represents the external facing side and allows external connections. this nodes IManagedGridNode.setExposedOnSides(Set) will be automatically updated with the side the part is placed on.
    • getExternalCableConnectionType

      default AECableType getExternalCableConnectionType()
      This method controls the cable type that is returned for IInWorldGridNodeHost.getCableConnectionType(Direction) by the part host for the side this part is on.
    • setPartHostInfo

      void setPartHostInfo(@Nullable @Nullable net.minecraft.core.Direction side, IPartHost host, net.minecraft.world.level.block.entity.BlockEntity blockEntity)
      called by the Part host to keep your part informed.
      Parameters:
      side - The side the part is attached to, or null to indicate the part is at the center.
      blockEntity - block entity of part
    • onUseWithoutItem

      default boolean onUseWithoutItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.Vec3 pos)
      Called when a player right-clicks the part without an item in hand.
      Parameters:
      player - right clicking player
      pos - position of block
      Returns:
      if your activate method performed something.
    • onUseItemOn

      default boolean onUseItemOn(net.minecraft.world.item.ItemStack heldItem, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.Vec3 pos)
      Called when a player right-clicks the part with an item in hand.
      Parameters:
      heldItem - item triggering the interaction
      player - right clicking player
      hand - hand used
      pos - position of block
      Returns:
      if your activate method performed something.
    • onClicked

      default boolean onClicked(net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.Vec3 pos)
      Called when you left click the part, very similar to Block.onBlockClicked a
      Parameters:
      player - left clicking player
      pos - clicked position, in block-local coordinates
      Returns:
      True if your part wants to suppress the default behavior of attacking the part host.
    • onShiftClicked

      default boolean onShiftClicked(net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.Vec3 pos)
      Called when you shift-left click the part, very similar to Block.onBlockClicked
      Parameters:
      player - shift-left clicking player
      pos - clicked position, in block-local coordinates
      Returns:
      True if your part wants to suppress the default behavior of attacking the part host.
    • addPartDrop

      default void addPartDrop(List<net.minecraft.world.item.ItemStack> drops, boolean wrenched)
      Add the stack of the part itself to the drop list.
      Parameters:
      wrenched - control flag for wrenched vs broken
    • addAdditionalDrops

      @MustBeInvokedByOverriders default void addAdditionalDrops(List<net.minecraft.world.item.ItemStack> drops, boolean wrenched)
      Add additional drops to the drop list (the contents of the part, but not the part itself).
      Parameters:
      wrenched - control flag for wrenched vs broken
    • clearContent

      @MustBeInvokedByOverriders default void clearContent()
      Clears the contents of the part, which would otherwise be dropped by addAdditionalDrops(java.util.List<net.minecraft.world.item.ItemStack>, boolean).
      Specified by:
      clearContent in interface net.minecraft.world.Clearable
    • getCableConnectionLength

      float getCableConnectionLength(AECableType cable)
      Specified by:
      getCableConnectionLength in interface ICustomCableConnection
      Returns:
      0 - 8, reasonable default 3-4, this controls the cable connection to the node. -1 to render connection yourself.
    • animateTick

      default void animateTick(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource r)
      same as Block.animateTick, for but parts.
      Parameters:
      level - level of block
      pos - location of block
      r - random
    • onPlacement

      default void onPlacement(net.minecraft.world.entity.player.Player player)
      Called when placed in the world by a player, this happens before addWorld.
      Parameters:
      player - placing player
    • canBePlacedOn

      default boolean canBePlacedOn(BusSupport what)
      Used to determine which parts can be placed on what cables.

      Dense cables are not allowed for functional (getGridNode returns a node) parts. Doing so will result in crashes.

      Parameters:
      what - placed part
      Returns:
      true if the part can be placed on this support.
    • getStaticModels

      default IPartModel getStaticModels()
      This method is used when a chunk is rebuilt to determine how this part should be rendered. The returned models should represent the part oriented north. They will be automatically rotated to match the part's actual orientation. Tint indices 1-4 can be used in the models to access the parts color.
      Tint Index 1
      The dark variant color of the cable that this part is attached to.
      Tint Index 2
      The color of the cable that this part is attached to.
      Tint Index 3
      The bright variant color of the cable that this part is attached to.
      Tint Index 4
      A color variant that is between the cable's color and its bright variant.
      Important: All models must have been registered via the PartModels API before use.
    • getModelData

      default net.neoforged.neoforge.client.model.data.ModelData getModelData()
      Additional model data to be passed to the models for rendering this part.
      Returns:
      The model data to pass to the model. Only useful if custom models are used.
    • getBoxes

      void getBoxes(IPartCollisionHelper bch)
      add your collision information to the list.
      Parameters:
      bch - collision boxes
    • addEntityCrashInfo

      default void addEntityCrashInfo(net.minecraft.CrashReportCategory section)
      This will be used by the core to add information about this part to a crash report if it is attached to a host that caused a crash during tick processing.
      Parameters:
      section - The crash report section the information will be added to.
    • getDesiredConnectionType

      default AECableType getDesiredConnectionType()
      This method may be implemented by a part to request a specific type of cable connection for rendering. Mechanics are not affected by this in any way.