Class PartTypeBase<P extends IPartType<P,S>,S extends IPartState<P>>

java.lang.Object
org.cyclops.integrateddynamics.api.part.PartTypeAdapter<P,S>
org.cyclops.integrateddynamics.core.part.PartTypeBase<P,S>
All Implemented Interfaces:
INetworkEventListener<IPartNetworkElement<P,S>>, IPartType<P,S>
Direct Known Subclasses:
PartTypeConfigurable, PartTypeConnector, PartTypePanel

public abstract class PartTypeBase<P extends IPartType<P,S>,S extends IPartState<P>> extends PartTypeAdapter<P,S>
An abstract IPartType with a default implementation for creating network elements.
  • Constructor Details

  • Method Details

    • getUniqueName

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

      protected org.cyclops.cyclopscore.init.ModBase getMod()
    • getModId

      protected String getModId()
    • registerBlock

      protected void registerBlock()
      Creates and registers a block instance for this part type. This is mainly used for the block model.
    • createBlock

      protected net.minecraft.world.level.block.Block createBlock(org.cyclops.cyclopscore.config.extendedconfig.BlockConfig blockConfig)
      Factory method for creating a block instance.
      Parameters:
      blockConfig - The config to register the block for.
      Returns:
      The block instance.
    • createItem

      protected net.minecraft.world.item.Item createItem(org.cyclops.cyclopscore.config.extendedconfig.BlockConfig blockConfig, net.minecraft.world.level.block.Block block)
      Factory method for creating a item instance.
      Parameters:
      blockConfig - The block config to register the item for.
      block - The block corresponding to the item.
      Returns:
      The item instance.
    • getBlockModelPath

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

      protected String createTranslationKey()
      Specified by:
      createTranslationKey in class PartTypeAdapter<P extends IPartType<P,S>,S extends IPartState<P>>
    • createNetworkElement

      public INetworkElement createNetworkElement(IPartContainer partContainer, org.cyclops.cyclopscore.datastructure.DimPos pos, net.minecraft.core.Direction side)
      Description copied from interface: IPartType
      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

      public 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)
      Description copied from interface: IPartType
      Called when a part is right-clicked.
      Specified by:
      onPartActivated in interface IPartType<P extends IPartType<P,S>,S extends IPartState<P>>
      Overrides:
      onPartActivated in class PartTypeAdapter<P extends IPartType<P,S>,S extends IPartState<P>>
      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.
    • addDrops

      public void addDrops(PartTarget target, S state, List<net.minecraft.world.item.ItemStack> itemStacks, boolean dropMainElement, boolean saveState)
      Description copied from interface: IPartType
      Add the itemstacks to drop when this element is removed.
      Specified by:
      addDrops in interface IPartType<P extends IPartType<P,S>,S extends IPartState<P>>
      Overrides:
      addDrops in class PartTypeAdapter<P extends IPartType<P,S>,S extends IPartState<P>>
      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.
    • getBlockState

      public net.minecraft.world.level.block.state.BlockState getBlockState(IPartContainer partContainer, net.minecraft.core.Direction side)
      Description copied from interface: IPartType
      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

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

      public void loadTooltip(S state, List<net.minecraft.network.chat.Component> lines)
      Description copied from interface: IPartType
      Add tooltip lines for this aspect when this part is being hovered by a mod like WAILA.
      Specified by:
      loadTooltip in interface IPartType<P extends IPartType<P,S>,S extends IPartState<P>>
      Overrides:
      loadTooltip in class PartTypeAdapter<P extends IPartType<P,S>,S extends IPartState<P>>
      Parameters:
      state - The state.
      lines - The list to add lines to.
    • loadTooltip

      public void loadTooltip(net.minecraft.world.item.ItemStack itemStack, List<net.minecraft.network.chat.Component> lines)
      Description copied from interface: IPartType
      Add tooltip lines for this aspect when this part's item is being hovered.
      Specified by:
      loadTooltip in interface IPartType<P extends IPartType<P,S>,S extends IPartState<P>>
      Overrides:
      loadTooltip in class PartTypeAdapter<P extends IPartType<P,S>,S extends IPartState<P>>
      Parameters:
      itemStack - The itemstack.
      lines - The list to add lines to.
    • constructNetworkEventActions

      protected Map<Class<? extends INetworkEvent>,PartTypeBase.IEventAction> constructNetworkEventActions()
      Override this to register your network event actions.
      Returns:
      The event actions.
    • hasEventSubscriptions

      public final boolean hasEventSubscriptions()
      Specified by:
      hasEventSubscriptions in interface INetworkEventListener<P extends IPartType<P,S>>
      Overrides:
      hasEventSubscriptions in class PartTypeAdapter<P extends IPartType<P,S>,S extends IPartState<P>>
      Returns:
      If this should be registered to the network event bus for listening to network events.
    • getSubscribedEvents

      public final Set<Class<? extends INetworkEvent>> getSubscribedEvents()
      Specified by:
      getSubscribedEvents in interface INetworkEventListener<P extends IPartType<P,S>>
      Overrides:
      getSubscribedEvents in class PartTypeAdapter<P extends IPartType<P,S>,S extends IPartState<P>>
      Returns:
      The static set of events this listener should be subscribed to.
    • onEvent

      public final void onEvent(INetworkEvent event, IPartNetworkElement<P,S> networkElement)
      Description copied from interface: INetworkEventListener
      Can be called at any time by the INetworkEventBus. Only events in the set from INetworkEventListener.getSubscribedEvents() will be received.
      Specified by:
      onEvent in interface INetworkEventListener<P extends IPartType<P,S>>
      Overrides:
      onEvent in class PartTypeAdapter<P extends IPartType<P,S>,S extends IPartState<P>>
      Parameters:
      event - The received event.
      networkElement - The network element.
    • forceLightTransparency

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

      public void writeExtraGuiData(net.minecraft.network.FriendlyByteBuf packetBuffer, PartPos pos, net.minecraft.server.level.ServerPlayer player)
      Description copied from interface: IPartType
      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.