-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy pathDamageSources.java
67 lines (53 loc) · 2.46 KB
/
DamageSources.java
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
package gregtech.api.damagesources;
import gregtech.api.items.toolitem.IGTTool;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import org.jetbrains.annotations.Nullable;
public class DamageSources {
private static final DamageSource EXPLOSION = new DamageSource("explosion").setExplosion();
private static final DamageSource HEAT = new DamageSource("heat").setFireDamage();
private static final DamageSource FROST = new DamageSource("frost");
private static final DamageSource CHEMICAL = new DamageSource("chemical").setDamageBypassesArmor();
private static final DamageSource ELECTRIC = new DamageSource("electric");
private static final DamageSource RADIATION = new DamageSource("radiation").setDamageBypassesArmor();
private static final DamageSource TURBINE = new DamageSource("turbine");
public static DamageSource getExplodingDamage() {
return EXPLOSION;
}
public static DamageSource getHeatDamage() {
return HEAT;
}
public static DamageSource getFrostDamage() {
return FROST;
}
public static DamageSource getChemicalDamage() {
return CHEMICAL;
}
public static DamageSource getElectricDamage() {
return ELECTRIC;
}
public static DamageSource getRadioactiveDamage() {
return RADIATION;
}
public static DamageSource getTurbineDamage() {
return TURBINE;
}
public static DamageSource getPlayerDamage(@Nullable EntityPlayer source) {
ItemStack stack = source != null ? source.getHeldItemMainhand() : ItemStack.EMPTY;
if (!stack.isEmpty() && stack.getItem() instanceof IGTTool tool) {
return new DamageSourceTool("player", source, String.format("death.attack.%s", tool.getToolId()));
}
return new EntityDamageSource("player", source);
}
public static DamageSource getMobDamage(@Nullable EntityLivingBase source) {
ItemStack stack = source != null ? source.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND) : ItemStack.EMPTY;
if (!stack.isEmpty() && stack.getItem() instanceof IGTTool tool) {
return new DamageSourceTool("mob", source, String.format("death.attack.%s", tool.getToolId()));
}
return new EntityDamageSource("mob", source);
}
}