Interface ILightningConductive


public interface ILightningConductive
This interface allows implementing blocks to respond to lighting strikes and redirect lightning strikes to other adjacent blocks.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.core.Direction[]
    A default array of faces for conductive blocks to redirect lightning to.
    static final net.minecraft.core.Direction[]
    An empty array of lightning redirection faces.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    canRedirectLightning(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos strikePos, net.minecraft.world.level.block.state.BlockState strikeState)
    Checks if the block should trigger onIndirectLightingStrike(Level, BlockPos, BlockState, BlockPos, BlockState, LightningBolt) of adjacent blocks when directly struck by lightning.
    default net.minecraft.core.Direction[]
    getLightningRedirectionFaces(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos strikePos, net.minecraft.world.level.block.state.BlockState strikeState)
    Gets an array of block faces that should conduct lightning when struck.
    default void
    onDirectLightningStrike(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.entity.LightningBolt lightning)
    This method is called when a lightning bolt directly strikes the blocks.
    default void
    onIndirectLightingStrike(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos strikePos, net.minecraft.world.level.block.state.BlockState strikeState, net.minecraft.core.BlockPos indirectPos, net.minecraft.world.level.block.state.BlockState indirectState, net.minecraft.world.entity.LightningBolt lightning)
    This method is called when a lightning bolt strikes an adjacent conductive block such as a lightning rod.
  • Field Details

    • LIGHTNING_REDIRECTION_FACES

      static final net.minecraft.core.Direction[] LIGHTNING_REDIRECTION_FACES
      A default array of faces for conductive blocks to redirect lightning to.
    • NO_REDIRECTION_FACES

      static final net.minecraft.core.Direction[] NO_REDIRECTION_FACES
      An empty array of lightning redirection faces. Can be used when the block should not redirect lightning.
  • Method Details

    • onDirectLightningStrike

      default void onDirectLightningStrike(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.entity.LightningBolt lightning)
      This method is called when a lightning bolt directly strikes the blocks.
      Parameters:
      world - The world the block is in.
      pos - The position the lightning bolt struck.
      state - The state of the block struck by the lighting bolt.
      lightning - The lightning bolt that struck the block.
    • onIndirectLightingStrike

      default void onIndirectLightingStrike(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos strikePos, net.minecraft.world.level.block.state.BlockState strikeState, net.minecraft.core.BlockPos indirectPos, net.minecraft.world.level.block.state.BlockState indirectState, net.minecraft.world.entity.LightningBolt lightning)
      This method is called when a lightning bolt strikes an adjacent conductive block such as a lightning rod.
      Parameters:
      world - The world the block is in.
      strikePos - The position the lightning bolt struck.
      strikeState - The state of the block struck by the lightning bolt.
      indirectPos - The position of this block in the world.
      indirectState - The state of this block.
      lightning - The lighting bolt that indirectly struck our block.
    • canRedirectLightning

      default boolean canRedirectLightning(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos strikePos, net.minecraft.world.level.block.state.BlockState strikeState)
      Checks if the block should trigger onIndirectLightingStrike(Level, BlockPos, BlockState, BlockPos, BlockState, LightningBolt) of adjacent blocks when directly struck by lightning.
      Parameters:
      world - The world the block is in.
      strikePos - The position the lightning bolt struck.
      strikeState - The state of the block struck by the lightning bolt.
      Returns:
      Will the lightning indirectly strike adjacent blocks.
    • getLightningRedirectionFaces

      default net.minecraft.core.Direction[] getLightningRedirectionFaces(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos strikePos, net.minecraft.world.level.block.state.BlockState strikeState)
      Gets an array of block faces that should conduct lightning when struck. If canRedirectLightning(Level, BlockPos, BlockState) is true, onIndirectLightingStrike(Level, BlockPos, BlockState, BlockPos, BlockState, LightningBolt) will be invoked on blocks adjacent to the faces returned by this method.
      Parameters:
      world - The world the block is in.
      strikePos - The position the lightning bolt struck.
      strikeState - The state of the block struck by the lightning bolt.
      Returns:
      An array of adjacent faces that will be indirectly struck by lightning.