Class CableHelpers

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

public class CableHelpers extends Object
Helpers related to cables.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Collection<net.minecraft.core.Direction>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    canCableConnectTo(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side, ICable originCable)
    Check if one side of the given cable at the given position can connect to the given side.
    static void
    disconnectCable(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side, ICable cable, net.minecraft.core.Direction disconnectSide)
    Disconnect a cable's side.
    getCable(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side)
    Get the cable capability at the given position.
    static Collection<net.minecraft.core.Direction>
    Get the sides the cable is currently connected to.
    getCableFakeable(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side)
    Get the fakeable cable capability at the given position.
    static Collection<net.minecraft.core.Direction>
    getExternallyConnectedCables(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
    Get the sides that are externally connected to the given position.
    static Optional<net.minecraft.world.level.block.state.BlockState>
    getFacade(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos)
    Get the target's facade
    static Optional<net.minecraft.world.level.block.state.BlockState>
    getFacade(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState blockState)
    Get the target's facade
    getPathElement(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side)
    Get the path element capability at the given position.
    static boolean
    hasFacade(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos)
    Check if the target has a facade.
    static boolean
    isCableConnected(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side)
    Check if there is a cable at the given position AND if it is connected for the given side.
    static boolean
    isLightTransparent(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side)
     
    static boolean
    isLightTransparent(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side, net.minecraft.world.level.block.state.BlockState blockState)
     
    static boolean
    isNoFakeCable(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side)
    Check if the given position is not a fake cable.
    static boolean
     
    static net.minecraft.world.InteractionResult
    onCableActivated(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack heldItem, net.minecraft.core.Direction side, net.minecraft.core.Direction cableConnectionHit)
    Actions to be performed when a player right clicks on a cable.
    static void
    onCableAdded(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
    This should be called when a cable is added.
    static void
    onCableAddedByPlayer(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.LivingEntity placer)
    This should be called when a cable was added by a player.
    static boolean
    onCableRemoved(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, Collection<net.minecraft.core.Direction> sides)
    This should be called AFTER a cable is removed, at this stage the part entity will not exist anymore.
    static boolean
    onCableRemoving(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, boolean dropMainElement, boolean saveState)
    This should be called when a cable is being removed, while the part entity is still present.
    static void
    removeCable(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
    Remove a cable.
    static void
    setRemovingCable(boolean removingCable)
     
    static void
    updateConnections(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side)
    Request to update the cable connections at the given position.
    static void
    updateConnectionsNeighbours(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, Collection<net.minecraft.core.Direction> sides)
    Request to update the cable connections of all neighbours of the given position.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ALL_SIDES

      public static final Collection<net.minecraft.core.Direction> ALL_SIDES
  • Constructor Details

    • CableHelpers

      public CableHelpers()
  • Method Details

    • getCable

      public static Optional<ICable> getCable(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side)
      Get the cable capability at the given position.
      Parameters:
      world - The world.
      pos - The position.
      side - The side.
      Returns:
      The optional cable capability.
    • getCableFakeable

      public static Optional<ICableFakeable> getCableFakeable(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side)
      Get the fakeable cable capability at the given position.
      Parameters:
      world - The world.
      pos - The position.
      side - The side.
      Returns:
      The optional fakeable cable capability.
    • getPathElement

      public static Optional<IPathElement> getPathElement(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side)
      Get the path element capability at the given position.
      Parameters:
      world - The world.
      pos - The position.
      side - The side.
      Returns:
      The optional path element capability.
    • updateConnectionsNeighbours

      public static void updateConnectionsNeighbours(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, Collection<net.minecraft.core.Direction> sides)
      Request to update the cable connections of all neighbours of the given position.
      Parameters:
      world - The world.
      pos - The center position.
      sides - The sides to update connections for.
    • updateConnections

      public static void updateConnections(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side)
      Request to update the cable connections at the given position.
      Parameters:
      world - The world.
      pos - The position.
      side - The side.
    • isCableConnected

      public static boolean isCableConnected(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side)
      Check if there is a cable at the given position AND if it is connected for the given side.
      Parameters:
      world - The world.
      pos - The position.
      side - The side to check a connection for.
      Returns:
      If there is a cable that is connected.
    • canCableConnectTo

      public static boolean canCableConnectTo(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side, ICable originCable)
      Check if one side of the given cable at the given position can connect to the given side. To be used when the cable connections are being updated. This will check if the origin cable can connect to that side, if there is a cable at the target side and if that cable can connect with this side. This ignores any current cable connections.
      Parameters:
      world - The world.
      pos - The center position.
      side - The side from the center position to check.
      originCable - The cable at the center position.
      Returns:
      If it can connect.
    • isNoFakeCable

      public static boolean isNoFakeCable(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side)
      Check if the given position is not a fake cable. This can mean that there is no cable at all! But if there is a cable, this method will return true only if it is a real cable.
      Parameters:
      world - The world.
      pos - The position.
      side - The side.
      Returns:
      If there is no fake cable.
    • disconnectCable

      public static void disconnectCable(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side, ICable cable, net.minecraft.core.Direction disconnectSide)
      Disconnect a cable's side.
      Parameters:
      world - The cable world.
      pos - The cable position.
      side - The cable side.
      cable - The cable to disconnect.
      disconnectSide - The side to disconnect.
    • onCableActivated

      public static net.minecraft.world.InteractionResult onCableActivated(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack heldItem, net.minecraft.core.Direction side, @Nullable net.minecraft.core.Direction cableConnectionHit)
      Actions to be performed when a player right clicks on a cable.
      Parameters:
      world - The world of the cable.
      pos - The position of the cable.
      state - The blockstate of the cable.
      player - The player activating the cable.
      heldItem - The item with which the player is right-clicking.
      side - The side of the block the player right-clicked on.
      cableConnectionHit - The side identifying the cable connection that is being activated, this will be null if the center part of the cable is activated.
      Returns:
      Action result.
    • onCableAdded

      public static void onCableAdded(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
      This should be called when a cable is added. This method automatically notifies the neighbours and (re-)initializes the network if this cable carries one. This should in most cases only be called server-side.
      Parameters:
      world - The world.
      pos - The position.
    • onCableAddedByPlayer

      public static void onCableAddedByPlayer(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.world.entity.LivingEntity placer)
      This should be called when a cable was added by a player. This should be called after onCableAdded(Level, BlockPos). It simply emits an player-sensitive init event on the network bus.
      Parameters:
      world - The world.
      pos - The position.
      placer - The entity who placed the cable.
    • onCableRemoving

      public static boolean onCableRemoving(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, boolean dropMainElement, boolean saveState)
      This should be called when a cable is being removed, while the part entity is still present. This method won't do anything when called client-side.
      Parameters:
      world - The world.
      pos - The position.
      dropMainElement - If the main part element should be dropped.
      saveState - If the element state should be saved in the item.
      Returns:
      If the cable was removed from the network.
    • onCableRemoved

      public static boolean onCableRemoved(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, Collection<net.minecraft.core.Direction> sides)
      This should be called AFTER a cable is removed, at this stage the part entity will not exist anymore. This method won't do anything when called client-side.
      Parameters:
      world - The world.
      pos - The position.
      sides - The sides to update connections for.
      Returns:
      If the cable was removed from the network.
    • isRemovingCable

      public static boolean isRemovingCable()
      Returns:
      If removeCable(net.minecraft.world.level.Level, net.minecraft.core.BlockPos, net.minecraft.world.entity.player.Player) is currently being called.
    • setRemovingCable

      public static void setRemovingCable(boolean removingCable)
      Parameters:
      removingCable - If the removing cable flag should be set
    • removeCable

      public static void removeCable(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.world.entity.player.Player player)
      Remove a cable. This will automatically handle sounds, drops, fakeable cables, network element removal and network (re)intialization.
      Parameters:
      world - The world.
      pos - The position.
      player - The player removing the cable or null.
    • hasFacade

      public static boolean hasFacade(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos)
      Check if the target has a facade.
      Parameters:
      world - The world.
      pos - The position.
      Returns:
      If it has a facade.
    • getFacade

      public static Optional<net.minecraft.world.level.block.state.BlockState> getFacade(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos)
      Get the target's facade
      Parameters:
      world - The world.
      pos - The position.
      Returns:
      The optional facade.
    • getFacade

      public static Optional<net.minecraft.world.level.block.state.BlockState> getFacade(net.neoforged.neoforge.common.extensions.ILevelExtension world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState blockState)
      Get the target's facade
      Parameters:
      world - The world.
      pos - The position.
      blockState - The block state.
      Returns:
      The optional facade.
    • isLightTransparent

      public static boolean isLightTransparent(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side)
    • isLightTransparent

      public static boolean isLightTransparent(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Direction side, net.minecraft.world.level.block.state.BlockState blockState)
    • getCableConnections

      public static Collection<net.minecraft.core.Direction> getCableConnections(ICable cable)
      Get the sides the cable is currently connected to.
      Parameters:
      cable - A cable.
      Returns:
      The cable connections.
    • getExternallyConnectedCables

      public static Collection<net.minecraft.core.Direction> getExternallyConnectedCables(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
      Get the sides that are externally connected to the given position.
      Parameters:
      world - The world.
      pos - The position.
      Returns:
      The sides.