From 88124a202a65445e33697416fa6ee97ca8c024f5 Mon Sep 17 00:00:00 2001 From: Tec Date: Sat, 16 Feb 2019 10:00:48 +0100 Subject: Move to util --- src/main/java/com/github/technus/tectech/Util.java | 15 +++++++++++++-- .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 15 +-------------- .../single/GT_MetaTileEntity_TeslaCoil.java | 16 +--------------- 3 files changed, 15 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index 1fd479939c..7a5366f337 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -24,8 +24,7 @@ import org.apache.commons.lang3.StringUtils; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -39,6 +38,18 @@ public final class Util { private Util() { } + @SuppressWarnings("ComparatorMethodParameterNotUsed") + public static > SortedSet> entriesSortedByValues(Map map) { + SortedSet> sortedEntries = new TreeSet>( + (e1, e2) -> { + int res = e1.getValue().compareTo(e2.getValue()); + return res != 0 ? res : 1; // Special fix to preserve items with equal values + } + ); + sortedEntries.addAll(map.entrySet()); + return sortedEntries; + } + public static String intBitsToString(int number) { StringBuilder result = new StringBuilder(16); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 926c5e5d30..eca3dde6cb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -25,6 +25,7 @@ import java.util.*; import static com.github.technus.tectech.CommonValues.V; import static com.github.technus.tectech.Util.StructureBuilder; +import static com.github.technus.tectech.Util.entriesSortedByValues; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static gregtech.api.GregTech_API.*; @@ -78,20 +79,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private long outputCurrentParam = 0; private int scanTimeMinParam = 0; - static > SortedSet> entriesSortedByValues(Map map) { - SortedSet> sortedEntries = new TreeSet>( - new Comparator>() { - @Override - public int compare(Map.Entry e1, Map.Entry e2) { - int res = e1.getValue().compareTo(e2.getValue()); - return res != 0 ? res : 1; // Special fix to preserve items with equal values - } - } - ); - sortedEntries.addAll(map.entrySet()); - return sortedEntries; - } - //region structure private static final String[][] shape0 = new String[][]{//3 16 0 {"\u000F", "A . ",}, diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java index 906ce556f7..c556ca2ef6 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack; import java.util.*; +import static com.github.technus.tectech.Util.entriesSortedByValues; import static java.lang.Math.round; @@ -41,25 +42,10 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB private int transferRadiusTower = 32; //Radius for transceiver to tower transfers private int transferRadiusCover = 16; //Radius for transceiver to cover transfers - private long outputVoltage = 512; //Tesla Voltage Output private long outputCurrent = 1; //Tesla Current Output private long outputEuT = outputVoltage * outputCurrent; //Tesla Power Output - static > SortedSet> entriesSortedByValues(Map map) { - SortedSet> sortedEntries = new TreeSet>( - new Comparator>() { - @Override - public int compare(Map.Entry e1, Map.Entry e2) { - int res = e1.getValue().compareTo(e2.getValue()); - return res != 0 ? res : 1; // Special fix to preserve items with equal values - } - } - ); - sortedEntries.addAll(map.entrySet()); - return sortedEntries; - } - public GT_MetaTileEntity_TeslaCoil(int aID, String aName, String aNameRegional, int aTier, int aSlotCount) { super(aID, aName, aNameRegional, aTier, "Tesla Coil Transceiver", aSlotCount); -- cgit