Package commoble.bagofyurting

# Class BlockRemovalSorter

java.lang.Object
commoble.bagofyurting.BlockRemovalSorter

All Implemented Interfaces:
  `Comparator<net.minecraft.core.BlockPos>`

public class BlockRemovalSorter extends Object implements Comparator<net.minecraft.core.BlockPos>

## Constructor Summary

Constructors
Constructor
Description
`BlockRemovalSorter​(net.minecraft.world.level.Level Level)`

## Method Summary

Modifier and Type
Method
Description
`int`
`compare​(net.minecraft.core.BlockPos posA, net.minecraft.core.BlockPos posB)`
When we remove blocks, we want to remove them in layers from top to bottom, with the non-solid blocks in each layer being removed before the solid blocks.
`int`
`getSortValue​(net.minecraft.core.BlockPos pos)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.Comparator

`equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

## Constructor Details

### BlockRemovalSorter

public BlockRemovalSorter​(net.minecraft.world.level.Level Level)

## Method Details

### compare

public int compare​(net.minecraft.core.BlockPos posA, net.minecraft.core.BlockPos posB)
When we remove blocks, we want to remove them in layers from top to bottom, with the non-solid blocks in each layer being removed before the solid blocks. We can assume some things: -- the y-difference between posA and posB is less than a few hundred -- no y-level in posA or posB will be close to the largest positive or lowest negative integer in java if we sort a list, the lowest-valued thing will be first, so we want the highest-y-value to have the lowest sorting value Solution: "double" the y-position (all y-levels are now even) and if the block is non-solid, add 1 to it (making it appear "higher" than solid blocks in the same layer, but not higher than the next layer)

Specified by:
  `compare` in interface `Comparator<net.minecraft.core.BlockPos>`

### getSortValue

public int getSortValue​(net.minecraft.core.BlockPos pos)