Class NetworkHelpers
java.lang.Object
org.cyclops.integrateddynamics.core.helper.NetworkHelpers
Network helper methods.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional
<IEnergyNetwork> getEnergyNetwork
(Optional<INetwork> optionalNetwork) Get the part network capability of a network.static Optional
<IEnergyNetwork> getEnergyNetwork
(INetwork network) Get the part network capability of a network.static IEnergyNetwork
getEnergyNetworkChecked
(INetwork network) Get the part network capability of a network.static <T,
M> Optional <IPositionedAddonsNetworkIngredients<T, M>> getIngredientNetwork
(Optional<INetwork> optionalNetwork, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent) Get the ingredient network within a network.getNetwork
(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side) Get the network at the given position.getNetwork
(PartPos pos) Get the network at the given position.static Optional
<INetworkCarrier> getNetworkCarrier
(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side) Get the network carrier capability at the given position.static INetwork
getNetworkChecked
(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side) Get the network at the given position.static INetwork
getNetworkChecked
(PartPos pos) Get the network at the given position.static Optional
<INetworkElementProvider> getNetworkElementProvider
(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side) Get the network element provider capability at the given position.static Optional
<IPartNetwork> getPartNetwork
(Optional<INetwork> optionalNetwork) Get the part network capability of a network.static Optional
<IPartNetwork> getPartNetwork
(INetwork network) Get the part network capability of a network.static IPartNetwork
getPartNetworkChecked
(INetwork network) Get the part network capability of a network.initNetwork
(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side) Form a new network starting from the given position.static void
invalidateNetworkElements
(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, INetwork network, INetworkElementProvider networkElementProvider) Invalidate all network elements at the given position.static void
onElementProviderBlockNeighborChange
(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.Block neighbourBlock, net.minecraft.core.Direction side, net.minecraft.core.BlockPos neighbourBlockPos) This MUST be called by blocks having theINetworkElementProvider
capability in when a neighbouring block is updated, more specifically whenBlockBehaviour.neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean)
,IBlockExtension.onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos)
orBlockBehaviour.updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos)
is called.static void
revalidateNetworkElements
(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) Revalidate all network elements at the given position.static boolean
-
Constructor Details
-
NetworkHelpers
public NetworkHelpers()
-
-
Method Details
-
getNetworkCarrier
public static Optional<INetworkCarrier> getNetworkCarrier(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side) Get the network carrier capability at the given position.- Parameters:
world
- The world.pos
- The position.side
- The side.- Returns:
- The optional network carrier capability.
-
getNetworkElementProvider
public static Optional<INetworkElementProvider> getNetworkElementProvider(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side) Get the network element provider capability at the given position.- Parameters:
world
- The world.pos
- The position.side
- The side.- Returns:
- The optional network element provider capability.
-
getNetwork
public static Optional<INetwork> getNetwork(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side) Get the network at the given position.- Parameters:
world
- The world.pos
- The position.side
- The side.- Returns:
- The optional network.
-
getNetwork
Get the network at the given position.- Parameters:
pos
- The position.- Returns:
- The optional network.
-
getNetworkChecked
public static INetwork getNetworkChecked(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side) Get the network at the given position. If it is not present, then an illegal state exception will be thrown. This should only be called if you know for certain that there will be a network present.- Parameters:
world
- The world.pos
- The position.side
- The side.- Returns:
- The network.
-
getNetworkChecked
Get the network at the given position. If it is not present, then an illegal state exception will be thrown. This should only be called if you know for certain that there will be a network present.- Parameters:
pos
- The position.- Returns:
- The network.
-
getPartNetwork
Get the part network capability of a network.- Parameters:
optionalNetwork
- The optional network.- Returns:
- The optional part network.
-
getPartNetwork
Get the part network capability of a network.- Parameters:
network
- The network.- Returns:
- The optional part network.
-
getPartNetworkChecked
Get the part network capability of a network. If it is not present, then an illegal state exception will be thrown. This should only be called if you know for certain that there will be a part network present.- Parameters:
network
- The network.- Returns:
- The part network.
-
getEnergyNetwork
Get the part network capability of a network.- Parameters:
optionalNetwork
- The optional network.- Returns:
- The optional energy network.
-
getEnergyNetwork
Get the part network capability of a network.- Parameters:
network
- The network.- Returns:
- The optional energy network.
-
getEnergyNetworkChecked
Get the part network capability of a network.- Parameters:
network
- The network.- Returns:
- The energy network.
-
getIngredientNetwork
public static <T,M> Optional<IPositionedAddonsNetworkIngredients<T,M>> getIngredientNetwork(Optional<INetwork> optionalNetwork, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent) Get the ingredient network within a network.- Type Parameters:
T
- The instance type.M
- The matching condition parameter.- Parameters:
optionalNetwork
- The optional network.ingredientComponent
- The ingredient component type.- Returns:
- The optional ingredient network.
-
initNetwork
public static Optional<INetwork> initNetwork(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side) Form a new network starting from the given position. This position should have aIPathElement
capability, otherwise this method will fail silently. This will correctly transfer all passed network elements to this new network.- Parameters:
world
- The world.pos
- The starting position.side
- The side.- Returns:
- The optionally created part network.
Can be absent if the starting position did not have a
IPathElement
capability.
-
onElementProviderBlockNeighborChange
public static void onElementProviderBlockNeighborChange(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.Block neighbourBlock, @Nullable net.minecraft.core.Direction side, net.minecraft.core.BlockPos neighbourBlockPos) This MUST be called by blocks having theINetworkElementProvider
capability in when a neighbouring block is updated, more specifically whenBlockBehaviour.neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean)
,IBlockExtension.onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos)
orBlockBehaviour.updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos)
is called.- Parameters:
world
- The world in which the neighbour was updated.pos
- The position of the center block.neighbourBlock
- The block type of the neighbour that was updated.side
- The side at the center block.neighbourBlockPos
- The position of the neighbour that was updated.
-
shouldWork
public static boolean shouldWork()- Returns:
- If networks should work and evaluations should be done.
-
invalidateNetworkElements
public static void invalidateNetworkElements(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, INetwork network, INetworkElementProvider networkElementProvider) Invalidate all network elements at the given position. Warning: this assumes unsided network carrier capabilities, for example full-block network elements.- Parameters:
world
- The world.pos
- The position.network
- The network.networkElementProvider
- The network element provider.
-
revalidateNetworkElements
public static void revalidateNetworkElements(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos) Revalidate all network elements at the given position. Warning: this assumes unsided network carrier capabilities, for example full-block network elements.- Parameters:
world
- The world.pos
- The position.
-