Class BlockEntityMechanicalMachine<RCK,R extends net.minecraft.world.item.crafting.Recipe>
java.lang.Object
net.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.world.level.block.entity.BlockEntity>
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.minecraftforge.common.capabilities.ICapabilityProvider
,net.minecraftforge.common.capabilities.ICapabilityProviderImpl<net.minecraft.world.level.block.entity.BlockEntity>
,net.minecraftforge.common.capabilities.ICapabilitySerializable<net.minecraft.nbt.CompoundTag>
,net.minecraftforge.common.extensions.IForgeBlockEntity
,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
,net.minecraftforge.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.minecraftforge.energy.IEnergyStorage
An abstract machine base tile entity that is able to process recipes by consuming energy.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
BlockEntityMechanicalMachine.Ticker<RCK,
R extends net.minecraft.world.item.crafting.Recipe, BE extends BlockEntityMechanicalMachine<RCK, R>> Nested classes/interfaces inherited from class net.minecraftforge.common.capabilities.CapabilityProvider
net.minecraftforge.common.capabilities.CapabilityProvider.AsField<B extends net.minecraftforge.common.capabilities.ICapabilityProviderImpl<B>>
-
Field Summary
Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity
level, remove, worldPosition
Fields inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity
INFINITE_EXTENT_AABB
-
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 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
net.minecraftforge.common.util.LazyOptional<IEnergyNetwork>
int
abstract int[]
int
abstract int[]
int
abstract int
getRecipeDuration
(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, onChunkUnloaded, read, saveAdditional
Methods inherited from class org.cyclops.cyclopscore.blockentity.CyclopsBlockEntity
addCapabilityInternal, addCapabilitySided, canInteractWith, getCapability, getRotation, getStoredCapabilities, getUpdateBackoff, getUpdateBackoffTicks, getUpdatePacket, getUpdateTag, invalidateCaps, load, onDataPacket, onDirty, onLoad, onUpdateReceived, readGeneratedFieldsFromNBT, sendUpdate, setUpdateBackoff, shouldSendUpdate, transformFacingForRotation, unsetSendUpdate, writeGeneratedFieldsToNBT, writeToItemStack
Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity
addEntityType, clearRemoved, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPersistentData, getPosFromTag, getType, hasLevel, isRemoved, loadStatic, onlyOpCanSetNbt, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setChanged, setLevel, setRemoved, triggerEvent
Methods inherited from class net.minecraftforge.common.capabilities.CapabilityProvider
areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, gatherCapabilities, getCapabilities, reviveCaps, serializeCaps
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cyclops.cyclopscore.blockentity.IBlockEntityDelayedTickable
reduceUpdateBackoff, sendImmediateUpdate
Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
Methods inherited from interface net.minecraftforge.energy.IEnergyStorage
getMaxEnergyStored
Methods inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity
deserializeNBT, getModelData, getRenderBoundingBox, handleUpdateTag, hasCustomOutlineRendering, requestModelDataUpdate, serializeNBT
-
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
-
createCacheUpdater
protected abstract org.cyclops.cyclopscore.datastructure.SingleCache.ICacheUpdater<RCK,Optional<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.minecraftforge.energy.IEnergyStorage
-
extractEnergy
public int extractEnergy(int maxExtract, boolean simulate) - Specified by:
extractEnergy
in interfacenet.minecraftforge.energy.IEnergyStorage
-
getEnergyStored
public int getEnergyStored()- Specified by:
getEnergyStored
in interfacenet.minecraftforge.energy.IEnergyStorage
-
canExtract
public boolean canExtract()- Specified by:
canExtract
in interfacenet.minecraftforge.energy.IEnergyStorage
-
canReceive
public boolean canReceive()- Specified by:
canReceive
in interfacenet.minecraftforge.energy.IEnergyStorage
-