Interface IPartType<P extends IPartType<P,S>,S extends IPartState<P>>

Type Parameters:
P - The part type.
S - The part state type.
All Superinterfaces:
INetworkEventListener<IPartNetworkElement<P,S>>
All Known Subinterfaces:
IPartTypeActiveVariable<P,S>, IPartTypeReader<P,S>, IPartTypeWriter<P,S>
All Known Implementing Classes:
PartTypeAdapter, PartTypeAspects, PartTypeAudioReader, PartTypeAudioWriter, PartTypeBase, PartTypeBlockReader, PartTypeConfigurable, PartTypeConnector, PartTypeConnectorMonoDirectional, PartTypeConnectorOmniDirectional, PartTypeEffectWriter, PartTypeEntityReader, PartTypeEntityWriter, PartTypeExtraDimensionalReader, PartTypeFluidReader, PartTypeInventoryReader, PartTypeInventoryWriter, PartTypeMachineReader, PartTypeMachineWriter, PartTypeNetworkReader, PartTypePanel, PartTypePanelDisplay, PartTypePanelLightDynamic, PartTypePanelLightStatic, PartTypePanelVariableDriven, PartTypeReadBase, PartTypeRedstoneReader, PartTypeRedstoneWriter, PartTypeWorldReader, PartTypeWriteBase

public interface IPartType<P extends IPartType<P,S>,S extends IPartState<P>> extends INetworkEventListener<IPartNetworkElement<P,S>>
A type of part that can be inserted into a IPartContainer. Only one unique instance for each part should exist, the values are stored inside an IPartState.
  • Method Details

    • getUniqueName

      net.minecraft.resources.ResourceLocation getUniqueName()
      Returns:
      The unique name for this part type.
    • getTranslationKey

      String getTranslationKey()
      Returns:
      The unlocalized name of this part.
    • getBlockModelPath

      net.minecraft.resources.ResourceLocation getBlockModelPath()
      Returns:
      JSON model path for the block representation of this part.
    • getItem

      net.minecraft.world.item.Item getItem()
      Returns:
      The item associated with this part type.
    • isSolid

      boolean isSolid(S state)
      Parameters:
      state - The state
      Returns:
      If this element is solid.
    • getPartRenderPosition

      PartRenderPosition getPartRenderPosition()
      Returns:
      The position part occupies, used to calculate the required render lengths. This part is assumed to be aligned at the edge of the block for the depth, while centered on width and height.
    • toNBT

      void toNBT(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.CompoundTag tag, S partState)
      Write the properties of this part to NBT. An identificator for this part is not required, this is written somewhere else.
      Parameters:
      valueDeseralizationContext -
      tag - The tag to write to. This tag is guaranteed to be empty.
      partState - The state of this part.
    • fromNBT

      S fromNBT(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.CompoundTag tag)
      Read the properties of this part from nbt. This tag is guaranteed to only contain data for this part.
      Parameters:
      valueDeseralizationContext -
      tag - The tag to read from.
      Returns:
      The state of this part.
    • defaultBlockState

      S defaultBlockState()
      Returns:
      The default state of this part.
    • setUpdateInterval

      void setUpdateInterval(S state, int updateInterval)
      Set the update interval for this part.
      Parameters:
      state - The state
      updateInterval - The tick interval to update this element.
    • getUpdateInterval

      int getUpdateInterval(S state)
      Parameters:
      state - The state
      Returns:
      The tick interval to update this element.
    • getMinimumUpdateInterval

      int getMinimumUpdateInterval(S state)
      Parameters:
      state - The state
      Returns:
      The minimum allowed tick interval to update this element.
    • setPriorityAndChannel

      @Deprecated void setPriorityAndChannel(INetwork network, IPartNetwork partNetwork, PartTarget target, S state, int priority, int channel)
      Deprecated.
      Set the priority and channel of this part in the network.
      Parameters:
      network - The network to update in.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
      priority - The new priority
      channel - The new channel
    • getPriority

      int getPriority(S state)
      Parameters:
      state - The state
      Returns:
      The priority of this part in the network.
    • getChannel

      int getChannel(S state)
      Parameters:
      state - The state
      Returns:
      The channel of this part in the network.
    • supportsOffsets

      default boolean supportsOffsets()
      Returns:
      If this part can handle custom offsets.
    • getTargetOffset

      net.minecraft.core.Vec3i getTargetOffset(S state)
      Parameters:
      state - The state
      Returns:
      The target position offset.
    • setTargetOffset

      boolean setTargetOffset(S state, PartPos center, net.minecraft.core.Vec3i offset)
      Parameters:
      state - The state
      center - The center position.
      offset - The target position offset.
      Returns:
      True if the offset was valid
    • setTargetSideOverride

      void setTargetSideOverride(S state, @Nullable net.minecraft.core.Direction side)
      Indicate that the given part should interact with the given side of the target.
      Parameters:
      state - The state
      side - The side of the target block to interact with. Null removes the side override.
    • getTargetSideOverride

      @Nullable net.minecraft.core.Direction getTargetSideOverride(S state)
      Parameters:
      state - The state
      Returns:
      The overridden side of the target block to interact with. Can be null.
    • getTarget

      PartTarget getTarget(PartPos pos, S state)
      Get the part target for this part.
      Parameters:
      pos - The center position of this part.
      state - The state.
      Returns:
      The part target.
    • onOffsetVariablesChanged

      void onOffsetVariablesChanged(PartTarget target, S state)
      Called when an offset variable was inserted or removed from a slot.
      Parameters:
      target - The target block.
      state - The state.
    • isUpdate

      boolean isUpdate(S state)
      Parameters:
      state - The state
      Returns:
      If this element should be updated. This method is only called once during network initialization.
    • update

      void update(INetwork network, IPartNetwork partNetwork, PartTarget target, S state)
      Update at the tick interval specified.
      Parameters:
      network - The network to update in.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
    • beforeNetworkKill

      void beforeNetworkKill(INetwork network, IPartNetwork partNetwork, PartTarget target, S state)
      Called right before the network is terminated or will be reset.
      Parameters:
      network - The network to update in.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
    • afterNetworkAlive

      void afterNetworkAlive(INetwork network, IPartNetwork partNetwork, PartTarget target, S state)
      Called right after this network is initialized.
      Parameters:
      network - The network to update in.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
    • afterNetworkReAlive

      void afterNetworkReAlive(INetwork network, IPartNetwork partNetwork, PartTarget target, S state)
      Called right after this network has come alive again, for example after a network restart.
      Parameters:
      network - The network to update in.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
    • getItemStack

      net.minecraft.world.item.ItemStack getItemStack(ValueDeseralizationContext valueDeseralizationContext, S state, boolean saveState)
      Get the itemstack from the given state.
      Parameters:
      valueDeseralizationContext -
      state - The state
      saveState - If the part state should be saved in the item.
      Returns:
      The itemstack possibly containing the state information.
    • getCloneItemStack

      net.minecraft.world.item.ItemStack getCloneItemStack(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, S state)
      Get the itemstack from the given state.
      Parameters:
      world - The world.
      pos - The position.
      state - The state.
      Returns:
      The itemstack possibly containing the state information.
    • getState

      S getState(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.world.item.ItemStack itemStack)
      Get the part state from the given itemstack.
      Parameters:
      valueDeseralizationContext -
      itemStack - The itemstack possibly containing state information.
      Returns:
      The state contained in the itemstack or the default part state.
    • addDrops

      void addDrops(PartTarget target, S state, List<net.minecraft.world.item.ItemStack> itemStacks, boolean dropMainElement, boolean saveState)
      Add the itemstacks to drop when this element is removed.
      Parameters:
      target - The target.
      state - The state
      itemStacks - The itemstack list to add to.
      dropMainElement - If the part itself should also be dropped.
      saveState - If the part state should be saved in the item.
    • onNetworkAddition

      void onNetworkAddition(INetwork network, IPartNetwork partNetwork, PartTarget target, S state)
      Called when this element is added to the network.
      Parameters:
      network - The network to update in.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
    • onNetworkRemoval

      void onNetworkRemoval(INetwork network, IPartNetwork partNetwork, PartTarget target, S state)
      Called when this element is removed from the network.
      Parameters:
      network - The network to update in.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
    • createNetworkElement

      INetworkElement createNetworkElement(IPartContainer partContainer, org.cyclops.cyclopscore.datastructure.DimPos pos, net.minecraft.core.Direction side)
      Create a network element for this part type.
      Parameters:
      partContainer - The container this part is/will be part of.
      pos - The position this network element is/will be placed at.
      side - The side this network element is/will be placed at.
      Returns:
      A new network element instance.
    • onPartActivated

      net.minecraft.world.InteractionResult onPartActivated(S partState, net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack heldItem, net.minecraft.world.phys.BlockHitResult hit)
      Called when a part is right-clicked.
      Parameters:
      partState - The state of this part.
      pos - The position of the block this part is part of.
      world - The world.
      player - The player activating the part.
      hand - The hand in use by the player.
      heldItem - The held item.
      hit - The ray trace hit result.
      Returns:
      The action result.
    • getBlockState

      net.minecraft.world.level.block.state.BlockState getBlockState(IPartContainer partContainer, net.minecraft.core.Direction side)
      Get the base block state that will be rendered for this part. An appropriate IgnoredBlock.FACING property will be set.
      Parameters:
      partContainer - The part entity.
      side - The position of the part.
      Returns:
      The block state to render with.
    • getBaseBlockState

      net.minecraft.world.level.block.state.BlockState getBaseBlockState()
      Returns:
      The default block state representation of this part.
    • updateTick

      void updateTick(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, S partState, net.minecraft.util.RandomSource random)
      Called when a block update occurs
      Parameters:
      world - The world.
      pos - The position.
      partState - The part state.
      random - A random instance.
    • onPreRemoved

      void onPreRemoved(INetwork network, IPartNetwork partNetwork, PartTarget target, S state)
      Called when this element is about to be removed.
      Parameters:
      network - The network.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
    • onPostRemoved

      void onPostRemoved(INetwork network, IPartNetwork partNetwork, PartTarget target, S state)
      Called after this element has been removed.
      Parameters:
      network - The network.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
    • onBlockNeighborChange

      void onBlockNeighborChange(@Nullable INetwork network, @Nullable IPartNetwork partNetwork, PartTarget target, S state, net.minecraft.world.level.BlockGetter world, net.minecraft.world.level.block.Block neighbourBlock, net.minecraft.core.BlockPos neighbourBlockPos)
      Called when a neighbouring block is updated, more specifically when BlockBehaviour.neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean), IBlockExtension.onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos) or BlockBehaviour.updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos) is called.
      Parameters:
      network - The network to update in.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
      world - The world in which the neighbour was updated.
      neighbourBlock - The block type of the neighbour that was updated.
      neighbourBlockPos - The position of the neighbour that was updated.
    • getConsumptionRate

      int getConsumptionRate(S state)
      Parameters:
      state - The state
      Returns:
      The consumption rate of this part for the given state.
    • postUpdate

      void postUpdate(INetwork network, IPartNetwork partNetwork, PartTarget target, S state, boolean updated)
      Called after the element was updated or not. If the update was not called, this can be because the network did not contain enough energy to let this element work.
      Parameters:
      network - The network to update in.
      partNetwork - The part network to update in.
      target - The target block.
      state - The state
      updated - If the INetworkElement.update(INetwork) was called.
    • isEnabled

      boolean isEnabled(S state)
      Parameters:
      state - The state
      Returns:
      If this part is enabled.
    • setEnabled

      void setEnabled(S state, boolean enabled)
      Set if this part should work.
      Parameters:
      state - The state
      enabled - If it should work.
    • loadTooltip

      void loadTooltip(S state, List<net.minecraft.network.chat.Component> lines)
      Add tooltip lines for this aspect when this part is being hovered by a mod like WAILA.
      Parameters:
      state - The state.
      lines - The list to add lines to.
    • loadTooltip

      void loadTooltip(net.minecraft.world.item.ItemStack itemStack, List<net.minecraft.network.chat.Component> lines)
      Add tooltip lines for this aspect when this part's item is being hovered.
      Parameters:
      itemStack - The itemstack.
      lines - The list to add lines to.
    • shouldTriggerBlockRenderUpdate

      boolean shouldTriggerBlockRenderUpdate(@Nullable S oldPartState, @Nullable S newPartState)
      Check if the given state change should trigger a block render update. This is only called client-side. The new and old partstates are never both null, at most one will be null.
      Parameters:
      oldPartState - The old part state.
      newPartState - The new part state.
      Returns:
      If it should trigger a block render update.
    • forceLightTransparency

      boolean forceLightTransparency(S state)
      Parameters:
      state - The state.
      Returns:
      If this part should force the block to be transparent to light.
    • getContainerProvider

      default Optional<net.minecraft.world.MenuProvider> getContainerProvider(PartPos pos)
      Parameters:
      pos - The part position. May be null when called client-side, for checking presence.
      Returns:
      The optional container provider for the part type gui.
    • writeExtraGuiData

      default void writeExtraGuiData(net.minecraft.network.RegistryFriendlyByteBuf packetBuffer, PartPos pos, net.minecraft.server.level.ServerPlayer player)
      This method can be overridden for cases when additional data needs to be sent to clients when opening containers.
      Parameters:
      packetBuffer - A packet buffer that can be written to.
      pos - A part position.
      player - The player opening the gui.
    • getContainerProviderSettings

      default Optional<net.minecraft.world.MenuProvider> getContainerProviderSettings(PartPos pos)
      Parameters:
      pos - The part position. May be null when called client-side, for checking presence.
      Returns:
      The optional container provider for the part settings gui.
    • getContainerProviderOffsets

      default Optional<net.minecraft.world.MenuProvider> getContainerProviderOffsets(PartPos pos)
      Parameters:
      pos - The part position. May be null when called client-side, for checking presence.
      Returns:
      The optional container provider for the part offsets gui.
    • writeExtraGuiDataSettings

      default void writeExtraGuiDataSettings(net.minecraft.network.RegistryFriendlyByteBuf packetBuffer, PartPos pos, net.minecraft.server.level.ServerPlayer player)
      This method can be overridden for cases when additional data needs to be sent to clients when opening settings containers.
      Parameters:
      packetBuffer - A packet buffer that can be written to.
      pos - A part position.
      player - The player opening the settings gui.
    • writeExtraGuiDataOffsets

      default void writeExtraGuiDataOffsets(net.minecraft.network.RegistryFriendlyByteBuf packetBuffer, PartPos pos, net.minecraft.server.level.ServerPlayer player)
      This method can be overridden for cases when additional data needs to be sent to clients when opening offsets containers.
      Parameters:
      packetBuffer - A packet buffer that can be written to.
      pos - A part position.
      player - The player opening the offsets gui.