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
Modifier and TypeClassDescriptionstatic 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
ConstructorDescriptionBlockEntityMechanicalMachine
(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 TypeMethodDescriptionboolean
boolean
boolean
canWork()
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.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
getSleep()
boolean
hasWork()
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.integrateddynamics.core.blockentity.BlockEntityCableConnectableInventory
afterNetworkReAlive, getCable, getConnected, getInventory, getNetwork, getNetworkCarrier, onChunkUnloaded, read, saveAdditional
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
- Specified by:
getNetworkElementProvider
in 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:
createInventory
in 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:
receiveEnergy
in interfacenet.neoforged.neoforge.energy.IEnergyStorage
-
extractEnergy
public int extractEnergy(int maxExtract, boolean simulate) - Specified by:
extractEnergy
in interfacenet.neoforged.neoforge.energy.IEnergyStorage
-
getEnergyStored
public int getEnergyStored()- Specified by:
getEnergyStored
in interfacenet.neoforged.neoforge.energy.IEnergyStorage
-
canExtract
public boolean canExtract()- Specified by:
canExtract
in interfacenet.neoforged.neoforge.energy.IEnergyStorage
-
canReceive
public boolean canReceive()- Specified by:
canReceive
in interfacenet.neoforged.neoforge.energy.IEnergyStorage
-