diff options
author | Martin Robertz <dream-master@gmx.net> | 2021-12-02 16:53:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-02 16:53:40 +0100 |
commit | c0a6800447fdb87e266acfb47f35b5f765c74fe3 (patch) | |
tree | 2066554d22848e6818689d41cd4ca7f683ebebb7 /src/main/java/gregtech/api/util/GT_Utility.java | |
parent | 03b6fb248b1a20b9ccce7ac4da4c1a76875fa966 (diff) | |
download | GT5-Unofficial-c0a6800447fdb87e266acfb47f35b5f765c74fe3.tar.gz GT5-Unofficial-c0a6800447fdb87e266acfb47f35b5f765c74fe3.tar.bz2 GT5-Unofficial-c0a6800447fdb87e266acfb47f35b5f765c74fe3.zip |
add select circuit gui for machine and circuits itself (#773)
also fixed some issue with basic machine gui introduced in 9d42b299def1c41bbc7a1f01efe445be28f54399
also retrofitted volumetric flask to use the new INetworkUpdatableItem and GT_Packet_UpdateItem, deprecating MessageSetFlaskCapacity in the meanwhile.
To open the gui for machine, shift-left-click the circuit slot
To open the gui for circuit, click any block (need to be sneaking if it's chest, furnace, etc) with the circuit held in hand.
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
Co-authored-by: Glease <4586901+Glease@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_Utility.java')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Utility.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index a07868ec68..3b0ec94a92 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -3,6 +3,7 @@ package gregtech.api.util; import cofh.api.transport.IItemDuct; import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; import com.google.common.collect.Maps; import com.gtnewhorizon.structurelib.alignment.IAlignment; import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; @@ -104,7 +105,16 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.text.NumberFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Optional; @@ -2425,7 +2435,18 @@ public class GT_Utility { return false; } - public static class ItemNBT { + public static int findMatchingStackInList(List<ItemStack> aStacks, ItemStack aStack) { + if (isStackInvalid(aStack)) + return -1; + for (int i = 0, aStacksSize = aStacks.size(); i < aStacksSize; i++) { + ItemStack tStack = aStacks.get(i); + if (areStacksEqual(aStack, tStack)) + return i; + } + return -1; + } + + public static class ItemNBT { public static void setNBT(ItemStack aStack, NBTTagCompound aNBT) { if (aNBT == null) { aStack.setTagCompound(null); @@ -2989,4 +3010,8 @@ public class GT_Utility { public static long getNonnullElementCount(Object[] tArray) { return Arrays.stream(tArray).filter(Objects::nonNull).count(); } + + public static int clamp(int val, int lo, int hi) { + return val > hi ? hi : val < lo ? lo : val; + } } |