Class BlockUtils

java.lang.Object
org.geysermc.geyser.util.BlockUtils

public final class BlockUtils extends Object
  • Method Details

    • getBlockMiningProgressPerTick

      public static float getBlockMiningProgressPerTick(GeyserSession session, Block block, GeyserItemStack itemInHand)
      Returns the total mining progress added by mining the block in a single tick Mirrors mojmap BlockBehaviour#getDestroyProgress
      Returns:
      the mining progress added by this tick.
    • reciprocal

      public static double reciprocal(double progress)
    • getBlockPosition

      public static org.cloudburstmc.math.vector.Vector3i getBlockPosition(org.cloudburstmc.math.vector.Vector3i blockPos, Direction face)
      Given a position, return the position if a block were located on the specified block face.
      Parameters:
      blockPos - the block position
      face - the face of the block - see Direction
      Returns:
      the block position with the block face accounted for
    • getCleanIdentifier

      public static String getCleanIdentifier(String fullJavaIdentifier)
      Taking in a complete Java block state identifier, output just the block ID of this block state without the states. Examples: minecraft:oak_log[axis=x] = minecraft:oak_log minecraft:stone_brick_wall[east=low,north=tall,south=none,up=true,waterlogged=false,west=tall] = minecraft:stone_brick_wall minecraft:stone = minecraft:stone
      Parameters:
      fullJavaIdentifier - a full Java block identifier, with possible block states.
      Returns:
      a clean identifier in the format of minecraft:block
    • getCollision

      public static BlockCollision getCollision(int blockId)
    • spawnBlockBreakParticles

      public static void spawnBlockBreakParticles(GeyserSession session, Direction direction, org.cloudburstmc.math.vector.Vector3i position, BlockState blockState)
    • sendBedrockStopBlockBreak

      public static void sendBedrockStopBlockBreak(GeyserSession session, org.cloudburstmc.math.vector.Vector3f vector)
    • sendBedrockBlockDestroy

      public static void sendBedrockBlockDestroy(GeyserSession session, org.cloudburstmc.math.vector.Vector3f vector, int blockState)
    • restoreCorrectBlock

      public static void restoreCorrectBlock(GeyserSession session, org.cloudburstmc.math.vector.Vector3i vector, BlockState blockState)
    • restoreCorrectBlock

      public static void restoreCorrectBlock(GeyserSession session, org.cloudburstmc.math.vector.Vector3i blockPos, int slot)
    • restoreCorrectBlockAndItem

      public static void restoreCorrectBlockAndItem(GeyserSession session, org.cloudburstmc.math.vector.Vector3i vector, BlockState blockState, int slot)
    • stopBreakAndRestoreBlock

      public static void stopBreakAndRestoreBlock(GeyserSession session, org.cloudburstmc.math.vector.Vector3i vector, BlockState blockState)
    • blockMatchesPredicate

      public static boolean blockMatchesPredicate(GeyserSession session, BlockState state, org.geysermc.mcprotocollib.protocol.data.game.item.component.AdventureModePredicate.BlockPredicate predicate)