Class PartContainerDefault
java.lang.Object
org.cyclops.integrateddynamics.capability.partcontainer.PartContainerDefault
- All Implemented Interfaces:
net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
,IPartContainer
- Direct Known Subclasses:
PartContainerTileMultipartTicking
Default implementation of an
IPartContainer
.-
Field Summary
Modifier and TypeFieldDescriptionprotected final org.cyclops.cyclopscore.datastructure.EnumFacingMap
<PartHelpers.PartStateHolder<?, ?>> -
Constructor Summary
-
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.void
deserializeNBT
(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag tag) <T> Optional
<T> getCapability
(PartCapability<T> partCapability, INetwork network, IPartNetwork partNetwork, PartTarget target) Get a part capability.protected abstract net.minecraft.world.level.Level
getLevel()
protected abstract INetwork
getPart
(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.BlockPos
getPos()
org.cyclops.cyclopscore.datastructure.DimPos
boolean
hasPart
(net.minecraft.core.Direction side) boolean
hasParts()
protected void
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.protected abstract void
net.minecraft.nbt.CompoundTag
serializeNBT
(net.minecraft.core.HolderLookup.Provider provider) protected 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.void
setPartData
(Map<net.minecraft.core.Direction, PartHelpers.PartStateHolder<?, ?>> partData) Override the part data.void
setPartState
(net.minecraft.core.Direction side, IPartState partState) dz Set the state of a part.void
Reset the part data without signaling any neighbours or the network.void
update()
Should be called every tick, updates parts.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:IPartContainer
Should be called every tick, updates parts.- Specified by:
update
in interfaceIPartContainer
-
getPosition
public org.cyclops.cyclopscore.datastructure.DimPos getPosition()- Specified by:
getPosition
in interfaceIPartContainer
- Returns:
- The position this container is at.
-
getParts
- Specified by:
getParts
in interfaceIPartContainer
- Returns:
- The parts inside this container.
-
hasParts
public boolean hasParts()- Specified by:
hasParts
in 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:IPartContainer
Check if the given part can be added at the given side.- Specified by:
canAddPart
in 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:IPartContainer
Set the part for a side.- Specified by:
setPart
in 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:IPartContainer
Get the part of a side, can be null.- Specified by:
getPart
in interfaceIPartContainer
- Parameters:
side
- The side.- Returns:
- The part or null.
-
hasPart
public boolean hasPart(net.minecraft.core.Direction side) - Specified by:
hasPart
in 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:IPartContainer
Remove the part from a side, can return null if there was no part on that side.- Specified by:
removePart
in 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:IPartContainer
dz Set the state of a part.- Specified by:
setPartState
in 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:IPartContainer
Get the state of a part.- Specified by:
getPartState
in 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:IPartContainer
Get a part capability.- Specified by:
getCapability
in 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.
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT(net.minecraft.core.HolderLookup.Provider provider) - Specified by:
serializeNBT
in interfacenet.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-
deserializeNBT
public void deserializeNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag tag) - Specified by:
deserializeNBT
in interfacenet.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-
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.
-