Package net.minecraft.world
Class PortalUtil
java.lang.Object
net.minecraft.world.PortalUtil
public class PortalUtil extends Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PortalUtil.IntBounds
static class
PortalUtil.Rectangle
-
Constructor Summary
Constructors Constructor Description PortalUtil()
-
Method Summary
Modifier and Type Method Description (package private) static com.mojang.datafixers.util.Pair<PortalUtil.IntBounds,Integer>
findLargestRectangle(int[] heights)
Finds the largest rectangle within a histogram, where the vertical bars each have width 1 and height specified inheights
.static PortalUtil.Rectangle
getLargestRectangle(BlockPos center, Direction.Axis primaryAxis, int primaryMaxBlocks, Direction.Axis secondaryAxis, int secondaryMaxBlocks, Predicate<BlockPos> predicate)
Gets the largest rectangle of blocks along two axes for which all blocks meet a predicate.private static int
moveWhile(Predicate<BlockPos> predicate, BlockPos.Mutable mutable, Direction direction, int max)
-
Constructor Details
-
PortalUtil
public PortalUtil()
-
-
Method Details
-
getLargestRectangle
public static PortalUtil.Rectangle getLargestRectangle(BlockPos center, Direction.Axis primaryAxis, int primaryMaxBlocks, Direction.Axis secondaryAxis, int secondaryMaxBlocks, Predicate<BlockPos> predicate)Gets the largest rectangle of blocks along two axes for which all blocks meet a predicate. Used for getting rectangles of Nether portal blocks. -
moveWhile
private static int moveWhile(Predicate<BlockPos> predicate, BlockPos.Mutable mutable, Direction direction, int max) -
findLargestRectangle
static com.mojang.datafixers.util.Pair<PortalUtil.IntBounds,Integer> findLargestRectangle(int[] heights)Finds the largest rectangle within a histogram, where the vertical bars each have width 1 and height specified inheights
.- Parameters:
heights
- the heights of bars in the histogram- Returns:
- the base of the rectangle as an inclusive range and the height of the rectangle packed in a pair
- See Also:
- Largest Rectangle in Histogram - LeetCode
-