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.AsFieldNested 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
ConstructorsConstructorDescriptionEtheriumGeneratorBlockEntity(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 TypeMethodDescriptionintaddAmount(net.minecraft.core.Holder<EtheriumType> type, int amount) Adds the given amount to the stored amount for the givenEtheriumType.voidaddConnectedPosition(net.minecraft.core.BlockPos pos) Adds aBlockPosto connect.booleanintgetAmount(net.minecraft.core.Holder<EtheriumType> type) SequencedSet<net.minecraft.core.BlockPos> List<net.minecraft.core.Holder<EtheriumType>> abstract intintgetMaxAmount(net.minecraft.core.Holder<EtheriumType> type) abstract intgetTier(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) Returns the tier of the generator at the given position.voidremoveConnectedPosition(net.minecraft.core.BlockPos pos) Removes aBlockPosto connect.voidsetAmount(net.minecraft.core.Holder<EtheriumType> type, int amount) Sets the stored amount for the givenEtheriumType.intsubtractAmount(net.minecraft.core.Holder<EtheriumType> type, int amount) Subtracts the given amount to the stored amount for the givenEtheriumType.abstract voidtick(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, typeHolderMethods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachmentsMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EtheriumHandler
getOutline, getOutlineColorMethods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncDataMethods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
getModelData, handleUpdateTag, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onDataPacket, onLoad, requestModelDataUpdateMethods 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 registeredBlockEntityType.pos- TheBlockPos, as supplied byEntityBlock.newBlockEntity(BlockPos, BlockState).state- TheBlockState, as supplied byEntityBlock.newBlockEntity(BlockPos, BlockState).etheriumType- TheEtheriumTypeof 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- TheLevel.pos- TheBlockPos.state- TheBlockState.
-
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- TheLevelthe generator is in.pos- TheBlockPosat which the check should place.- Returns:
- The tier of the generator.
-
getEtheriumTypes
- Specified by:
getEtheriumTypesin interfaceEtheriumHandler- Returns:
- The
EtheriumTypes supported by the handler.
-
getAmount
- Specified by:
getAmountin interfaceEtheriumHandler- Parameters:
type- TheEtheriumTypeto get the stored amount for.- Returns:
- The amount of the
EtheriumTypestored in the handler.
-
getMaxAmount
- Specified by:
getMaxAmountin interfaceEtheriumHandler- Parameters:
type- TheEtheriumTypeto get the maximum amount for.- Returns:
- The maximum amount of the
EtheriumTypethat can be stored in the handler.
-
setAmount
Description copied from interface:EtheriumHandlerSets the stored amount for the givenEtheriumType.- Specified by:
setAmountin interfaceEtheriumHandler- Parameters:
type- TheEtheriumTypeto set the stored amount for.amount- The stored amount to set.
-
addAmount
Description copied from interface:EtheriumHandlerAdds 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:
addAmountin interfaceEtheriumHandler- Parameters:
type- TheEtheriumTypeto add the given amount for.amount- The amount to add.- Returns:
- The amount left to be added.
-
subtractAmount
Description copied from interface:EtheriumHandlerSubtracts 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:
subtractAmountin interfaceEtheriumHandler- Parameters:
type- TheEtheriumTypeto subtract the given amount for.amount- The amount to subtract.- Returns:
- The amount left to be subtracted.
-
canHaveConnectedPositions
public boolean canHaveConnectedPositions()- Specified by:
canHaveConnectedPositionsin interfaceEtheriumHandler- Returns:
- Whether the handler is allowed to have connections to other handlers.
-
getConnectedPositions
- Specified by:
getConnectedPositionsin interfaceEtheriumHandler- Returns:
- A
SequencedSetof connections to other handlers. IfEtheriumHandler.canHaveConnectedPositions()returns false, this is expected to be always empty.
-
addConnectedPosition
public void addConnectedPosition(net.minecraft.core.BlockPos pos) Description copied from interface:EtheriumHandlerAdds aBlockPosto connect. IfEtheriumHandler.canHaveConnectedPositions()returns false, this method should do nothing.- Specified by:
addConnectedPositionin interfaceEtheriumHandler- Parameters:
pos- TheBlockPosto add.
-
removeConnectedPosition
public void removeConnectedPosition(net.minecraft.core.BlockPos pos) Description copied from interface:EtheriumHandlerRemoves aBlockPosto connect. IfEtheriumHandler.canHaveConnectedPositions()returns false, this method should do nothing.- Specified by:
removeConnectedPositionin interfaceEtheriumHandler- Parameters:
pos- TheBlockPosto remove.
-