Class PartContainerDefault
java.lang.Object
org.cyclops.integrateddynamics.capability.partcontainer.PartContainerDefault
- All Implemented Interfaces:
org.cyclops.cyclopscore.persist.nbt.INBTSerializable,IPartContainer
- Direct Known Subclasses:
PartContainerTileMultipartTicking
Default implementation of an
IPartContainer.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cyclops.cyclopscore.persist.nbt.INBTSerializable
org.cyclops.cyclopscore.persist.nbt.INBTSerializable.SelfNBTClassType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.cyclops.cyclopscore.datastructure.EnumFacingMap<PartHelpers.PartStateHolder<?, ?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<P extends IPartType<P,S>, S extends IPartState<P>>
booleancanAddPart(net.minecraft.core.Direction side, IPartType<P, S> part) Check if the given part can be added at the given side.voidfromValueInput(net.minecraft.world.level.storage.ValueInput valueInput) <T> Optional<T> getCapability(PartCapability<T> partCapability, INetwork network, IPartNetwork partNetwork, PartTarget target) Get a part capability.protected abstract net.minecraft.world.level.LevelgetLevel()protected abstract INetworkgetPart(net.minecraft.core.Direction side) Get the part of a side, can be null.org.cyclops.cyclopscore.datastructure.EnumFacingMap<PartHelpers.PartStateHolder<?, ?>> protected Optional<IPartNetwork> getParts()getPartState(net.minecraft.core.Direction side) Get the state of a part.protected abstract net.minecraft.core.BlockPosgetPos()org.cyclops.cyclopscore.datastructure.DimPosbooleanhasPart(net.minecraft.core.Direction side) booleanhasParts()protected voidremovePart(net.minecraft.core.Direction side, net.minecraft.world.entity.player.Player player, boolean dropMainElement, boolean saveState) Remove the part from a side, can return null if there was no part on that side.protected abstract voidprotected abstract void<P extends IPartType<P,S>, S extends IPartState<P>>
voidsetPart(net.minecraft.core.Direction side, IPartType<P, S> part, IPartState<P> partState) Set the part for a side.voidsetPartData(Map<net.minecraft.core.Direction, PartHelpers.PartStateHolder<?, ?>> partData) Override the part data.voidsetPartState(net.minecraft.core.Direction side, IPartState partState) dz Set the state of a part.voidReset the part data without signaling any neighbours or the network.voidtoValueOutput(net.minecraft.world.level.storage.ValueOutput valueOutput) voidupdate()Should be called every tick, updates parts.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cyclops.integrateddynamics.api.part.IPartContainer
getWatchingSide
-
Field Details
-
partData
protected final org.cyclops.cyclopscore.datastructure.EnumFacingMap<PartHelpers.PartStateHolder<?,?>> partData
-
-
Constructor Details
-
PartContainerDefault
public PartContainerDefault()
-
-
Method Details
-
update
public void update()Description copied from interface:IPartContainerShould be called every tick, updates parts.- Specified by:
updatein interfaceIPartContainer
-
getPosition
public org.cyclops.cyclopscore.datastructure.DimPos getPosition()- Specified by:
getPositionin interfaceIPartContainer- Returns:
- The position this container is at.
-
getParts
- Specified by:
getPartsin interfaceIPartContainer- Returns:
- The parts inside this container.
-
hasParts
public boolean hasParts()- Specified by:
hasPartsin interfaceIPartContainer- Returns:
- If this container has at least one part.
-
canAddPart
public <P extends IPartType<P,S>, boolean canAddPartS extends IPartState<P>> (net.minecraft.core.Direction side, IPartType<P, S> part) Description copied from interface:IPartContainerCheck if the given part can be added at the given side.- Specified by:
canAddPartin interfaceIPartContainer- Type Parameters:
P- The type of part.S- The type of part state.- Parameters:
side- The side to place the part on.part- The part.- Returns:
- If the part can be added.
-
setPart
public <P extends IPartType<P,S>, void setPartS extends IPartState<P>> (net.minecraft.core.Direction side, IPartType<P, S> part, IPartState<P> partState) Description copied from interface:IPartContainerSet the part for a side.- Specified by:
setPartin interfaceIPartContainer- Type Parameters:
P- The type of part.S- The type of part state.- Parameters:
side- The side to place the part on.part- The part.partState- The state for this part.
-
getPart
Description copied from interface:IPartContainerGet the part of a side, can be null.- Specified by:
getPartin interfaceIPartContainer- Parameters:
side- The side.- Returns:
- The part or null.
-
hasPart
public boolean hasPart(net.minecraft.core.Direction side) - Specified by:
hasPartin interfaceIPartContainer- Parameters:
side- The side.- Returns:
- If the given side has a part.
-
removePart
public IPartType removePart(net.minecraft.core.Direction side, net.minecraft.world.entity.player.Player player, boolean dropMainElement, boolean saveState) Description copied from interface:IPartContainerRemove the part from a side, can return null if there was no part on that side.- Specified by:
removePartin interfaceIPartContainer- Parameters:
side- The side.player- The player removing the part.dropMainElement- If the main part element should be dropped.saveState- If the part state should be saved in the item.- Returns:
- The removed part or null.
-
setPartState
public void setPartState(net.minecraft.core.Direction side, IPartState partState) throws PartStateException Description copied from interface:IPartContainerdz Set the state of a part.- Specified by:
setPartStatein interfaceIPartContainer- Parameters:
side- The side.partState- The part state.- Throws:
PartStateException- If no part at the given position is available.
-
getPartState
Description copied from interface:IPartContainerGet the state of a part.- Specified by:
getPartStatein interfaceIPartContainer- Parameters:
side- The side.- Returns:
- The part state.
- Throws:
PartStateException- If no part at the given position is available.
-
getCapability
public <T> Optional<T> getCapability(PartCapability<T> partCapability, INetwork network, IPartNetwork partNetwork, PartTarget target) Description copied from interface:IPartContainerGet a part capability.- Specified by:
getCapabilityin interfaceIPartContainer- Type Parameters:
T- The capability type.- Parameters:
partCapability- A part capability.network- The network.partNetwork- The part network.target- The part target.- Returns:
- The capability instance.
-
toValueOutput
public void toValueOutput(net.minecraft.world.level.storage.ValueOutput valueOutput) - Specified by:
toValueOutputin interfaceorg.cyclops.cyclopscore.persist.nbt.INBTSerializable
-
fromValueInput
public void fromValueInput(net.minecraft.world.level.storage.ValueInput valueInput) - Specified by:
fromValueInputin interfaceorg.cyclops.cyclopscore.persist.nbt.INBTSerializable
-
onPartsChanged
protected void onPartsChanged() -
setChanged
protected abstract void setChanged() -
sendUpdate
protected abstract void sendUpdate() -
getLevel
protected abstract net.minecraft.world.level.Level getLevel() -
getPos
protected abstract net.minecraft.core.BlockPos getPos() -
getNetwork
-
getPartNetwork
-
getPartData
public org.cyclops.cyclopscore.datastructure.EnumFacingMap<PartHelpers.PartStateHolder<?,?>> getPartData()- Returns:
- The raw part data.
-
setPartData
public void setPartData(Map<net.minecraft.core.Direction, PartHelpers.PartStateHolder<?, ?>> partData) Override the part data.- Parameters:
partData- The raw part data.
-
silentResetPartData
public void silentResetPartData()Reset the part data without signaling any neighbours or the network. Is used in block conversion.
-