aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
authorDavid Lindström <info@davidlindstrom.se>2023-01-20 09:27:42 +0100
committerGitHub <noreply@github.com>2023-01-20 09:27:42 +0100
commit750a4070af4756e3708e2b2555b9874864bf3cfb (patch)
tree29f029934a68871d7dd35592a1b952af995bf10e /src/main/java/gregtech/api/util
parentc7f1646f4b473359d270d55e4dc54cb1f4e7a64b (diff)
downloadGT5-Unofficial-750a4070af4756e3708e2b2555b9874864bf3cfb.tar.gz
GT5-Unofficial-750a4070af4756e3708e2b2555b9874864bf3cfb.tar.bz2
GT5-Unofficial-750a4070af4756e3708e2b2555b9874864bf3cfb.zip
Add Hazmat enchant to add Full Hazmat protection to an arbitrary armor item (#1663)
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java67
1 files changed, 55 insertions, 12 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index 38e3ef0d8b..cfa261c321 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -24,6 +24,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.damagesources.GT_DamageSources;
import gregtech.api.damagesources.GT_DamageSources.DamageSourceHotItem;
+import gregtech.api.enchants.Enchantment_Hazmat;
import gregtech.api.enchants.Enchantment_Radioactivity;
import gregtech.api.enums.*;
import gregtech.api.events.BlockScanningEvent;
@@ -2654,41 +2655,83 @@ public class GT_Utility {
}
public static boolean isWearingFullFrostHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sFrostHazmatList)) return false;
+ for (byte i = 1; i < 5; i++) {
+ ItemStack tStack = aEntity.getEquipmentInSlot(i);
+
+ if (!isStackInList(tStack, GregTech_API.sFrostHazmatList) && !hasHazmatEnchant(tStack)) {
+ return false;
+ }
+ }
return true;
}
public static boolean isWearingFullHeatHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sHeatHazmatList)) return false;
+ for (byte i = 1; i < 5; i++) {
+ ItemStack tStack = aEntity.getEquipmentInSlot(i);
+
+ if (!isStackInList(tStack, GregTech_API.sHeatHazmatList) && !hasHazmatEnchant(tStack)) {
+ return false;
+ }
+ }
+
return true;
}
public static boolean isWearingFullBioHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sBioHazmatList)) return false;
+ for (byte i = 1; i < 5; i++) {
+ ItemStack tStack = aEntity.getEquipmentInSlot(i);
+
+ if (!isStackInList(tStack, GregTech_API.sBioHazmatList) && !hasHazmatEnchant(tStack)) {
+ return false;
+ }
+ }
return true;
}
public static boolean isWearingFullRadioHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sRadioHazmatList)) return false;
+ for (byte i = 1; i < 5; i++) {
+ ItemStack tStack = aEntity.getEquipmentInSlot(i);
+
+ if (!isStackInList(tStack, GregTech_API.sRadioHazmatList) && !hasHazmatEnchant(tStack)) {
+ return false;
+ }
+ }
return true;
}
public static boolean isWearingFullElectroHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sElectroHazmatList)) return false;
+ for (byte i = 1; i < 5; i++) {
+ ItemStack tStack = aEntity.getEquipmentInSlot(i);
+
+ if (!isStackInList(tStack, GregTech_API.sElectroHazmatList) && !hasHazmatEnchant(tStack)) {
+ return false;
+ }
+ }
return true;
}
public static boolean isWearingFullGasHazmat(EntityLivingBase aEntity) {
- for (byte i = 1; i < 5; i++)
- if (!isStackInList(aEntity.getEquipmentInSlot(i), GregTech_API.sGasHazmatList)) return false;
+ for (byte i = 1; i < 5; i++) {
+ ItemStack tStack = aEntity.getEquipmentInSlot(i);
+
+ if (!isStackInList(tStack, GregTech_API.sGasHazmatList) && !hasHazmatEnchant(tStack)) {
+ return false;
+ }
+ }
return true;
}
+ public static boolean hasHazmatEnchant(ItemStack aStack) {
+ if (aStack == null) return false;
+ Map<Integer, Integer> tEnchantments = EnchantmentHelper.getEnchantments(aStack);
+ Integer tLevel = tEnchantments.get(Enchantment_Hazmat.INSTANCE.effectId);
+
+ if (tLevel != null && tLevel.intValue() >= 1) {
+ return true;
+ }
+ return false;
+ }
+
public static float getHeatDamageFromItem(ItemStack aStack) {
ItemData tData = GT_OreDictUnificator.getItemData(aStack);
return tData == null