Class NetworkHelpers

java.lang.Object
org.cyclops.integrateddynamics.core.helper.NetworkHelpers

public class NetworkHelpers extends Object
Network helper methods.
  • 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

      public static Optional<INetwork> getNetwork(PartPos pos)
      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

      public static INetwork getNetworkChecked(PartPos pos)
      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 Optional<IPartNetwork> getPartNetwork(Optional<INetwork> optionalNetwork)
      Get the part network capability of a network.
      Parameters:
      optionalNetwork - The optional network.
      Returns:
      The optional part network.
    • getPartNetwork

      public static Optional<IPartNetwork> getPartNetwork(@Nullable INetwork network)
      Get the part network capability of a network.
      Parameters:
      network - The network.
      Returns:
      The optional part network.
    • getPartNetworkChecked

      public static IPartNetwork getPartNetworkChecked(INetwork network)
      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 Optional<IEnergyNetwork> getEnergyNetwork(Optional<INetwork> optionalNetwork)
      Get the part network capability of a network.
      Parameters:
      optionalNetwork - The optional network.
      Returns:
      The optional energy network.
    • getEnergyNetwork

      public static Optional<IEnergyNetwork> getEnergyNetwork(@Nullable INetwork network)
      Get the part network capability of a network.
      Parameters:
      network - The network.
      Returns:
      The optional energy network.
    • getEnergyNetworkChecked

      public static IEnergyNetwork getEnergyNetworkChecked(INetwork network)
      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 a IPathElement 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 the INetworkElementProvider capability in when a neighbouring block is updated, more specifically when BlockBehaviour.neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean), IBlockExtension.onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos) or BlockBehaviour.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.