diff options
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r-- | src/main/java/gregtech/api/damagesources/GT_DamageSources.java | 19 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Utility.java | 18 |
2 files changed, 30 insertions, 7 deletions
diff --git a/src/main/java/gregtech/api/damagesources/GT_DamageSources.java b/src/main/java/gregtech/api/damagesources/GT_DamageSources.java index fd13b9cfee..45f3fd5323 100644 --- a/src/main/java/gregtech/api/damagesources/GT_DamageSources.java +++ b/src/main/java/gregtech/api/damagesources/GT_DamageSources.java @@ -1,8 +1,11 @@ package gregtech.api.damagesources; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; import net.minecraft.util.*; +import javax.annotation.Nullable; + public class GT_DamageSources { public static DamageSource getElectricDamage() { return ic2.api.info.Info.DMG_ELECTRIC; @@ -33,7 +36,7 @@ public class GT_DamageSources { } private static class DamageSourceCombat extends EntityDamageSource { - private IChatComponent mDeathMessage; + private final IChatComponent mDeathMessage; public DamageSourceCombat(String aType, EntityLivingBase aPlayer, IChatComponent aDeathMessage) { super(aType, aPlayer); @@ -70,6 +73,20 @@ public class GT_DamageSources { } } + public static class DamageSourceHotItem extends DamageSourceHeat { + @Nullable + private final ItemStack stack; + + public DamageSourceHotItem(@Nullable ItemStack cause) { + this.stack = cause; + } + + @Nullable + public ItemStack getDamagingStack() { + return stack; + } + } + public static class DamageSourceExploding extends DamageSource { public DamageSourceExploding() { super("exploded"); diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 77194a7bff..28c6b266ec 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -9,6 +9,7 @@ import com.mojang.authlib.GameProfile; import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; import gregtech.api.damagesources.GT_DamageSources; +import gregtech.api.damagesources.GT_DamageSources.DamageSourceHotItem; import gregtech.api.enchants.Enchantment_Radioactivity; import gregtech.api.enums.*; import gregtech.api.events.BlockScanningEvent; @@ -55,10 +56,7 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MathHelper; +import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.DimensionManager; @@ -1571,9 +1569,17 @@ public class GT_Utility { return isWearingFullGasHazmat(aEntity); } - public static boolean applyHeatDamage(EntityLivingBase aEntity, float aDamage) { + public static boolean applyHeatDamage(EntityLivingBase entity, float damage) { + return applyHeatDamage(entity, damage, GT_DamageSources.getHeatDamage()); + } + + public static boolean applyHeatDamageFromItem(EntityLivingBase entity, float damage, ItemStack item) { + return applyHeatDamage(entity, damage, new DamageSourceHotItem(item)); + } + + private static boolean applyHeatDamage(EntityLivingBase aEntity, float aDamage, DamageSource source) { if (aDamage > 0 && aEntity != null && aEntity.getActivePotionEffect(Potion.fireResistance) == null && !isWearingFullHeatHazmat(aEntity)) { - aEntity.attackEntityFrom(GT_DamageSources.getHeatDamage(), aDamage); + aEntity.attackEntityFrom(source, aDamage); return true; } return false; |