Contents
- Description
- Constructor Summary
- Method Summary
- Constructor Details
- Method Details
- isFluidOnlyBlock(BlockType, int)
- isSolidOnlyBlock(BlockType, int)
- isEmptyOnlyBlock(BlockType, int)
- getFluidIdAtPosition(ChunkStore, int, int, int)
- getPackedMaterialAndFluidAtPosition(ChunkStore, double, double, double)
- findFluidBlock(ChunkStore, int, int, int, boolean)
- getWaterLevel(ChunkStore, int, int, int, int)
- findFarthestEmptySpaceBelow(ChunkStore, int, int, int, int, int)
- findFarthestEmptySpaceAbove(ChunkStore, int, int, int, int, int)
Class WorldUtil
java.lang.Object
com.hypixel.hytale.server.core.modules.collision.WorldUtil
A utility class for collision-specific world functions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intfindFarthestEmptySpaceAbove(ChunkStore chunkStore, int x, int y, int z, int yFail, int maxY) Compute y block position of the farthest consecutive empty block above given position.static intfindFarthestEmptySpaceBelow(ChunkStore chunkStore, int x, int y, int z, int yFail, int minY) Compute y block position of the farthest consecutive empty block below given position.static intfindFluidBlock(ChunkStore chunkStore, int x, int y, int z, boolean allowBubble) Get bottom most fluid block for fluid depth computation.static intgetFluidIdAtPosition(ChunkStore chunkStore, int x, int y, int z) Returns the fluid ID at the given block position.static longgetPackedMaterialAndFluidAtPosition(ChunkStore chunkStore, double x, double y, double z) Returns the material and fluid ID at the given position, packed into a long.static intgetWaterLevel(ChunkStore chunkStore, int x, int z, int startY, int maxY) Compute water level at a given block position.static booleanisEmptyOnlyBlock(BlockType blockType, int fluidId) Determine if a block is plain empty.static booleanisFluidOnlyBlock(BlockType blockType, int fluidId) Determine if a block consists only of fluid regarding collisions.static booleanisSolidOnlyBlock(BlockType blockType, int fluidId) Determine if a block is solid without fluid.
-
Constructor Details
-
WorldUtil
public WorldUtil()
-
-
Method Details
-
isFluidOnlyBlock
Determine if a block consists only of fluid regarding collisions.- Parameters:
blockType- BlockType to test.fluidId- The fluid ID at the block position.- Returns:
- true if the block can be considered fluid only.
-
isSolidOnlyBlock
Determine if a block is solid without fluid.- Parameters:
blockType- BlockType to test.fluidId- The fluid ID at the block position.- Returns:
- true if block is solid and contains no fluid.
-
isEmptyOnlyBlock
Determine if a block is plain empty.- Parameters:
blockType- BlockType to test.fluidId- The fluid ID at the block position.- Returns:
- true if block is empty and contains no fluid.
-
getFluidIdAtPosition
Returns the fluid ID at the given block position.- Parameters:
chunkStore- The chunk store to resolve the section from.x- The X block coordinate.y- The Y block coordinate.z- The Z block coordinate.- Returns:
- the fluid ID at the position, or
Fluid.EMPTY_IDif none.
-
getPackedMaterialAndFluidAtPosition
public static long getPackedMaterialAndFluidAtPosition(@Nonnull ChunkStore chunkStore, double x, double y, double z) Returns the material and fluid ID at the given position, packed into a long.The material ordinal is packed into the left 32 bits, and the fluid ID is packed into the right 32 bits. Use
MathUtil.unpackLeft(long)to extract the material ordinal, andMathUtil.unpackRight(long)to extract the fluid ID.- Parameters:
chunkStore- The chunk store to resolve the section from.x- The X coordinate of the position.y- The Y coordinate of the position.z- The Z coordinate of the position.- Returns:
- a packed long containing material ordinal, left, and fluid ID, right.
-
findFluidBlock
public static int findFluidBlock(@Nonnull ChunkStore chunkStore, int x, int y, int z, boolean allowBubble) Get bottom most fluid block for fluid depth computation.The initial block x/y/z can point to a non fluid block if allowBubble is set to true. In that case x/y/z is assumed to be a ground block and an empty block can be on top (caused by submerging blocks).
- Parameters:
chunkStore- The chunk store to resolve sections from.x- The X block coordinate.y- The Y block coordinate.z- The Z block coordinate.allowBubble- Tolerate a ground bubble from submerging.- Returns:
- y coordinate of fluid block or -1 if there is none.
-
getWaterLevel
Compute water level at a given block position.Water level is given by a consecutive number of fully fluid blocks from start position upwards allowing for a ground bubble.
- Parameters:
chunkStore- The chunk store to resolve sections from.x- The X block coordinate.z- The Z block coordinate.startY- The Y coordinate to start.maxY- The highest Y block coordinate the walk may visit.- Returns:
- water level from this position upwards or -1 if there is no water.
-
findFarthestEmptySpaceBelow
public static int findFarthestEmptySpaceBelow(@Nonnull ChunkStore chunkStore, int x, int y, int z, int yFail, int minY) Compute y block position of the farthest consecutive empty block below given position.- Parameters:
chunkStore- The chunk store to resolve sections from.x- The X block coordinate.y- The Y block coordinate.z- The Z block coordinate.yFail- The Y value to be returned when initial y is belowminY.minY- The lowest Y block coordinate the scan may visit.- Returns:
- y block coordinate of farthest empty block below initial block position,
minYwhen the scan reaches it, or yFail.
-
findFarthestEmptySpaceAbove
public static int findFarthestEmptySpaceAbove(@Nonnull ChunkStore chunkStore, int x, int y, int z, int yFail, int maxY) Compute y block position of the farthest consecutive empty block above given position.- Parameters:
chunkStore- The chunk store to resolve sections from.x- The X block coordinate.y- The Y block coordinate.z- The Z block coordinate.yFail- The Y value to be returned when initial y is abovemaxY.maxY- The highest Y block coordinate the scan may visit.- Returns:
- y block coordinate of farthest empty block above initial block position,
maxYwhen the scan reaches it, or yFail.
-