aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common/helpers
diff options
context:
space:
mode:
authorAlkalus <Draknyte1@hotmail.com>2020-05-25 02:55:32 +0100
committerAlkalus <Draknyte1@hotmail.com>2020-05-25 02:55:32 +0100
commit6fb4b8a333e69bd591d49d9c5f251797de333c7b (patch)
treec54bb1070920660d96c71dd48d68ef7095b1aafe /src/Java/gtPlusPlus/xmod/gregtech/common/helpers
parent2b7ae2001ed8f49d2de8f88ef306426af60c279b (diff)
downloadGT5-Unofficial-6fb4b8a333e69bd591d49d9c5f251797de333c7b.tar.gz
GT5-Unofficial-6fb4b8a333e69bd591d49d9c5f251797de333c7b.tar.bz2
GT5-Unofficial-6fb4b8a333e69bd591d49d9c5f251797de333c7b.zip
+ Added the Volumetric Flask Configurator.
+ Added a recipe for the Egg Box. + Added a Book for the Chemical Plant. % Changed the Tooltip for the Egg Box. $ Fixed Robinators not returning the correct block when mined. $ Fixed Electric tool recipes not consuming the original tool. $ Redid handling of all shaped crafting recipes. $ Fixed recipe handling for the last few multiblocks. $ Potentially forgot some other minor fixes.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/helpers')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java
new file mode 100644
index 0000000000..76bb378377
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java
@@ -0,0 +1,81 @@
+package gtPlusPlus.xmod.gregtech.common.helpers;
+
+import java.lang.reflect.Method;
+
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class VolumetricFlaskHelper {
+
+ private static final Class sClassVolumetricFlask;
+ private static final Method sMethodGetFlaskMaxCapacity;
+ private static Item mFlask;
+
+ static {
+ if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) {
+ sClassVolumetricFlask = ReflectionUtils.getClass("gregtech.common.items.GT_VolumetricFlask");
+ sMethodGetFlaskMaxCapacity = ReflectionUtils.getMethod(sClassVolumetricFlask, "getMaxCapacity", new Class[] {});
+ }
+ else {
+ sClassVolumetricFlask = null;
+ sMethodGetFlaskMaxCapacity = null;
+ }
+ }
+
+ public static ItemStack getVolumetricFlask(int aAmount) {
+ ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", aAmount, (ItemStack) null);
+ return aFlask;
+ }
+
+ public static boolean isVolumetricFlask(ItemStack aStack) {
+ if (mFlask == null) {
+ ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", 1, (ItemStack) null);
+ if (aFlask != null) {
+ mFlask = aFlask.getItem();
+ }
+ }
+ if (aStack.getItem() == mFlask) {
+ return true;
+ }
+ return false;
+ }
+
+ public static int getMaxFlaskCapacity(ItemStack aStack) {
+ if (aStack != null && sMethodGetFlaskMaxCapacity != null) {
+ Item aItem = aStack.getItem();
+ if (sClassVolumetricFlask.isInstance(aItem)) {
+ int aMaxCapacity = (int) ReflectionUtils.invokeNonBool(aItem, sMethodGetFlaskMaxCapacity, new Object[] {});
+ return aMaxCapacity;
+ }
+ }
+ return 0;
+ }
+
+ public static int getFlaskCapacity(ItemStack aStack) {
+ int capacity = 1000;
+ if (aStack.hasTagCompound()) {
+ NBTTagCompound nbt = aStack.getTagCompound();
+ if (nbt.hasKey("Capacity", 3))
+ capacity = nbt.getInteger("Capacity");
+ }
+ return Math.min(getMaxFlaskCapacity(aStack), capacity);
+ }
+
+ public static boolean setNewFlaskCapacity(ItemStack aStack, int aCapacity) {
+ if (aStack == null || aCapacity <= 0) {
+ return false;
+ }
+ aCapacity = Math.min(aCapacity, getMaxFlaskCapacity(aStack));
+ NBTTagCompound nbt = aStack.getTagCompound();
+ if (nbt == null) {
+ aStack.setTagCompound(nbt = new NBTTagCompound());
+ }
+ nbt.setInteger("Capacity", aCapacity);
+ return true;
+ }
+
+}