ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/common/misc/DamageSources.java

26 lines
963 B
Java
Raw Normal View History

2020-09-09 16:49:01 +02:00
package de.ellpeck.actuallyadditions.common.misc;
2020-09-09 16:49:01 +02:00
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
2016-03-18 23:47:22 +01:00
import net.minecraft.util.text.ITextComponent;
2016-05-27 18:54:17 +02:00
import net.minecraft.util.text.TextComponentTranslation;
2019-05-02 09:10:29 +02:00
public class DamageSources extends DamageSource {
2015-11-19 15:26:54 +01:00
public static final DamageSource DAMAGE_ATOMIC_RECONSTRUCTOR = new DamageSources("atomicReconstructor", 5).setDamageBypassesArmor();
2016-05-19 20:05:12 +02:00
private final int messageCount;
2019-05-02 09:10:29 +02:00
public DamageSources(String name, int messageCount) {
super(name);
this.messageCount = messageCount;
}
@Override
2019-05-02 09:10:29 +02:00
public ITextComponent getDeathMessage(EntityLivingBase entity) {
String locTag = "death." + ActuallyAdditions.MODID + "." + this.damageType + "." + (entity.world.rand.nextInt(this.messageCount) + 1);
return new TextComponentTranslation(locTag, entity.getName());
}
}