aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core
diff options
context:
space:
mode:
authorAlkalus <Draknyte1@hotmail.com>2020-05-30 21:31:52 +0100
committerAlkalus <Draknyte1@hotmail.com>2020-05-30 21:31:52 +0100
commit4ded21b4e901630a72fe2ccf7fd8dff56e744bb7 (patch)
tree99a8351468e1bf62fa8ee32f159b5c446c1c670a /src/Java/gtPlusPlus/core
parent664c388b944e87125a9305fbbdda6a374854e0b5 (diff)
downloadGT5-Unofficial-4ded21b4e901630a72fe2ccf7fd8dff56e744bb7.tar.gz
GT5-Unofficial-4ded21b4e901630a72fe2ccf7fd8dff56e744bb7.tar.bz2
GT5-Unofficial-4ded21b4e901630a72fe2ccf7fd8dff56e744bb7.zip
$ Fixed minor oversight in RC ASM.
$ Fixed bug where PSS would generate power due to an integer overflow.
Diffstat (limited to 'src/Java/gtPlusPlus/core')
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/NBTUtils.java102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/NBTUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/NBTUtils.java
index b0623d429d..7ed4d887cc 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/NBTUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/NBTUtils.java
@@ -2,6 +2,7 @@ package gtPlusPlus.core.util.minecraft;
import static gtPlusPlus.core.item.ModItems.ZZZ_Empty;
+import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.Entity;
@@ -413,6 +414,107 @@ public class NBTUtils {
return false;
}
+ public static Map getTagMap(NBTTagCompound aNBT) {
+ Map tagMap = new HashMap();
+ if (!aNBT.hasNoTags()) {
+ Map<?, ?> mInternalMap = ReflectionUtils.getField(aNBT, "tagMap");
+ if (mInternalMap != null && !mInternalMap.isEmpty()) {
+ tagMap.putAll(mInternalMap);
+ }
+ }
+ return tagMap;
+ }
+
+ public static boolean isTagString(NBTTagCompound aNBT, String aTagName) {
+ Map<?, ?> aTagMap = getTagMap(aNBT);
+ if (aTagMap != null && !aTagMap.isEmpty()) {
+ for (Map.Entry<?, ?> e : aTagMap.entrySet()) {
+ if (e.getKey().equals(aTagName)) {
+ Object aValue = e.getValue();
+ if (aValue instanceof String) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isTagInteger(NBTTagCompound aNBT, String aTagName) {
+ Map<?, ?> aTagMap = getTagMap(aNBT);
+ if (aTagMap != null && !aTagMap.isEmpty()) {
+ for (Map.Entry<?, ?> e : aTagMap.entrySet()) {
+ if (e.getKey().equals(aTagName)) {
+ Object aValue = e.getValue();
+ if (int.class.isInstance(aValue) || aValue instanceof Integer) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isTagLong(NBTTagCompound aNBT, String aTagName) {
+ Map<?, ?> aTagMap = getTagMap(aNBT);
+ if (aTagMap != null && !aTagMap.isEmpty()) {
+ for (Map.Entry<?, ?> e : aTagMap.entrySet()) {
+ if (e.getKey().equals(aTagName)) {
+ Object aValue = e.getValue();
+ if (long.class.isInstance(aValue) || aValue instanceof Long) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isTagFloat(NBTTagCompound aNBT, String aTagName) {
+ Map<?, ?> aTagMap = getTagMap(aNBT);
+ if (aTagMap != null && !aTagMap.isEmpty()) {
+ for (Map.Entry<?, ?> e : aTagMap.entrySet()) {
+ if (e.getKey().equals(aTagName)) {
+ Object aValue = e.getValue();
+ if (float.class.isInstance(aValue) || aValue instanceof Float) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isTagDouble(NBTTagCompound aNBT, String aTagName) {
+ Map<?, ?> aTagMap = getTagMap(aNBT);
+ if (aTagMap != null && !aTagMap.isEmpty()) {
+ for (Map.Entry<?, ?> e : aTagMap.entrySet()) {
+ if (e.getKey().equals(aTagName)) {
+ Object aValue = e.getValue();
+ if (double.class.isInstance(aValue) || aValue instanceof Double) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isTagBoolean(NBTTagCompound aNBT, String aTagName) {
+ Map<?, ?> aTagMap = getTagMap(aNBT);
+ if (aTagMap != null && !aTagMap.isEmpty()) {
+ for (Map.Entry<?, ?> e : aTagMap.entrySet()) {
+ if (e.getKey().equals(aTagName)) {
+ Object aValue = e.getValue();
+ if (boolean.class.isInstance(aValue) || aValue instanceof Boolean) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
public static boolean tryCloneTagCompoundDataIntoSubTag(ItemStack aStack, NBTTagCompound aTagCompound) {
try {
NBTTagCompound aNBT = aTagCompound;