Class RedstoneInteractions

java.lang.Object
codechicken.multipart.api.RedstoneInteractions

public class RedstoneInteractions extends Object
static helper class for calculating various things about redstone. Indirect power (also known as strong power) is not handled here, just use world.getIndirectPowerTo Masks are defined in IRedstoneConnector
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    connectionMask(MultiPart p, int side)
    Get the connection mask of part on a given block side.
    static int
    getConnectionMask(net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, int side, boolean power)
    Retrieves connection mask for block at give pos.
    static int
    getPower(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, int side, int mask)
    Get the direct power level provided by space (pos) on side with mask
    static int
    getPowerTo(MultiPart p, int side)
    Get the direct power to p on side
    static int
    getPowerTo(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, int side, int mask)
    Get the direct power level to space (pos) on side with mask
    static int
    otherConnectionMask(net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, int side, boolean power)
    Get the connection mask of the block on side of (pos).
    static int
    vanillaConnectionMask(net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int side, boolean power)
    Calculates the connection mask for a vanilla block.

    Methods inherited from class java.lang.Object

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

    • RedstoneInteractions

      public RedstoneInteractions()
  • Method Details

    • getPowerTo

      public static int getPowerTo(MultiPart p, int side)
      Get the direct power to p on side
    • getPowerTo

      public static int getPowerTo(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, int side, int mask)
      Get the direct power level to space (pos) on side with mask
    • getPower

      public static int getPower(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, int side, int mask)
      Get the direct power level provided by space (pos) on side with mask
    • otherConnectionMask

      public static int otherConnectionMask(net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, int side, boolean power)
      Get the connection mask of the block on side of (pos). See getConnectionMask(LevelReader, BlockPos, int, boolean)
      Parameters:
      world - The world
      pos - The position of the original block
      side - The side the target block is in that will be queried
      power - If true, returns a power transmission mask rather than visual connection mask
    • connectionMask

      public static int connectionMask(MultiPart p, int side)
      Get the connection mask of part on a given block side.
      Parameters:
      p - The part to query
      side - The side to query, relative to the part's parent block
    • getConnectionMask

      public static int getConnectionMask(net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, int side, boolean power)
      Retrieves connection mask for block at give pos. If the block/entity implements the more capable RedstoneConnector/RedstoneConnectorBlock interfaces, it provides the mask directly. Otherwise, it is calculated from known vanilla blocks. For unknown blocks, the default canConnectRedstone logic applies.

      If power is true, the power transmission mask is returned instead. Some blocks can accept/emit signal even without a visible connection.

      Parameters:
      world - The level
      pos - The position of the block to query
      side - The side of the block to query
      power - If true, returns a power transmission mask rather than visual connection mask
    • vanillaConnectionMask

      public static int vanillaConnectionMask(net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int side, boolean power)
      Calculates the connection mask for a vanilla block. This will take care of calculating partial masks for non-full blocks, which default block methods cannot handle.

      If power is true, the power transmission mask is returned instead. Some blocks can accept/emit signal even without a visible connection.

      Parameters:
      world - The level
      pos - The position of the vanilla block
      state - The state of the vanilla block
      side - The side of the vanilla block to query
      power - If true, returns a power transmission mask rather than visual connection mask