Class WorldHelper
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanblocksMovement(net.minecraft.core.BlockPos pos) Checks if a block blocks movement (has a collision box).static booleancanBreak(net.minecraft.core.BlockPos pos) Checks if a block can be broken.static booleancanMine(net.minecraft.core.BlockPos pos) Checks if a block can be mined.static booleancanPlaceAt(net.minecraft.core.BlockPos pos) Checks if a block can be placed at the given position.static net.minecraft.core.BlockPosfindDoubleHole(net.minecraft.core.BlockPos pos) Finds a connected double hole adjacent to the given position.static net.minecraft.core.BlockPosfindSafeDoubleHole(net.minecraft.core.BlockPos pos) Finds a connected safe double hole adjacent to the given position.static net.minecraft.core.BlockPosfindUnsafeDoubleHole(net.minecraft.core.BlockPos pos) Finds a connected unsafe double hole adjacent to the given position.static net.minecraft.world.phys.Vec3findVisiblePointOnBlock(net.minecraft.core.BlockPos pos, net.minecraft.world.phys.Vec3 eyePos) Finds a visible point on a block's surface from the given eye position.static doublegetBlastResistance(net.minecraft.core.BlockPos pos) Gets the blast resistance of a block.static net.minecraft.world.level.block.BlockgetBlock(net.minecraft.core.BlockPos pos) Gets the block at the given position.static Iterable<net.minecraft.world.level.block.entity.BlockEntity> Gets all block entities in the world.static net.minecraft.world.level.block.entity.BlockEntitygetBlockEntity(net.minecraft.core.BlockPos pos) Gets the block entity at the given position.static net.minecraft.world.level.block.state.BlockStategetBlockState(net.minecraft.core.BlockPos pos) Gets the block state at the given position.static floatgetHardness(net.minecraft.core.BlockPos pos) Gets the hardness of a block.static intGets the current render distance.static booleanhasBlockEntity(net.minecraft.core.BlockPos pos) Checks if a position has a block entity.static booleanisAir(net.minecraft.core.BlockPos pos) Checks if a block position contains air.static booleanisBeingMined(net.minecraft.core.BlockPos pos) Checks if a block is currently being mined by the mining system.static booleanisBeingMined(net.minecraft.core.BlockPos pos, boolean predicted) Checks if a block is currently being mined, with option for predicted mining.static booleanisClear(net.minecraft.core.BlockPos pos, int height) Checks if a position and the vertical space above it are composed entirely of Air.static booleanisHole(net.minecraft.core.BlockPos pos) Checks if a position is a hole.static booleanisHole(net.minecraft.core.BlockPos pos, boolean doubles) Checks if a position is a hole, with support for double holes.static booleanisInRenderDistance(net.minecraft.core.BlockPos pos) Checks if a position is within render distance.static booleanisInWorldBounds(net.minecraft.core.BlockPos pos) Checks if a position is within the world's valid boundaries.static booleanisRegionLoaded(net.minecraft.core.BlockPos pos) Checks if the chunk region containing the position is loaded.static booleanisReplaceable(net.minecraft.core.BlockPos pos) Checks if a block can be replaced (is air or fluid).static booleanisSafeHole(net.minecraft.core.BlockPos pos) Checks if a position is a safe hole.static booleanisSafeHole(net.minecraft.core.BlockPos pos, boolean doubles) Checks if a position is a safe hole, with support for double holes.static booleanisSolidBlock(net.minecraft.core.BlockPos pos) Checks if a block is solid (opaque and blocks light).static booleanisUnbreakable(net.minecraft.core.BlockPos pos) Checks if a block is unbreakable.static booleanisUnsafeHole(net.minecraft.core.BlockPos pos) Checks if a position is an unsafe hole.static booleanisUnsafeHole(net.minecraft.core.BlockPos pos, boolean doubles) Checks if a position is an unsafe hole, with support for double holes.static booleanisValidPlacement(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.Block block) Checks if a specific block can be placed at the given position.static net.minecraft.world.phys.BlockHitResultraycast(net.minecraft.world.phys.Vec3 start, net.minecraft.world.phys.Vec3 end) Performs a raycast between two points in the world.
-
Constructor Details
-
WorldHelper
public WorldHelper()
-
-
Method Details
-
isHole
public static boolean isHole(net.minecraft.core.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.core.BlockPos pos, boolean doubles) Checks if a position is a hole, with support for double holes.- Parameters:
pos- The position to checkdoubles- Whether to include checks for 2x1 double holes- Returns:
- true if the position is a hole
-
isSafeHole
public static boolean isSafeHole(net.minecraft.core.BlockPos pos) Checks if a position is a safe hole.A safe hole is surrounded by unbreakable blocks (e.g., Bedrock, End Portal Frames) on all relevant sides. This provides maximum protection from crystal damage as the walls cannot be broken or exploded.
- Parameters:
pos- The position to check- Returns:
- true if the position is a safe hole
-
isSafeHole
public static boolean isSafeHole(net.minecraft.core.BlockPos pos, boolean doubles) Checks if a position is a safe hole, with support for double holes.A safe hole is surrounded by unbreakable blocks on all sides.
- Parameters:
pos- The position to checkdoubles- Whether to include checks for 2x1 double holes- Returns:
- true if the position is a safe hole
-
isUnsafeHole
public static boolean isUnsafeHole(net.minecraft.core.BlockPos pos) Checks if a position is an unsafe hole.An unsafe hole is surrounded by blast-resistant blocks (like Obsidian) that can eventually be broken. This provides blast protection but is less secure than a safe hole.
- Parameters:
pos- The position to check- Returns:
- true if the position is an unsafe hole
-
isUnsafeHole
public static boolean isUnsafeHole(net.minecraft.core.BlockPos pos, boolean doubles) Checks if a position is an unsafe hole, with support for double holes.An unsafe hole is surrounded by blast-resistant blocks (like Obsidian).
- Parameters:
pos- The position to checkdoubles- Whether to include checks for 2x1 double holes- Returns:
- true if the position is an unsafe hole
-
findDoubleHole
public static net.minecraft.core.BlockPos findDoubleHole(net.minecraft.core.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.core.BlockPos findSafeDoubleHole(net.minecraft.core.BlockPos pos) Finds a connected safe double hole adjacent to the given position.Requires the entire perimeter to be composed of unbreakable blocks.
- Parameters:
pos- The reference position- Returns:
- The position of the connected safe hole, or null if none found
-
findUnsafeDoubleHole
public static net.minecraft.core.BlockPos findUnsafeDoubleHole(net.minecraft.core.BlockPos pos) Finds a connected unsafe double hole adjacent to the given position.Requires the entire perimeter to be composed of blast-resistant blocks.
- 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.core.BlockPos pos) Checks if a block position contains air.- Parameters:
pos- The position to check- Returns:
- true if the block at position is air
-
isClear
public static boolean isClear(net.minecraft.core.BlockPos pos, int height) Checks if a position and the vertical space above it are composed entirely of Air.This checks the block at
posand the blocks above it up toheight.- Parameters:
pos- The base position (floor level of the column).height- The total height of the column to check.- Returns:
- true if the block at
posand the blocks above it are Air.
-
isReplaceable
public static boolean isReplaceable(net.minecraft.core.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.core.BlockPos pos) Checks if a block blocks movement (has a collision box).- Parameters:
pos- The position to check- Returns:
- true if the block blocks movement
-
isSolidBlock
public static boolean isSolidBlock(net.minecraft.core.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.world.level.block.state.BlockState getBlockState(net.minecraft.core.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.world.level.block.Block getBlock(net.minecraft.core.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.core.BlockPos pos) Gets the blast resistance of a block.Higher values indicate more explosion-resistant blocks. Bedrock has resistance 3,600,000.0F, obsidian has 1,200.0F.
- Parameters:
pos- The position to check- Returns:
- The blast resistance value
-
isUnbreakable
public static boolean isUnbreakable(net.minecraft.core.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.core.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.core.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.core.BlockPos pos, net.minecraft.world.level.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 checkblock- The block to place- Returns:
- true if the block can be placed at this position
-
isInWorldBounds
public static boolean isInWorldBounds(net.minecraft.core.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.core.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.core.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.core.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.core.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.core.BlockPos pos) Checks if a block is currently being mined by the mining system.- Parameters:
pos- The position to check- Returns:
- true if the block is being broken
-
isBeingMined
public static boolean isBeingMined(net.minecraft.core.BlockPos pos, boolean predicted) Checks if a block is currently being mined, with option for predicted mining.- Parameters:
pos- The position to checkpredicted- Whether to include predicted mining data (client-side packets)- Returns:
- true if the block is being broken
-
hasBlockEntity
public static boolean hasBlockEntity(net.minecraft.core.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.world.level.block.entity.BlockEntity getBlockEntity(net.minecraft.core.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
Gets all block entities in the world.- Returns:
- An iterable of all block entities
-
raycast
public static net.minecraft.world.phys.BlockHitResult raycast(net.minecraft.world.phys.Vec3 start, net.minecraft.world.phys.Vec3 end) Performs a raycast between two points in the world.- Parameters:
start- The starting positionend- The ending position- Returns:
- The block hit result, or null if no block was hit
-
findVisiblePointOnBlock
public static net.minecraft.world.phys.Vec3 findVisiblePointOnBlock(net.minecraft.core.BlockPos pos, net.minecraft.world.phys.Vec3 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 positioneyePos- The eye position to check visibility from- Returns:
- A visible point on the block surface
-