Class NetworkHelpers
java.lang.Object
org.cyclops.integrateddynamics.core.helper.NetworkHelpers
Network helper methods.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraftforge.common.util.LazyOptional<IEnergyNetwork>
getEnergyNetwork
(net.minecraftforge.common.util.LazyOptional<INetwork> optionalNetwork) Get the part network capability of a network.static net.minecraftforge.common.util.LazyOptional<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> net.minecraftforge.common.util.LazyOptional<IPositionedAddonsNetworkIngredients<T, M>> getIngredientNetwork
(net.minecraftforge.common.util.LazyOptional<INetwork> optionalNetwork, org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> ingredientComponent) Get the ingredient network within a network.static net.minecraftforge.common.util.LazyOptional<INetwork>
getNetwork
(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side) Get the network at the given position.static net.minecraftforge.common.util.LazyOptional<INetwork>
getNetwork
(PartPos pos) Get the network at the given position.static net.minecraftforge.common.util.LazyOptional<INetworkCarrier>
getNetworkCarrier
(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side) Get the network carrier capability at the given position.static INetwork
getNetworkChecked
(net.minecraft.world.level.BlockGetter 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 net.minecraftforge.common.util.LazyOptional<INetworkElementProvider>
getNetworkElementProvider
(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side) Get the network element provider capability at the given position.static net.minecraftforge.common.util.LazyOptional<IPartNetwork>
getPartNetwork
(net.minecraftforge.common.util.LazyOptional<INetwork> optionalNetwork) Get the part network capability of a network.static net.minecraftforge.common.util.LazyOptional<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.minecraft.world.level.Level 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, net.minecraft.world.level.block.entity.BlockEntity tile) 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)
,IForgeBlock.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 net.minecraftforge.common.util.LazyOptional<INetworkCarrier> getNetworkCarrier(net.minecraft.world.level.BlockGetter 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 net.minecraftforge.common.util.LazyOptional<INetworkElementProvider> getNetworkElementProvider(net.minecraft.world.level.BlockGetter 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 net.minecraftforge.common.util.LazyOptional<INetwork> getNetwork(net.minecraft.world.level.BlockGetter 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.minecraft.world.level.BlockGetter 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
public static net.minecraftforge.common.util.LazyOptional<IPartNetwork> getPartNetwork(net.minecraftforge.common.util.LazyOptional<INetwork> optionalNetwork) Get the part network capability of a network.- Parameters:
optionalNetwork
- The optional network.- Returns:
- The optional part network.
-
getPartNetwork
public static net.minecraftforge.common.util.LazyOptional<IPartNetwork> getPartNetwork(@Nullable INetwork network) 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
public static net.minecraftforge.common.util.LazyOptional<IEnergyNetwork> getEnergyNetwork(net.minecraftforge.common.util.LazyOptional<INetwork> optionalNetwork) Get the part network capability of a network.- Parameters:
optionalNetwork
- The optional network.- Returns:
- The optional energy network.
-
getEnergyNetwork
public static net.minecraftforge.common.util.LazyOptional<IEnergyNetwork> getEnergyNetwork(@Nullable INetwork network) 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> net.minecraftforge.common.util.LazyOptional<IPositionedAddonsNetworkIngredients<T,M>> getIngredientNetwork(net.minecraftforge.common.util.LazyOptional<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.minecraft.world.level.Level 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)
,IForgeBlock.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.side
- The side at the center block.neighbourBlock
- The block type of the neighbour that was updated.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, net.minecraft.world.level.block.entity.BlockEntity tile) 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.tile
- The tile entity that is unloaded.
-
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.
-