Class BlockApi

java.lang.Object
com.shanebeestudios.nms.api.world.block.BlockApi
Direct Known Subclasses:
BlockApi

public class BlockApi extends Object
API methods relating to Blocks
  • Constructor Details

    • BlockApi

      protected BlockApi()
      Do not use
  • Method Details

    • getForPlacement

      @Nullable public static @Nullable com.mojang.datafixers.util.Pair<Location,BlockData> getForPlacement(@NotNull @NotNull Player player, int maxDistance)
      Get the BlockData that would be placed at a specific position as well as the location of the placement
      Parameters:
      player - Player that would be placing
      maxDistance - Max distance to check for
      Returns:
      Pair of location and block data
    • getBlockDataForPlacement

      @Nullable public static @Nullable BlockData getBlockDataForPlacement(@NotNull @NotNull Player player, int maxDistance)
      Get the BlockData that would be placed at a specific position
      Parameters:
      player - Player that would be placing
      maxDistance - Max distance to check for
      Returns:
      BlockData of what would be placed
    • getBlockDataForPlacement

      @Nullable public static @Nullable BlockData getBlockDataForPlacement(@NotNull @NotNull Player player, @NotNull @NotNull Block hitBlock, @NotNull @NotNull Location hitLocation, @NotNull @NotNull BlockFace face)
      Get the BlockData that would be placed at a specific position
      Parameters:
      player - Player that would be placing
      hitBlock - The block that was hit
      hitLocation - The position of the player's cursor
      face - The fact of the block relative to the hit block
      Returns:
      BlockData of what would be placed
    • getBlockDataForPlacement

      @Nullable public static @Nullable BlockData getBlockDataForPlacement(@NotNull @NotNull Player player, @NotNull @NotNull Block hitBlock, @NotNull @NotNull Location hitLocation, @NotNull @NotNull BlockFace face, @NotNull @NotNull ItemStack itemStack)
      Get the BlockData that would be placed at a specific position
      Parameters:
      player - Player that would be placing
      hitBlock - The block that was hit
      hitLocation - The position of the player's cursor
      face - The fact of the block relative to the hit block
      itemStack - ItemStack to try to place
      Returns:
      BlockData of what would be placed
    • randomlyTick

      public static void randomlyTick(Block bukkitBlock)
      Randomly tick a block.

      This does the same thing Minecraft does when it picks blocks to randomly tick, for example crops, leaf decay and farmland moisture.

      NOTE: If the block does not have any ticking code (ex: stone), nothing will happen.

      Parameters:
      bukkitBlock - Block to randomly tick
    • getDestroyProgress

      public static float getDestroyProgress(Player player, Block bukkitBlock)
      Get the destroy progress of a specific Block by a Player
      Parameters:
      player - Player to check for progress
      bukkitBlock - Block to check for progress
      Returns:
      Destroy progress of block by player