Interface IPartContainer

All Superinterfaces:
net.minecraftforge.common.capabilities.ICapabilityProvider, net.minecraftforge.common.capabilities.ICapabilitySerializable<net.minecraft.nbt.CompoundTag>, net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
All Known Implementing Classes:
PartContainerDefault, PartContainerTileMultipartTicking

public interface IPartContainer extends net.minecraftforge.common.capabilities.ICapabilitySerializable<net.minecraft.nbt.CompoundTag>
An interface for containers that can hold IPartTypes.
  • Method Summary

    Modifier and Type
    Method
    Description
    <P extends IPartType<P, S>, S extends IPartState<P>>
    boolean
    canAddPart(net.minecraft.core.Direction side, IPartType<P,S> part)
    Check if the given part can be added at the given side.
    getPart(net.minecraft.core.Direction side)
    Get the part of a side, can be null.
    Map<net.minecraft.core.Direction,IPartType<?,?>>
     
    getPartState(net.minecraft.core.Direction side)
    Get the state of a part.
    org.cyclops.cyclopscore.datastructure.DimPos
     
    net.minecraft.core.Direction
    getWatchingSide(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
    Get the part side the player is watching.
    boolean
    hasPart(net.minecraft.core.Direction side)
     
    boolean
     
    removePart(net.minecraft.core.Direction side, net.minecraft.world.entity.player.Player player, boolean dropMainElement, boolean saveState)
    Remove the part from a side, can return null if there was no part on that side.
    <P extends IPartType<P, S>, S extends IPartState<P>>
    void
    setPart(net.minecraft.core.Direction side, IPartType<P,S> part, IPartState<P> partState)
    Set the part for a side.
    void
    setPartState(net.minecraft.core.Direction side, IPartState partState)
    dz Set the state of a part.
    void
    Should be called every tick, updates parts.

    Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider

    getCapability, getCapability

    Methods inherited from interface net.minecraftforge.common.util.INBTSerializable

    deserializeNBT, serializeNBT
  • Method Details

    • update

      void update()
      Should be called every tick, updates parts.
    • getPosition

      org.cyclops.cyclopscore.datastructure.DimPos getPosition()
      Returns:
      The position this container is at.
    • getParts

      Map<net.minecraft.core.Direction,IPartType<?,?>> getParts()
      Returns:
      The parts inside this container.
    • hasParts

      boolean hasParts()
      Returns:
      If this container has at least one part.
    • setPart

      <P extends IPartType<P, S>, S extends IPartState<P>> void setPart(net.minecraft.core.Direction side, IPartType<P,S> part, IPartState<P> partState)
      Set the part for a side.
      Type Parameters:
      P - The type of part.
      S - The type of part state.
      Parameters:
      side - The side to place the part on.
      part - The part.
      partState - The state for this part.
    • canAddPart

      <P extends IPartType<P, S>, S extends IPartState<P>> boolean canAddPart(net.minecraft.core.Direction side, IPartType<P,S> part)
      Check if the given part can be added at the given side.
      Type Parameters:
      P - The type of part.
      S - The type of part state.
      Parameters:
      side - The side to place the part on.
      part - The part.
      Returns:
      If the part can be added.
    • getPart

      IPartType getPart(net.minecraft.core.Direction side)
      Get the part of a side, can be null.
      Parameters:
      side - The side.
      Returns:
      The part or null.
    • hasPart

      boolean hasPart(net.minecraft.core.Direction side)
      Parameters:
      side - The side.
      Returns:
      If the given side has a part.
    • removePart

      IPartType removePart(net.minecraft.core.Direction side, @Nullable net.minecraft.world.entity.player.Player player, boolean dropMainElement, boolean saveState)
      Remove the part from a side, can return null if there was no part on that side.
      Parameters:
      side - The side.
      player - The player removing the part.
      dropMainElement - If the main part element should be dropped.
      saveState - If the part state should be saved in the item.
      Returns:
      The removed part or null.
    • setPartState

      void setPartState(net.minecraft.core.Direction side, IPartState partState) throws PartStateException
      dz Set the state of a part.
      Parameters:
      side - The side.
      partState - The part state.
      Throws:
      PartStateException - If no part at the given position is available.
    • getPartState

      IPartState getPartState(net.minecraft.core.Direction side) throws PartStateException
      Get the state of a part.
      Parameters:
      side - The side.
      Returns:
      The part state.
      Throws:
      PartStateException - If no part at the given position is available.
    • getWatchingSide

      @Nullable net.minecraft.core.Direction getWatchingSide(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
      Get the part side the player is watching. This is used to determine the part the player is looking at.
      Parameters:
      world - The world.
      pos - The block position to perform a ray trace for.
      player - The player.
      Returns:
      The side the player is watching or null.