Class WorldHelper

java.lang.Object
dev.boze.api.utility.WorldHelper

public class WorldHelper extends Object
WorldHelper provides world and block-related utilities.

This class offers comprehensive utilities for interacting with the Minecraft world, including hole detection, block state queries, placement validation, and mining operations. All methods handle null positions and world safety appropriately.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    blocksMovement(net.minecraft.util.math.BlockPos pos)
    Checks if a block blocks movement (solid blocks).
    static boolean
    canBreak(net.minecraft.util.math.BlockPos pos)
    Checks if a block can be broken.
    static boolean
    canMine(net.minecraft.util.math.BlockPos pos)
    Checks if a block can be mined.
    static boolean
    canPlaceAt(net.minecraft.util.math.BlockPos pos)
    Checks if a block can be placed at the given position.
    static net.minecraft.util.math.BlockPos
    findDoubleHole(net.minecraft.util.math.BlockPos pos)
    Finds a connected double hole adjacent to the given position.
    static net.minecraft.util.math.BlockPos
    findSafeDoubleHole(net.minecraft.util.math.BlockPos pos)
    Finds a connected safe double hole adjacent to the given position.
    static net.minecraft.util.math.BlockPos
    findUnsafeDoubleHole(net.minecraft.util.math.BlockPos pos)
    Finds a connected unsafe double hole adjacent to the given position.
    static net.minecraft.util.math.Vec3d
    findVisiblePointOnBlock(net.minecraft.util.math.BlockPos pos, net.minecraft.util.math.Vec3d eyePos)
    Finds a visible point on a block's surface from the given eye position.
    static double
    getBlastResistance(net.minecraft.util.math.BlockPos pos)
    Gets the blast resistance of a block.
    static net.minecraft.block.Block
    getBlock(net.minecraft.util.math.BlockPos pos)
    Gets the block at the given position.
    static Iterable<net.minecraft.block.entity.BlockEntity>
    Gets all block entities in the world.
    static net.minecraft.block.entity.BlockEntity
    getBlockEntity(net.minecraft.util.math.BlockPos pos)
    Gets the block entity at the given position.
    static net.minecraft.block.BlockState
    getBlockState(net.minecraft.util.math.BlockPos pos)
    Gets the block state at the given position.
    static float
    getHardness(net.minecraft.util.math.BlockPos pos)
    Gets the hardness of a block.
    static int
    Gets the current render distance.
    static boolean
    hasBlockEntity(net.minecraft.util.math.BlockPos pos)
    Checks if a position has a block entity.
    static boolean
    isAir(net.minecraft.util.math.BlockPos pos)
    Checks if a block position contains air.
    static boolean
    isBeingMined(net.minecraft.util.math.BlockPos pos)
    Checks if a block is currently being mined.
    static boolean
    isBeingMined(net.minecraft.util.math.BlockPos pos, boolean predicted)
    Checks if a block is currently being mined, with option for predicted mining.
    static boolean
    isHole(net.minecraft.util.math.BlockPos pos)
    Checks if a position is a hole.
    static boolean
    isHole(net.minecraft.util.math.BlockPos pos, boolean doubles)
    Checks if a position is a hole, with option for double holes.
    static boolean
    isInRenderDistance(net.minecraft.util.math.BlockPos pos)
    Checks if a position is within render distance.
    static boolean
    isInWorldBounds(net.minecraft.util.math.BlockPos pos)
    Checks if a position is within the world's valid boundaries.
    static boolean
    isRegionLoaded(net.minecraft.util.math.BlockPos pos)
    Checks if the chunk region containing the position is loaded.
    static boolean
    isReplaceable(net.minecraft.util.math.BlockPos pos)
    Checks if a block can be replaced (is air or fluid).
    static boolean
    isSafeHole(net.minecraft.util.math.BlockPos pos)
    Checks if a position is a safe (bedrock) hole.
    static boolean
    isSafeHole(net.minecraft.util.math.BlockPos pos, boolean doubles)
    Checks if a position is a safe (bedrock) hole, with option for double holes.
    static boolean
    isSolidBlock(net.minecraft.util.math.BlockPos pos)
    Checks if a block is solid (opaque and blocks light).
    static boolean
    isUnbreakable(net.minecraft.util.math.BlockPos pos)
    Checks if a block is unbreakable.
    static boolean
    isUnsafeHole(net.minecraft.util.math.BlockPos pos)
    Checks if a position is an unsafe (obsidian) hole.
    static boolean
    isUnsafeHole(net.minecraft.util.math.BlockPos pos, boolean doubles)
    Checks if a position is an unsafe (obsidian) hole, with option for double holes.
    static boolean
    isValidPlacement(net.minecraft.util.math.BlockPos pos, net.minecraft.block.Block block)
    Checks if a specific block can be placed at the given position.
    static net.minecraft.util.hit.BlockHitResult
    raycast(net.minecraft.util.math.Vec3d start, net.minecraft.util.math.Vec3d end)
    Performs a raycast between two points in the world.

    Methods inherited from class java.lang.Object

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

    • WorldHelper

      public WorldHelper()
  • Method Details

    • isHole

      public static boolean isHole(net.minecraft.util.math.BlockPos pos)
      Checks if a position is a hole.

      A hole is surrounded by solid blocks on all horizontal sides and below, with air blocks at the hole position and above it.
      Parameters:
      pos - The position to check
      Returns:
      true if the position is a hole
    • isHole

      public static boolean isHole(net.minecraft.util.math.BlockPos pos, boolean doubles)
      Checks if a position is a hole, with option for double holes.

      Parameters:
      pos - The position to check
      doubles - Whether to check for double holes
      Returns:
      true if the position is a hole
    • isSafeHole

      public static boolean isSafeHole(net.minecraft.util.math.BlockPos pos)
      Checks if a position is a safe (bedrock) hole.

      A safe hole is surrounded by bedrock blocks on all sides. This provides maximum protection from crystal damage.
      Parameters:
      pos - The position to check
      Returns:
      true if the position is a safe bedrock hole
    • isUnsafeHole

      public static boolean isUnsafeHole(net.minecraft.util.math.BlockPos pos)
      Checks if a position is an unsafe (obsidian) hole.

      An unsafe hole is surrounded by obsidian/crying obsidian blocks. This provides less protection than bedrock but is still commonly used.
      Parameters:
      pos - The position to check
      Returns:
      true if the position is an unsafe obsidian hole
    • isSafeHole

      public static boolean isSafeHole(net.minecraft.util.math.BlockPos pos, boolean doubles)
      Checks if a position is a safe (bedrock) hole, with option for double holes.

      A safe hole is surrounded by bedrock blocks on all sides. When doubles is true, checks for 3-block-high holes instead of 2-block-high.
      Parameters:
      pos - The position to check
      doubles - Whether to check for double holes
      Returns:
      true if the position is a safe bedrock hole
    • isUnsafeHole

      public static boolean isUnsafeHole(net.minecraft.util.math.BlockPos pos, boolean doubles)
      Checks if a position is an unsafe (obsidian) hole, with option for double holes.

      An unsafe hole is surrounded by obsidian/crying obsidian blocks. When doubles is true, checks for 3-block-high holes instead of 2-block-high.
      Parameters:
      pos - The position to check
      doubles - Whether to check for double holes
      Returns:
      true if the position is an unsafe obsidian hole
    • findDoubleHole

      public static net.minecraft.util.math.BlockPos findDoubleHole(net.minecraft.util.math.BlockPos pos)
      Finds a connected double hole adjacent to the given position.

      Searches west, east, north, and south positions for a connected hole that forms a double hole pattern with the given position.
      Parameters:
      pos - The reference position
      Returns:
      The position of the connected hole, or null if none found
    • findSafeDoubleHole

      public static net.minecraft.util.math.BlockPos findSafeDoubleHole(net.minecraft.util.math.BlockPos pos)
      Finds a connected safe double hole adjacent to the given position.

      Searches adjacent positions (west, east, north, south) for a safe hole that forms a double hole pattern with the reference position.
      Parameters:
      pos - The reference position
      Returns:
      The position of the connected safe hole, or null if none found
    • findUnsafeDoubleHole

      public static net.minecraft.util.math.BlockPos findUnsafeDoubleHole(net.minecraft.util.math.BlockPos pos)
      Finds a connected unsafe double hole adjacent to the given position.

      Searches adjacent positions (west, east, north, south) for an unsafe hole that forms a double hole pattern with the reference position.
      Parameters:
      pos - The reference position
      Returns:
      The position of the connected unsafe hole, or null if none found
    • isAir

      public static boolean isAir(net.minecraft.util.math.BlockPos pos)
      Checks if a block position contains air.
      Parameters:
      pos - The position to check
      Returns:
      true if the block at position is air
    • isReplaceable

      public static boolean isReplaceable(net.minecraft.util.math.BlockPos pos)
      Checks if a block can be replaced (is air or fluid).
      Parameters:
      pos - The position to check
      Returns:
      true if the block can be replaced
    • blocksMovement

      public static boolean blocksMovement(net.minecraft.util.math.BlockPos pos)
      Checks if a block blocks movement (solid blocks).
      Parameters:
      pos - The position to check
      Returns:
      true if the block blocks movement
    • isSolidBlock

      public static boolean isSolidBlock(net.minecraft.util.math.BlockPos pos)
      Checks if a block is solid (opaque and blocks light).
      Parameters:
      pos - The position to check
      Returns:
      true if the block is solid
    • getBlockState

      public static net.minecraft.block.BlockState getBlockState(net.minecraft.util.math.BlockPos pos)
      Gets the block state at the given position.
      Parameters:
      pos - The position to get block state from
      Returns:
      The block state at the position
    • getBlock

      public static net.minecraft.block.Block getBlock(net.minecraft.util.math.BlockPos pos)
      Gets the block at the given position.
      Parameters:
      pos - The position to get block from
      Returns:
      The block at the position
    • getBlastResistance

      public static double getBlastResistance(net.minecraft.util.math.BlockPos pos)
      Gets the blast resistance of a block.

      Higher values indicate more explosion-resistant blocks. Bedrock has resistance 3600000.0F, obsidian has 1200.0F.
      Parameters:
      pos - The position to check
      Returns:
      The blast resistance value
    • isUnbreakable

      public static boolean isUnbreakable(net.minecraft.util.math.BlockPos pos)
      Checks if a block is unbreakable.

      Unbreakable blocks include bedrock, command blocks, barriers, etc.
      Parameters:
      pos - The position to check
      Returns:
      true if the block cannot be broken
    • canBreak

      public static boolean canBreak(net.minecraft.util.math.BlockPos pos)
      Checks if a block can be broken.

      Takes into account block hardness and game rules.
      Parameters:
      pos - The position to check
      Returns:
      true if the block can be broken
    • canPlaceAt

      public static boolean canPlaceAt(net.minecraft.util.math.BlockPos pos)
      Checks if a block can be placed at the given position.

      Takes into account block state and surrounding blocks.
      Parameters:
      pos - The position to check for placement
      Returns:
      true if a block can be placed at this position
    • isValidPlacement

      public static boolean isValidPlacement(net.minecraft.util.math.BlockPos pos, net.minecraft.block.Block block)
      Checks if a specific block can be placed at the given position.

      Validates that the block placement follows Minecraft's placement rules.
      Parameters:
      pos - The position to check
      block - The block to place
      Returns:
      true if the block can be placed at this position
    • isInWorldBounds

      public static boolean isInWorldBounds(net.minecraft.util.math.BlockPos pos)
      Checks if a position is within the world's valid boundaries.
      Parameters:
      pos - The position to check
      Returns:
      true if the position is within world bounds
    • isRegionLoaded

      public static boolean isRegionLoaded(net.minecraft.util.math.BlockPos pos)
      Checks if the chunk region containing the position is loaded.
      Parameters:
      pos - The position to check
      Returns:
      true if the region is loaded
    • getRenderDistance

      public static int getRenderDistance()
      Gets the current render distance.
      Returns:
      The render distance in chunks
    • isInRenderDistance

      public static boolean isInRenderDistance(net.minecraft.util.math.BlockPos pos)
      Checks if a position is within render distance.
      Parameters:
      pos - The position to check
      Returns:
      true if the position is within render distance
    • canMine

      public static boolean canMine(net.minecraft.util.math.BlockPos pos)
      Checks if a block can be mined.

      Takes into account block hardness, tools available, and game rules.
      Parameters:
      pos - The position to check
      Returns:
      true if the block can be mined
    • getHardness

      public static float getHardness(net.minecraft.util.math.BlockPos pos)
      Gets the hardness of a block.

      Hardness determines how long it takes to break the block.
      Parameters:
      pos - The position to check
      Returns:
      The block hardness value
    • isBeingMined

      public static boolean isBeingMined(net.minecraft.util.math.BlockPos pos)
      Checks if a block is currently being mined.
      Parameters:
      pos - The position to check
      Returns:
      true if the block is being broken
    • isBeingMined

      public static boolean isBeingMined(net.minecraft.util.math.BlockPos pos, boolean predicted)
      Checks if a block is currently being mined, with option for predicted mining.
      Parameters:
      pos - The position to check
      predicted - Whether to include predicted mining data
      Returns:
      true if the block is being broken
    • hasBlockEntity

      public static boolean hasBlockEntity(net.minecraft.util.math.BlockPos pos)
      Checks if a position has a block entity.
      Parameters:
      pos - The position to check
      Returns:
      true if the position has a block entity
    • getBlockEntity

      public static net.minecraft.block.entity.BlockEntity getBlockEntity(net.minecraft.util.math.BlockPos pos)
      Gets the block entity at the given position.
      Parameters:
      pos - The position to get block entity from
      Returns:
      The block entity, or null if none exists
    • getBlockEntities

      public static Iterable<net.minecraft.block.entity.BlockEntity> getBlockEntities()
      Gets all block entities in the world.
      Returns:
      An iterable of all block entities
    • raycast

      public static net.minecraft.util.hit.BlockHitResult raycast(net.minecraft.util.math.Vec3d start, net.minecraft.util.math.Vec3d end)
      Performs a raycast between two points in the world.
      Parameters:
      start - The starting position
      end - The ending position
      Returns:
      The block hit result, or null if no block was hit
    • findVisiblePointOnBlock

      public static net.minecraft.util.math.Vec3d findVisiblePointOnBlock(net.minecraft.util.math.BlockPos pos, net.minecraft.util.math.Vec3d eyePos)
      Finds a visible point on a block's surface from the given eye position.

      Calculates the closest visible point on the block's surface that would be visible from the eye position.
      Parameters:
      pos - The block position
      eyePos - The eye position to check visibility from
      Returns:
      A visible point on the block surface