Class PartContainerDefault
java.lang.Object
org.cyclops.integrateddynamics.capability.partcontainer.PartContainerDefault
- All Implemented Interfaces:
net.minecraftforge.common.capabilities.ICapabilityProvider
,net.minecraftforge.common.capabilities.ICapabilitySerializable<net.minecraft.nbt.CompoundTag>
,net.minecraftforge.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.nbt.CompoundTag tag) <T> net.minecraftforge.common.util.LazyOptional<T>
getCapability
(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.core.Direction facing) 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 net.minecraftforge.common.util.LazyOptional<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
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 net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
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> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable net.minecraft.core.Direction facing) - Specified by:
getCapability
in interfacenet.minecraftforge.common.capabilities.ICapabilityProvider
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT()- Specified by:
serializeNBT
in interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
-
deserializeNBT
public void deserializeNBT(net.minecraft.nbt.CompoundTag tag) - Specified by:
deserializeNBT
in interfacenet.minecraftforge.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.
-