Package net.minecraft.world
Class BlockLocating
java.lang.Object
net.minecraft.world.BlockLocating
A few utilities to find block positions matching certain conditions.
- Mappings:
- Namespace - Name - official - l- intermediary - net/minecraft/class_5459- named - net/minecraft/world/BlockLocating
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic class
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfindColumnEnd(BlockView world, BlockPos pos, Block intermediateBlock, Direction direction, Block endBlock) Finds an end to a block column starting fromposextending indirection.(package private) static com.mojang.datafixers.util.Pair<BlockLocating.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 BlockLocating.RectanglegetLargestRectangle(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 intmoveWhile(Predicate<BlockPos> predicate, BlockPos.Mutable pos, Direction direction, int max) 
- 
Constructor Details- 
BlockLocatingpublic BlockLocating()
 
- 
- 
Method Details- 
getLargestRectanglepublic static BlockLocating.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.- Mappings:
- Namespace - Name - Mixin selector - official - a- Ll;a(Lgu;Lha$a;ILha$a;ILjava/util/function/Predicate;)Ll$a;- intermediary - method_30574- Lnet/minecraft/class_5459;method_30574(Lnet/minecraft/class_2338;Lnet/minecraft/class_2350$class_2351;ILnet/minecraft/class_2350$class_2351;ILjava/util/function/Predicate;)Lnet/minecraft/class_5459$class_5460;- named - getLargestRectangle- Lnet/minecraft/world/BlockLocating;getLargestRectangle(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction$Axis;ILnet/minecraft/util/math/Direction$Axis;ILjava/util/function/Predicate;)Lnet/minecraft/world/BlockLocating$Rectangle;
 
- 
moveWhileprivate static int moveWhile(Predicate<BlockPos> predicate, BlockPos.Mutable pos, Direction direction, int max) - Mappings:
- Namespace - Name - Mixin selector - official - a- Ll;a(Ljava/util/function/Predicate;Lgu$a;Lha;I)I- intermediary - method_30575- Lnet/minecraft/class_5459;method_30575(Ljava/util/function/Predicate;Lnet/minecraft/class_2338$class_2339;Lnet/minecraft/class_2350;I)I- named - moveWhile- Lnet/minecraft/world/BlockLocating;moveWhile(Ljava/util/function/Predicate;Lnet/minecraft/util/math/BlockPos$Mutable;Lnet/minecraft/util/math/Direction;I)I
 
- 
findLargestRectanglestatic com.mojang.datafixers.util.Pair<BlockLocating.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:
- Implementation Note:
- This implementation solves the problem using a stack. The
 stack maintains a collection of height limits of rectangles that may grow as the
 array iteration continues. When a new height is encountered, each position pin the stack would be popped if the rectangle with height limit at positionpcan no longer extend right. The popped rectangle becomes the return value if it has a larger area than the current candidate.When the rectangle area is calculated, the range is between p0 + 1, wherep0is the current top of stack after popping rectangles that can no longer extend, and the current iterated positioni.
- Mappings:
- Namespace - Name - Mixin selector - official - a- Ll;a([I)Lcom/mojang/datafixers/util/Pair;- intermediary - method_30576- Lnet/minecraft/class_5459;method_30576([I)Lcom/mojang/datafixers/util/Pair;- named - findLargestRectangle- Lnet/minecraft/world/BlockLocating;findLargestRectangle([I)Lcom/mojang/datafixers/util/Pair;
 
- 
findColumnEndpublic static Optional<BlockPos> findColumnEnd(BlockView world, BlockPos pos, Block intermediateBlock, Direction direction, Block endBlock) Finds an end to a block column starting fromposextending indirection. Within the column, the block states must be ofintermediateBlockand the ending block state, whose position is returned, must be ofendBlock.- Parameters:
- world- the world the column is in
- pos- the starting position of the column
- intermediateBlock- the blocks that the column must be of, excluding the end
- direction- the direction which the column extends to
- endBlock- the ending block of the column
- Returns:
- the end position of the block column where a endBlocklays, or an empty optional if no such column exists
- Mappings:
- Namespace - Name - Mixin selector - official - a- Ll;a(Lcls;Lgu;Lcpn;Lha;Lcpn;)Ljava/util/Optional;- intermediary - method_34851- Lnet/minecraft/class_5459;method_34851(Lnet/minecraft/class_1922;Lnet/minecraft/class_2338;Lnet/minecraft/class_2248;Lnet/minecraft/class_2350;Lnet/minecraft/class_2248;)Ljava/util/Optional;- named - findColumnEnd- Lnet/minecraft/world/BlockLocating;findColumnEnd(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;Lnet/minecraft/util/math/Direction;Lnet/minecraft/block/Block;)Ljava/util/Optional;
 
 
-