Interface IPartContainer
- All Superinterfaces:
org.cyclops.cyclopscore.persist.nbt.INBTSerializable
- All Known Implementing Classes:
PartContainerDefault,PartContainerTileMultipartTicking
public interface IPartContainer
extends org.cyclops.cyclopscore.persist.nbt.INBTSerializable
An interface for containers that can hold
IPartTypes.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cyclops.cyclopscore.persist.nbt.INBTSerializable
org.cyclops.cyclopscore.persist.nbt.INBTSerializable.SelfNBTClassType -
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.<T> Optional<T> getCapability(PartCapability<T> partCapability, INetwork network, IPartNetwork partNetwork, PartTarget target) Get a part capability.getPart(net.minecraft.core.Direction side) Get the part of a side, can be null.getParts()getPartState(net.minecraft.core.Direction side) Get the state of a part.org.cyclops.cyclopscore.datastructure.DimPosnet.minecraft.core.DirectiongetWatchingSide(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player) Get the part side the player is watching.booleanhasPart(net.minecraft.core.Direction side) booleanhasParts()removePart(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.<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.voidsetPartState(net.minecraft.core.Direction side, IPartState partState) dz Set the state of a part.voidupdate()Should be called every tick, updates parts.Methods inherited from interface org.cyclops.cyclopscore.persist.nbt.INBTSerializable
fromValueInput, toValueOutput
-
Method Details
-
update
void update()Should be called every tick, updates parts. -
getPosition
org.cyclops.cyclopscore.datastructure.DimPos getPosition()- Returns:
- The position this container is at.
-
getParts
- Returns:
- The parts inside this container.
-
hasParts
boolean hasParts()- Returns:
- If this container has at least one part.
-
setPart
<P extends IPartType<P,S>, void setPartS extends IPartState<P>> (net.minecraft.core.Direction side, IPartType<P, S> part, IPartState<P> partState) Set the part for a side.- 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.
-
canAddPart
<P extends IPartType<P,S>, boolean canAddPartS extends IPartState<P>> (net.minecraft.core.Direction side, IPartType<P, S> part) Check if the given part can be added at the given side.- 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.
-
getPart
Get the part of a side, can be null.- Parameters:
side- The side.- Returns:
- The part or null.
-
hasPart
boolean hasPart(net.minecraft.core.Direction side) - Parameters:
side- The side.- Returns:
- If the given side has a part.
-
removePart
IPartType removePart(net.minecraft.core.Direction side, @Nullable 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.- 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
void setPartState(net.minecraft.core.Direction side, IPartState partState) throws PartStateException dz Set the state of a part.- Parameters:
side- The side.partState- The part state.- Throws:
PartStateException- If no part at the given position is available.
-
getPartState
Get the state of a part.- Parameters:
side- The side.- Returns:
- The part state.
- Throws:
PartStateException- If no part at the given position is available.
-
getWatchingSide
@Nullable net.minecraft.core.Direction getWatchingSide(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player) Get the part side the player is watching. This is used to determine the part the player is looking at.- Parameters:
world- The world.pos- The block position to perform a ray trace for.player- The player.- Returns:
- The side the player is watching or null.
-
getCapability
<T> Optional<T> getCapability(PartCapability<T> partCapability, INetwork network, IPartNetwork partNetwork, PartTarget target) Get a part capability.- 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.
-