Package codechicken.multipart.api
Class RedstoneInteractions
java.lang.Object
codechicken.multipart.api.RedstoneInteractions
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic intconnectionMask(MultiPart p, int side) Get the connection mask of part on a given block side.static intgetConnectionMask(net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, int side, boolean power) Retrieves connection mask for block at give pos.static intgetPower(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 maskstatic intgetPowerTo(MultiPart p, int side) Get the direct power to p on sidestatic intgetPowerTo(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 maskstatic intotherConnectionMask(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 intvanillaConnectionMask(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.
-
Constructor Details
-
RedstoneInteractions
public RedstoneInteractions()
-
-
Method Details
-
getPowerTo
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). SeegetConnectionMask(LevelReader, BlockPos, int, boolean)- Parameters:
world- The worldpos- The position of the original blockside- The side the target block is in that will be queriedpower- If true, returns a power transmission mask rather than visual connection mask
-
connectionMask
Get the connection mask of part on a given block side.- Parameters:
p- The part to queryside- 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 levelpos- The position of the block to queryside- The side of the block to querypower- 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 levelpos- The position of the vanilla blockstate- The state of the vanilla blockside- The side of the vanilla block to querypower- If true, returns a power transmission mask rather than visual connection mask
-