Replaces all custom number comparisons with java provided ones. (#3434)
This commit is contained in:
@@ -24,7 +24,6 @@ import javax.annotation.Nonnull;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ItemSorters;
|
||||
|
||||
|
||||
public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
|
||||
@@ -57,7 +56,7 @@ public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
|
||||
@Override
|
||||
public int compareTo( @Nonnull final ClientDCInternalInv o )
|
||||
{
|
||||
return ItemSorters.compareLong( this.sortBy, o.sortBy );
|
||||
return Long.compare( this.sortBy, o.sortBy );
|
||||
}
|
||||
|
||||
public AppEngInternalInventory getInventory()
|
||||
|
||||
@@ -22,7 +22,6 @@ package appeng.container.implementations;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.util.ItemSorters;
|
||||
|
||||
|
||||
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
||||
@@ -44,12 +43,12 @@ public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
||||
@Override
|
||||
public int compareTo( @Nonnull final CraftingCPURecord o )
|
||||
{
|
||||
final int a = ItemSorters.compareLong( o.getProcessors(), this.getProcessors() );
|
||||
final int a = Long.compare( o.getProcessors(), this.getProcessors() );
|
||||
if( a != 0 )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
return ItemSorters.compareLong( o.getSize(), this.getSize() );
|
||||
return Long.compare( o.getSize(), this.getSize() );
|
||||
}
|
||||
|
||||
ICraftingCPU getCpu()
|
||||
|
||||
@@ -44,7 +44,6 @@ import appeng.container.ContainerNull;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.ItemSorters;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
@@ -398,7 +397,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
@Override
|
||||
public int compareTo( final PatternHelper o )
|
||||
{
|
||||
return ItemSorters.compareInt( o.priority, this.priority );
|
||||
return Integer.compare( o.priority, this.priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,7 +79,6 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.me.helpers.BaseActionSource;
|
||||
import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.ItemSorters;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
@@ -295,7 +294,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
@Override
|
||||
public int compare( final IAEItemStack a, final IAEItemStack b )
|
||||
{
|
||||
return ItemSorters.compareInt( a.getItemDamage(), b.getItemDamage() );
|
||||
return Integer.compare( a.getItemDamage(), b.getItemDamage() );
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
+4
-5
@@ -86,7 +86,6 @@ import appeng.me.helpers.BaseActionSource;
|
||||
import appeng.me.helpers.GenericInterestManager;
|
||||
import appeng.tile.crafting.TileCraftingStorageTile;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.ItemSorters;
|
||||
|
||||
|
||||
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler<IAEItemStack>
|
||||
@@ -550,20 +549,20 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
{
|
||||
if( prioritizePower )
|
||||
{
|
||||
final int comparison = ItemSorters.compareLong( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() );
|
||||
final int comparison = Long.compare( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() );
|
||||
if( comparison != 0 )
|
||||
{
|
||||
return comparison;
|
||||
}
|
||||
return ItemSorters.compareLong( nextCluster.getAvailableStorage(), firstCluster.getAvailableStorage() );
|
||||
return Long.compare( nextCluster.getAvailableStorage(), firstCluster.getAvailableStorage() );
|
||||
}
|
||||
|
||||
final int comparison = ItemSorters.compareLong( firstCluster.getCoProcessors(), nextCluster.getCoProcessors() );
|
||||
final int comparison = Long.compare( firstCluster.getCoProcessors(), nextCluster.getCoProcessors() );
|
||||
if( comparison != 0 )
|
||||
{
|
||||
return comparison;
|
||||
}
|
||||
return ItemSorters.compareLong( firstCluster.getAvailableStorage(), nextCluster.getAvailableStorage() );
|
||||
return Long.compare( firstCluster.getAvailableStorage(), nextCluster.getAvailableStorage() );
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.cache.SecurityCache;
|
||||
import appeng.util.ItemSorters;
|
||||
|
||||
|
||||
public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
|
||||
@@ -48,7 +47,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
|
||||
private static final ThreadLocal<Deque> DEPTH_MOD = new ThreadLocal<>();
|
||||
private static final ThreadLocal<Deque> DEPTH_SIM = new ThreadLocal<>();
|
||||
private static final Comparator<Integer> PRIORITY_SORTER = ( o1, o2 ) -> ItemSorters.compareInt( o2, o1 );
|
||||
private static final Comparator<Integer> PRIORITY_SORTER = ( o1, o2 ) -> Integer.compare( o2, o1 );
|
||||
|
||||
private static int currentPass = 0;
|
||||
private final IStorageChannel<T> myChannel;
|
||||
|
||||
@@ -80,9 +80,9 @@ public class ItemSorters
|
||||
{
|
||||
if( getDirection() == SortDir.ASCENDING )
|
||||
{
|
||||
return compareLong( o2.getStackSize(), o1.getStackSize() );
|
||||
return Long.compare( o2.getStackSize(), o1.getStackSize() );
|
||||
}
|
||||
return compareLong( o1.getStackSize(), o2.getStackSize() );
|
||||
return Long.compare( o1.getStackSize(), o2.getStackSize() );
|
||||
}
|
||||
};
|
||||
private static IInvTweaks api;
|
||||
@@ -124,45 +124,6 @@ public class ItemSorters
|
||||
}
|
||||
}
|
||||
|
||||
public static int compareInt( final int a, final int b )
|
||||
{
|
||||
if( a == b )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if( a < b )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int compareLong( final long a, final long b )
|
||||
{
|
||||
if( a == b )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if( a < b )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int compareDouble( final double a, final double b )
|
||||
{
|
||||
if( a == b )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if( a < b )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static SortDir getDirection()
|
||||
{
|
||||
return Direction;
|
||||
|
||||
Reference in New Issue
Block a user