aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/damagesources/GT_DamageSources.java
blob: d83bf661fe7837d9fe8cf1d29f8829d36978e2c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package gregtech.api.damagesources;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.*;

public class GT_DamageSources {
	public static DamageSource getElectricDamage() {
		return ic2.api.info.Info.DMG_ELECTRIC;
	}
	
	public static DamageSource getRadioactiveDamage() {
		return ic2.api.info.Info.DMG_RADIATION;
	}
	
	public static DamageSource getNukeExplosionDamage() {
		return ic2.api.info.Info.DMG_NUKE_EXPLOSION;
	}
	
	public static DamageSource getExplodingDamage() {
		return new DamageSourceExploding();
	}
	
	public static DamageSource getCombatDamage(String aType, EntityLivingBase aPlayer, IChatComponent aDeathMessage) {
		return new DamageSourceCombat(aType, aPlayer, aDeathMessage);
	}
	
	public static DamageSource getHeatDamage() {
		return new DamageSourceHeat();
	}
	
	public static DamageSource getFrostDamage() {
		return new DamageSourceFrost();
	}
	
	private static class DamageSourceCombat extends EntityDamageSource {
		private IChatComponent mDeathMessage;
		
		public DamageSourceCombat(String aType, EntityLivingBase aPlayer, IChatComponent aDeathMessage) {
			super(aType, aPlayer);
			mDeathMessage = aDeathMessage;
		}
		
		@Override
	    public IChatComponent func_151519_b(EntityLivingBase aTarget) {
			return mDeathMessage == null ? super.func_151519_b(aTarget) : mDeathMessage;
	    }
	}
	
	private static class DamageSourceFrost extends DamageSource {
		public DamageSourceFrost() {
			super("frost");
			setDifficultyScaled();
		}
		
		@Override
	    public IChatComponent func_151519_b(EntityLivingBase aTarget) {
			return new ChatComponentText(EnumChatFormatting.RED+aTarget.getCommandSenderName()+EnumChatFormatting.WHITE + " got frozen");
	    }
	}
	
	private static class DamageSourceHeat extends DamageSource {
		public DamageSourceHeat() {
			super("steam");
			setDifficultyScaled();
		}
		
		@Override
	    public IChatComponent func_151519_b(EntityLivingBase aTarget) {
			return new ChatComponentText(EnumChatFormatting.RED+aTarget.getCommandSenderName()+EnumChatFormatting.WHITE + " was boiled alive");
	    }
	}
	
	public static class DamageSourceExploding extends DamageSource {
		public DamageSourceExploding() {
			super("exploded");
			setDamageAllowedInCreativeMode();
			setDamageBypassesArmor();
			setDamageIsAbsolute();
		}
		
		@Override
	    public IChatComponent func_151519_b(EntityLivingBase aTarget) {
			return new ChatComponentText(EnumChatFormatting.RED+aTarget.getCommandSenderName()+EnumChatFormatting.WHITE + " exploded");
	    }
	}
}