Class PartContainerDefault

java.lang.Object
org.cyclops.integrateddynamics.capability.partcontainer.PartContainerDefault
All Implemented Interfaces:
net.minecraftforge.common.capabilities.ICapabilityProvider, net.minecraftforge.common.capabilities.ICapabilitySerializable<net.minecraft.nbt.CompoundTag>, net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>, IPartContainer
Direct Known Subclasses:
PartContainerTileMultipartTicking

public abstract class PartContainerDefault extends Object implements IPartContainer
Default implementation of an IPartContainer.
  • Field Details

  • Constructor Details

    • PartContainerDefault

      public PartContainerDefault()
  • Method Details

    • update

      public void update()
      Description copied from interface: IPartContainer
      Should be called every tick, updates parts.
      Specified by:
      update in interface IPartContainer
    • getPosition

      public org.cyclops.cyclopscore.datastructure.DimPos getPosition()
      Specified by:
      getPosition in interface IPartContainer
      Returns:
      The position this container is at.
    • getParts

      public Map<net.minecraft.core.Direction,IPartType<?,?>> getParts()
      Specified by:
      getParts in interface IPartContainer
      Returns:
      The parts inside this container.
    • hasParts

      public boolean hasParts()
      Specified by:
      hasParts in interface IPartContainer
      Returns:
      If this container has at least one part.
    • canAddPart

      public <P extends IPartType<P, S>, S extends IPartState<P>> boolean canAddPart(net.minecraft.core.Direction side, IPartType<P,S> part)
      Description copied from interface: IPartContainer
      Check if the given part can be added at the given side.
      Specified by:
      canAddPart in interface IPartContainer
      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.
    • setPart

      public <P extends IPartType<P, S>, S extends IPartState<P>> void setPart(net.minecraft.core.Direction side, IPartType<P,S> part, IPartState<P> partState)
      Description copied from interface: IPartContainer
      Set the part for a side.
      Specified by:
      setPart in interface IPartContainer
      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.
    • getPart

      public IPartType getPart(net.minecraft.core.Direction side)
      Description copied from interface: IPartContainer
      Get the part of a side, can be null.
      Specified by:
      getPart in interface IPartContainer
      Parameters:
      side - The side.
      Returns:
      The part or null.
    • hasPart

      public boolean hasPart(net.minecraft.core.Direction side)
      Specified by:
      hasPart in interface IPartContainer
      Parameters:
      side - The side.
      Returns:
      If the given side has a part.
    • removePart

      public IPartType removePart(net.minecraft.core.Direction side, net.minecraft.world.entity.player.Player player, boolean dropMainElement, boolean saveState)
      Description copied from interface: IPartContainer
      Remove the part from a side, can return null if there was no part on that side.
      Specified by:
      removePart in interface IPartContainer
      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

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

      public IPartState getPartState(net.minecraft.core.Direction side) throws PartStateException
      Description copied from interface: IPartContainer
      Get the state of a part.
      Specified by:
      getPartState in interface IPartContainer
      Parameters:
      side - The side.
      Returns:
      The part state.
      Throws:
      PartStateException - If no part at the given position is available.
    • getCapability

      public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable net.minecraft.core.Direction facing)
      Specified by:
      getCapability in interface net.minecraftforge.common.capabilities.ICapabilityProvider
    • serializeNBT

      public net.minecraft.nbt.CompoundTag serializeNBT()
      Specified by:
      serializeNBT in interface net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
    • deserializeNBT

      public void deserializeNBT(net.minecraft.nbt.CompoundTag tag)
      Specified by:
      deserializeNBT in interface net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
    • onPartsChanged

      protected void onPartsChanged()
    • setChanged

      protected abstract void setChanged()
    • sendUpdate

      protected abstract void sendUpdate()
    • getLevel

      protected abstract net.minecraft.world.level.Level getLevel()
    • getPos

      protected abstract net.minecraft.core.BlockPos getPos()
    • getNetwork

      protected abstract INetwork getNetwork()
    • getPartNetwork

      protected net.minecraftforge.common.util.LazyOptional<IPartNetwork> getPartNetwork()
    • getPartData

      public org.cyclops.cyclopscore.datastructure.EnumFacingMap<PartHelpers.PartStateHolder<?,?>> getPartData()
      Returns:
      The raw part data.
    • setPartData

      public void setPartData(Map<net.minecraft.core.Direction,PartHelpers.PartStateHolder<?,?>> partData)
      Override the part data.
      Parameters:
      partData - The raw part data.
    • silentResetPartData

      public void silentResetPartData()
      Reset the part data without signaling any neighbours or the network. Is used in block conversion.