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 net.minecraft.util.text.translation.I18n;
|
||||||
|
|
||||||
import appeng.tile.inventory.AppEngInternalInventory;
|
import appeng.tile.inventory.AppEngInternalInventory;
|
||||||
import appeng.util.ItemSorters;
|
|
||||||
|
|
||||||
|
|
||||||
public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
|
public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
|
||||||
@@ -57,7 +56,7 @@ public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
|
|||||||
@Override
|
@Override
|
||||||
public int compareTo( @Nonnull final ClientDCInternalInv o )
|
public int compareTo( @Nonnull final ClientDCInternalInv o )
|
||||||
{
|
{
|
||||||
return ItemSorters.compareLong( this.sortBy, o.sortBy );
|
return Long.compare( this.sortBy, o.sortBy );
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppEngInternalInventory getInventory()
|
public AppEngInternalInventory getInventory()
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ package appeng.container.implementations;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import appeng.api.networking.crafting.ICraftingCPU;
|
import appeng.api.networking.crafting.ICraftingCPU;
|
||||||
import appeng.util.ItemSorters;
|
|
||||||
|
|
||||||
|
|
||||||
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
||||||
@@ -44,12 +43,12 @@ public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
|||||||
@Override
|
@Override
|
||||||
public int compareTo( @Nonnull final CraftingCPURecord o )
|
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 )
|
if( a != 0 )
|
||||||
{
|
{
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
return ItemSorters.compareLong( o.getSize(), this.getSize() );
|
return Long.compare( o.getSize(), this.getSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
ICraftingCPU getCpu()
|
ICraftingCPU getCpu()
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import appeng.container.ContainerNull;
|
|||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.util.ItemSorters;
|
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
|
|
||||||
@@ -398,7 +397,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
|||||||
@Override
|
@Override
|
||||||
public int compareTo( final PatternHelper o )
|
public int compareTo( final PatternHelper o )
|
||||||
{
|
{
|
||||||
return ItemSorters.compareInt( o.priority, this.priority );
|
return Integer.compare( o.priority, this.priority );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
|||||||
import appeng.me.helpers.BaseActionSource;
|
import appeng.me.helpers.BaseActionSource;
|
||||||
import appeng.me.storage.CellInventoryHandler;
|
import appeng.me.storage.CellInventoryHandler;
|
||||||
import appeng.tile.misc.TilePaint;
|
import appeng.tile.misc.TilePaint;
|
||||||
import appeng.util.ItemSorters;
|
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
|
|
||||||
@@ -295,7 +294,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
|||||||
@Override
|
@Override
|
||||||
public int compare( final IAEItemStack a, final IAEItemStack b )
|
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.me.helpers.GenericInterestManager;
|
||||||
import appeng.tile.crafting.TileCraftingStorageTile;
|
import appeng.tile.crafting.TileCraftingStorageTile;
|
||||||
import appeng.tile.crafting.TileCraftingTile;
|
import appeng.tile.crafting.TileCraftingTile;
|
||||||
import appeng.util.ItemSorters;
|
|
||||||
|
|
||||||
|
|
||||||
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler<IAEItemStack>
|
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler<IAEItemStack>
|
||||||
@@ -550,20 +549,20 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
|||||||
{
|
{
|
||||||
if( prioritizePower )
|
if( prioritizePower )
|
||||||
{
|
{
|
||||||
final int comparison = ItemSorters.compareLong( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() );
|
final int comparison = Long.compare( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() );
|
||||||
if( comparison != 0 )
|
if( comparison != 0 )
|
||||||
{
|
{
|
||||||
return comparison;
|
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 )
|
if( comparison != 0 )
|
||||||
{
|
{
|
||||||
return comparison;
|
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.IAEStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
import appeng.me.cache.SecurityCache;
|
import appeng.me.cache.SecurityCache;
|
||||||
import appeng.util.ItemSorters;
|
|
||||||
|
|
||||||
|
|
||||||
public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
|
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_MOD = new ThreadLocal<>();
|
||||||
private static final ThreadLocal<Deque> DEPTH_SIM = 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 static int currentPass = 0;
|
||||||
private final IStorageChannel<T> myChannel;
|
private final IStorageChannel<T> myChannel;
|
||||||
|
|||||||
@@ -80,9 +80,9 @@ public class ItemSorters
|
|||||||
{
|
{
|
||||||
if( getDirection() == SortDir.ASCENDING )
|
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;
|
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()
|
private static SortDir getDirection()
|
||||||
{
|
{
|
||||||
return Direction;
|
return Direction;
|
||||||
|
|||||||
Reference in New Issue
Block a user