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.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 ClassesModifier and TypeClassDescriptionstatic classstatic classBlockEntityMechanicalMachine.Ticker<RCK,R extends net.minecraft.world.item.crafting.Recipe<?>, BE extends BlockEntityMechanicalMachine<RCK, R>> 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, worldPositionFields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEY -
Constructor Summary
ConstructorsConstructorDescriptionBlockEntityMechanicalMachine(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 TypeMethodDescriptionbooleanbooleanbooleancanWork()protected abstract org.cyclops.cyclopscore.datastructure.SingleCache.ICacheUpdater<RCK, Optional<net.minecraft.world.item.crafting.RecipeHolder<R>>> protected org.cyclops.cyclopscore.inventory.SimpleInventorycreateInventory(int inventorySize, int stackSize) protected intdrainEnergy(int amount, boolean simulate) Drain energy from the internal buffer or the attached network.intextractEnergy(int maxExtract, boolean simulate) protected intextractEnergyInternal(int energy, boolean simulate) protected abstract booleanfinalizeRecipe(R recipe, boolean simulate) Finalize a recipe.protected abstract RCKintabstract intintabstract int[]intabstract int[]intabstract intgetRecipeDuration(net.minecraft.world.item.crafting.RecipeHolder<R> recipe) protected abstract net.minecraft.world.item.crafting.RecipeType<? extends R> intgetSleep()booleanhasWork()booleanbooleanvoidintreceiveEnergy(int maxReceive, boolean simulate) voidsetEnergy(int energy) voidsetProgress(int progress) voidsetSleep(int sleep) abstract voidsetWorking(boolean working) Set the new working state.voidUpdate the working state.abstract booleanMethods inherited from class org.cyclops.integrateddynamics.core.blockentity.BlockEntityCableConnectableInventory
afterNetworkReAlive, getCable, getConnected, getInventory, getNetwork, getNetworkCarrier, onChunkUnloaded, preRemoveSideEffects, read, saveAdditionalMethods inherited from class org.cyclops.cyclopscore.blockentity.CyclopsBlockEntity
canInteractWith, getRotation, getUpdateBackoff, getUpdateBackoffTicks, getUpdatePacket, getUpdateTag, loadAdditional, onDirty, readGeneratedFieldsFromNBT, sendUpdate, setUpdateBackoff, shouldSendUpdate, transformFacingForRotation, unsetSendUpdate, writeGeneratedFieldsToNBT, writeToItemStackMethods inherited from class net.minecraft.world.level.block.entity.BlockEntity
addEntityType, applyComponents, applyComponentsFromItemStack, applyImplicitComponents, clearRemoved, collectComponents, collectImplicitComponents, components, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getNameForReporting, getPersistentData, getPosFromTag, getType, hasLevel, isRemoved, isValidBlockState, loadCustomOnly, loadStatic, loadWithComponents, parseCustomNameSafe, problemPath, removeComponentsFromTag, removeData, saveCustomOnly, saveCustomOnly, saveWithFullMetadata, saveWithFullMetadata, saveWithId, saveWithoutMetadata, saveWithoutMetadata, setBlockState, setChanged, setChanged, setComponents, setData, setLevel, setRemoved, syncData, triggerEventMethods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachmentsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncDataMethods inherited from interface org.cyclops.cyclopscore.blockentity.IBlockEntityDelayedTickable
reduceUpdateBackoff, sendImmediateUpdateMethods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
getModelData, handleUpdateTag, invalidateCapabilities, onDataPacket, onLoad, requestModelDataUpdateMethods 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
- Specified by:
getNetworkElementProviderin classBlockEntityCableConnectableInventory
-
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
-
onTankChanged
public void onTankChanged() -
createInventory
protected org.cyclops.cyclopscore.inventory.SimpleInventory createInventory(int inventorySize, int stackSize) - Overrides:
createInventoryin classBlockEntityCableConnectableInventory
-
getRecipeRegistry
- Returns:
- The recipe registry this machine should work with..
-
getCurrentRecipeCacheKey
- Returns:
- The current recipe cache key that is used to determine the current input of a recipe.
-
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
- Parameters:
recipe- A recipe.- Returns:
- The duration of a given recipe.
-
finalizeRecipe
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:
receiveEnergyin interfacenet.neoforged.neoforge.energy.IEnergyStorage
-
extractEnergy
public int extractEnergy(int maxExtract, boolean simulate) - Specified by:
extractEnergyin interfacenet.neoforged.neoforge.energy.IEnergyStorage
-
getEnergyStored
public int getEnergyStored()- Specified by:
getEnergyStoredin interfacenet.neoforged.neoforge.energy.IEnergyStorage
-
canExtract
public boolean canExtract()- Specified by:
canExtractin interfacenet.neoforged.neoforge.energy.IEnergyStorage
-
canReceive
public boolean canReceive()- Specified by:
canReceivein interfacenet.neoforged.neoforge.energy.IEnergyStorage
-