Class EtheriumGeneratorBlockEntity

java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
at.minecraftschurli.mods.arsmagicalegacy.api.etherium.EtheriumGeneratorBlockEntity
All Implemented Interfaces:
EtheriumHandler, net.minecraft.core.TypedInstance<net.minecraft.world.level.block.entity.BlockEntityType<?>>, net.minecraft.util.debug.DebugValueSource, net.neoforged.neoforge.attachment.IAttachmentHolder, net.neoforged.neoforge.common.extensions.IBlockEntityExtension

public abstract class EtheriumGeneratorBlockEntity extends net.minecraft.world.level.block.entity.BlockEntity implements EtheriumHandler
Simple implementation of an etherium generator, as used by the three generators in the base mod (Obelisk, Celestial Prism and Black Aurem).
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder

    net.neoforged.neoforge.attachment.AttachmentHolder.AsField

    Nested classes/interfaces inherited from interface net.minecraft.util.debug.DebugValueSource

    net.minecraft.util.debug.DebugValueSource.Registration, net.minecraft.util.debug.DebugValueSource.ValueGetter<T>
  • Field Summary

    Fields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder

    ATTACHMENTS_NBT_KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
    EtheriumGeneratorBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<?> type, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.resources.ResourceKey<EtheriumType> etheriumType)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    addAmount(net.minecraft.core.Holder<EtheriumType> type, int amount)
    Adds the given amount to the stored amount for the given EtheriumType.
    void
    addConnectedPosition(net.minecraft.core.BlockPos pos)
    Adds a BlockPos to connect.
    boolean
     
    int
    getAmount(net.minecraft.core.Holder<EtheriumType> type)
     
    SequencedSet<net.minecraft.core.BlockPos>
     
    List<net.minecraft.core.Holder<EtheriumType>>
     
    abstract int
     
    int
    getMaxAmount(net.minecraft.core.Holder<EtheriumType> type)
     
    abstract int
    getTier(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
    Returns the tier of the generator at the given position.
    void
    removeConnectedPosition(net.minecraft.core.BlockPos pos)
    Removes a BlockPos to connect.
    void
    setAmount(net.minecraft.core.Holder<EtheriumType> type, int amount)
    Sets the stored amount for the given EtheriumType.
    int
    subtractAmount(net.minecraft.core.Holder<EtheriumType> type, int amount)
    Subtracts the given amount to the stored amount for the given EtheriumType.
    abstract void
    tick(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
    Ticks the block entity.

    Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity

    addEntityType, applyComponents, applyComponentsFromItemStack, clearRemoved, collectComponents, components, fillCrashReportCategory, getAndClearAttachmentTypesToSync, getBlockPos, getBlockState, getLevel, getNameForReporting, getPersistentData, getPosFromTag, getType, getUpdatePacket, getUpdateTag, hasLevel, isRemoved, isValidBlockState, loadCustomOnly, loadStatic, loadWithComponents, parseCustomNameSafe, preRemoveSideEffects, problemPath, registerDebugValues, removeComponentsFromTag, removeData, saveCustomOnly, saveCustomOnly, saveWithFullMetadata, saveWithFullMetadata, saveWithId, saveWithoutMetadata, saveWithoutMetadata, setBlockState, setChanged, setComponents, setData, setLevel, setRemoved, syncData, triggerEvent, typeHolder

    Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder

    getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachments

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface EtheriumHandler

    getOutline, getOutlineColor

    Methods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder

    getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncData

    Methods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension

    getModelData, handleUpdateTag, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onDataPacket, onLoad, requestModelDataUpdate

    Methods inherited from interface net.minecraft.core.TypedInstance

    is, is, is, is, is, tags
  • Constructor Details

    • EtheriumGeneratorBlockEntity

      public EtheriumGeneratorBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<?> type, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.resources.ResourceKey<EtheriumType> etheriumType)
      Parameters:
      type - The registered BlockEntityType.
      pos - The BlockPos, as supplied by EntityBlock.newBlockEntity(BlockPos, BlockState).
      state - The BlockState, as supplied by EntityBlock.newBlockEntity(BlockPos, BlockState).
      etheriumType - The EtheriumType of the generator.
  • Method Details

    • tick

      public abstract void tick(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
      Ticks the block entity.
      Parameters:
      level - The Level.
      pos - The BlockPos.
      state - The BlockState.
    • getMaxAmount

      public abstract int getMaxAmount()
      Returns:
      The max etherium amount that can be stored. Usually resolved from a config value or similar.
    • getTier

      public abstract int getTier(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
      Returns the tier of the generator at the given position.
      Parameters:
      level - The Level the generator is in.
      pos - The BlockPos at which the check should place.
      Returns:
      The tier of the generator.
    • getEtheriumTypes

      public List<net.minecraft.core.Holder<EtheriumType>> getEtheriumTypes()
      Specified by:
      getEtheriumTypes in interface EtheriumHandler
      Returns:
      The EtheriumTypes supported by the handler.
    • getAmount

      public int getAmount(net.minecraft.core.Holder<EtheriumType> type)
      Specified by:
      getAmount in interface EtheriumHandler
      Parameters:
      type - The EtheriumType to get the stored amount for.
      Returns:
      The amount of the EtheriumType stored in the handler.
    • getMaxAmount

      public int getMaxAmount(net.minecraft.core.Holder<EtheriumType> type)
      Specified by:
      getMaxAmount in interface EtheriumHandler
      Parameters:
      type - The EtheriumType to get the maximum amount for.
      Returns:
      The maximum amount of the EtheriumType that can be stored in the handler.
    • setAmount

      public void setAmount(net.minecraft.core.Holder<EtheriumType> type, int amount)
      Description copied from interface: EtheriumHandler
      Sets the stored amount for the given EtheriumType.
      Specified by:
      setAmount in interface EtheriumHandler
      Parameters:
      type - The EtheriumType to set the stored amount for.
      amount - The stored amount to set.
    • addAmount

      public int addAmount(net.minecraft.core.Holder<EtheriumType> type, int amount)
      Description copied from interface: EtheriumHandler

      Adds the given amount to the stored amount for the given EtheriumType.

      Returns the amount left to be added. For example, if all etherium was successfully added, 0 will be returned. If the handler is full, the amount will be returned.

      Specified by:
      addAmount in interface EtheriumHandler
      Parameters:
      type - The EtheriumType to add the given amount for.
      amount - The amount to add.
      Returns:
      The amount left to be added.
    • subtractAmount

      public int subtractAmount(net.minecraft.core.Holder<EtheriumType> type, int amount)
      Description copied from interface: EtheriumHandler

      Subtracts the given amount to the stored amount for the given EtheriumType.

      Returns the amount left to be subtracted. For example, if all etherium was successfully subtracted, 0 will be returned. If the handler is full, the amount will be returned.

      Specified by:
      subtractAmount in interface EtheriumHandler
      Parameters:
      type - The EtheriumType to subtract the given amount for.
      amount - The amount to subtract.
      Returns:
      The amount left to be subtracted.
    • canHaveConnectedPositions

      public boolean canHaveConnectedPositions()
      Specified by:
      canHaveConnectedPositions in interface EtheriumHandler
      Returns:
      Whether the handler is allowed to have connections to other handlers.
    • getConnectedPositions

      public SequencedSet<net.minecraft.core.BlockPos> getConnectedPositions()
      Specified by:
      getConnectedPositions in interface EtheriumHandler
      Returns:
      A SequencedSet of connections to other handlers. If EtheriumHandler.canHaveConnectedPositions() returns false, this is expected to be always empty.
    • addConnectedPosition

      public void addConnectedPosition(net.minecraft.core.BlockPos pos)
      Description copied from interface: EtheriumHandler
      Adds a BlockPos to connect. If EtheriumHandler.canHaveConnectedPositions() returns false, this method should do nothing.
      Specified by:
      addConnectedPosition in interface EtheriumHandler
      Parameters:
      pos - The BlockPos to add.
    • removeConnectedPosition

      public void removeConnectedPosition(net.minecraft.core.BlockPos pos)
      Description copied from interface: EtheriumHandler
      Removes a BlockPos to connect. If EtheriumHandler.canHaveConnectedPositions() returns false, this method should do nothing.
      Specified by:
      removeConnectedPosition in interface EtheriumHandler
      Parameters:
      pos - The BlockPos to remove.