Class BlockEntityMechanicalMachine<RCK,R extends net.minecraft.world.item.crafting.Recipe<?>>

java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
org.cyclops.cyclopscore.blockentity.CyclopsBlockEntityCommon
org.cyclops.cyclopscore.blockentity.CyclopsBlockEntity
org.cyclops.integrateddynamics.core.blockentity.BlockEntityCableConnectableInventory
org.cyclops.integrateddynamics.core.blockentity.BlockEntityMechanicalMachine<RCK,R>
Type Parameters:
RCK - The recipe cache key type.
R - The recipe type.
All Implemented Interfaces:
net.neoforged.neoforge.attachment.IAttachmentHolder, net.neoforged.neoforge.common.extensions.IBlockEntityExtension, net.neoforged.neoforge.energy.IEnergyStorage, org.cyclops.cyclopscore.blockentity.IBlockEntityDelayedTickable, org.cyclops.cyclopscore.persist.IDirtyMarkListener, org.cyclops.cyclopscore.persist.nbt.INBTProvider
Direct Known Subclasses:
BlockEntityMechanicalDryingBasin, BlockEntityMechanicalSqueezer

public abstract class BlockEntityMechanicalMachine<RCK,R extends net.minecraft.world.item.crafting.Recipe<?>> extends BlockEntityCableConnectableInventory implements net.neoforged.neoforge.energy.IEnergyStorage
An abstract machine base tile entity that is able to process recipes by consuming energy.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
    static class 
    BlockEntityMechanicalMachine.Ticker<RCK,R extends net.minecraft.world.item.crafting.Recipe<?>,BE extends BlockEntityMechanicalMachine<RCK,R>>
     

    Nested classes/interfaces inherited from class net.minecraft.world.level.block.entity.BlockEntity

    net.minecraft.world.level.block.entity.BlockEntity.DataComponentInput

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

    net.neoforged.neoforge.attachment.AttachmentHolder.AsField
  • Field Summary

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

    level, remove, worldPosition

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

    ATTACHMENTS_NBT_KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockEntityMechanicalMachine(net.minecraft.world.level.block.entity.BlockEntityType<?> type, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState, int inventorySize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    boolean
     
    boolean
     
    protected abstract org.cyclops.cyclopscore.datastructure.SingleCache.ICacheUpdater<RCK,Optional<net.minecraft.world.item.crafting.RecipeHolder<R>>>
     
    protected org.cyclops.cyclopscore.inventory.SimpleInventory
    createInventory(int inventorySize, int stackSize)
     
    protected int
    drainEnergy(int amount, boolean simulate)
    Drain energy from the internal buffer or the attached network.
    int
    extractEnergy(int maxExtract, boolean simulate)
     
    protected int
    extractEnergyInternal(int energy, boolean simulate)
     
    protected abstract boolean
    finalizeRecipe(R recipe, boolean simulate)
    Finalize a recipe.
    Optional<net.minecraft.world.item.crafting.RecipeHolder<R>>
     
    protected abstract RCK
     
    int
     
    abstract int
     
     
    int
     
    abstract int[]
     
    int
     
     
    abstract int[]
     
    int
     
    abstract int
    getRecipeDuration(net.minecraft.world.item.crafting.RecipeHolder<R> recipe)
     
    protected abstract net.minecraft.world.item.crafting.RecipeType<? extends R>
     
    int
     
    boolean
     
    boolean
     
    boolean
     
    void
     
    int
    receiveEnergy(int maxReceive, boolean simulate)
     
    void
    setEnergy(int energy)
     
    void
    setProgress(int progress)
     
    void
    setSleep(int sleep)
     
    abstract void
    setWorking(boolean working)
    Set the new working state.
    void
    Update the working state.
    abstract boolean
     

    Methods inherited from class org.cyclops.cyclopscore.blockentity.CyclopsBlockEntity

    onDataPacket, onUpdateReceived

    Methods inherited from class org.cyclops.cyclopscore.blockentity.CyclopsBlockEntityCommon

    canInteractWith, getRotation, getUpdateBackoff, getUpdateBackoffTicks, getUpdatePacket, getUpdateTag, loadAdditional, onDirty, readGeneratedFieldsFromNBT, sendUpdate, setUpdateBackoff, shouldSendUpdate, transformFacingForRotation, unsetSendUpdate, writeGeneratedFieldsToNBT, writeToItemStack

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

    addEntityType, applyComponents, applyComponentsFromItemStack, applyImplicitComponents, clearRemoved, collectComponents, collectImplicitComponents, components, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPersistentData, getPosFromTag, getType, hasLevel, isRemoved, isValidBlockState, loadCustomOnly, loadStatic, loadWithComponents, onlyOpCanSetNbt, parseCustomNameSafe, removeComponentsFromTag, removeData, saveCustomAndMetadata, saveCustomOnly, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setChanged, setComponents, setData, setLevel, setRemoved, triggerEvent

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

    deserializeAttachments, getData, getExistingData, hasAttachments, hasData, serializeAttachments

    Methods inherited from class java.lang.Object

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

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

    getData, getExistingData, hasData, removeData, setData

    Methods inherited from interface org.cyclops.cyclopscore.blockentity.IBlockEntityDelayedTickable

    reduceUpdateBackoff, sendImmediateUpdate

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

    getModelData, handleUpdateTag, hasCustomOutlineRendering, invalidateCapabilities, onLoad, requestModelDataUpdate

    Methods inherited from interface net.neoforged.neoforge.energy.IEnergyStorage

    getMaxEnergyStored
  • Constructor Details

    • BlockEntityMechanicalMachine

      public BlockEntityMechanicalMachine(net.minecraft.world.level.block.entity.BlockEntityType<?> type, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState, int inventorySize)
  • Method Details

    • getNetworkElementProvider

      public INetworkElementProvider getNetworkElementProvider()
      Specified by:
      getNetworkElementProvider in class BlockEntityCableConnectableInventory
    • createCacheUpdater

      protected abstract org.cyclops.cyclopscore.datastructure.SingleCache.ICacheUpdater<RCK,Optional<net.minecraft.world.item.crafting.RecipeHolder<R>>> createCacheUpdater()
      Returns:
      A new cache updater instance.
    • getInputSlots

      public abstract int[] getInputSlots()
      Returns:
      The available input slots.
    • getOutputSlots

      public abstract int[] getOutputSlots()
      Returns:
      The available output slots.
    • wasWorking

      public abstract boolean wasWorking()
      Returns:
      If the machine was in a working state.
    • setWorking

      public abstract void setWorking(boolean working)
      Set the new working state.
      Parameters:
      working - If the machine is working.
    • hasWork

      public boolean hasWork()
      Returns:
      If the machine currently has any work to process.
    • isWorking

      public boolean isWorking()
      Returns:
      If the machine is currently working.
    • canWork

      public boolean canWork()
      Returns:
      If the machine is able to work in its current state. This for example takes into account the available energy.
    • isSleeping

      public boolean isSleeping()
      Returns:
      If the machine is currently sleeping due to a recipe that could not be finalized.
    • setProgress

      public void setProgress(int progress)
    • setSleep

      public void setSleep(int sleep)
    • getSleep

      public int getSleep()
    • getEnergyNetwork

      public Optional<IEnergyNetwork> getEnergyNetwork()
    • onTankChanged

      public void onTankChanged()
    • createInventory

      protected org.cyclops.cyclopscore.inventory.SimpleInventory createInventory(int inventorySize, int stackSize)
      Overrides:
      createInventory in class BlockEntityCableConnectableInventory
    • getRecipeRegistry

      protected abstract net.minecraft.world.item.crafting.RecipeType<? extends R> getRecipeRegistry()
      Returns:
      The recipe registry this machine should work with..
    • getCurrentRecipeCacheKey

      protected abstract RCK getCurrentRecipeCacheKey()
      Returns:
      The current recipe cache key that is used to determine the current input of a recipe.
    • getCurrentRecipe

      public Optional<net.minecraft.world.item.crafting.RecipeHolder<R>> getCurrentRecipe()
      Returns:
      The currently applicable recipe.
    • getProgress

      public int getProgress()
      Returns:
      The current recipe progress, going from 0 to maxProgress.
    • getMaxProgress

      public int getMaxProgress()
      Returns:
      The current maximum progress.
    • getRecipeDuration

      public abstract int getRecipeDuration(net.minecraft.world.item.crafting.RecipeHolder<R> recipe)
      Parameters:
      recipe - A recipe.
      Returns:
      The duration of a given recipe.
    • finalizeRecipe

      protected abstract boolean finalizeRecipe(R recipe, boolean simulate)
      Finalize a recipe. This should insert the recipe output in the machine, and consume the input. If the output could not be added, this method should return false.
      Parameters:
      recipe - A recipe.
      simulate - If finalization should be simulated.
      Returns:
      If finalization was successful.
    • updateWorkingState

      public void updateWorkingState()
      Update the working state.
    • getEnergyConsumptionRate

      public abstract int getEnergyConsumptionRate()
      Returns:
      The energy consumption rate per (working) tick.
    • drainEnergy

      protected int drainEnergy(int amount, boolean simulate)
      Drain energy from the internal buffer or the attached network.
      Parameters:
      amount - The amount of energy.
      simulate - If drainage should be simulated.
      Returns:
      The drained energy.
    • extractEnergyInternal

      protected int extractEnergyInternal(int energy, boolean simulate)
    • getEnergy

      public int getEnergy()
    • setEnergy

      public void setEnergy(int energy)
    • receiveEnergy

      public int receiveEnergy(int maxReceive, boolean simulate)
      Specified by:
      receiveEnergy in interface net.neoforged.neoforge.energy.IEnergyStorage
    • extractEnergy

      public int extractEnergy(int maxExtract, boolean simulate)
      Specified by:
      extractEnergy in interface net.neoforged.neoforge.energy.IEnergyStorage
    • getEnergyStored

      public int getEnergyStored()
      Specified by:
      getEnergyStored in interface net.neoforged.neoforge.energy.IEnergyStorage
    • canExtract

      public boolean canExtract()
      Specified by:
      canExtract in interface net.neoforged.neoforge.energy.IEnergyStorage
    • canReceive

      public boolean canReceive()
      Specified by:
      canReceive in interface net.neoforged.neoforge.energy.IEnergyStorage