Minor cleanup

This commit is contained in:
Sollace 2018-09-19 09:09:43 +02:00
parent 0cb646bb56
commit 61a6a29d14
2 changed files with 14 additions and 15 deletions

View file

@ -12,7 +12,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.fml.client.registry.ClientRegistry;
public class UKeyHandler implements IKeyHandler {
class UKeyHandler implements IKeyHandler {
private static ArrayList<KeyBinding> bindings = new ArrayList<KeyBinding>();
private static ArrayList<KeyBinding> removed = new ArrayList<KeyBinding>();

View file

@ -1,5 +1,6 @@
package com.minelittlepony.util;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@ -8,50 +9,48 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.translation.I18n;
@SuppressWarnings("deprecation")
public class MagicalDamageSource extends EntityDamageSource {
public static DamageSource create(String type) {
return new MagicalDamageSource(type);
}
public static DamageSource causePlayerDamage(String type, EntityPlayer player) {
return new MagicalDamageSource(type, player);
}
public static DamageSource causeMobDamage(String type, EntityLivingBase source) {
return new MagicalDamageSource(type, source);
}
protected MagicalDamageSource(String type) {
this(type, null);
}
protected MagicalDamageSource(String type, Entity source) {
super(type, source);
setMagicDamage();
}
public ITextComponent getDeathMessage(EntityLivingBase target) {
Entity attacker = damageSourceEntity instanceof EntityLivingBase ? (EntityLivingBase)damageSourceEntity : target.getRidingEntity();
String basic = "death.attack." + this.damageType;
if (attacker != null && attacker instanceof EntityLivingBase) {
String withAttecker = basic + ".player";
ItemStack held = attacker instanceof EntityLivingBase ? ((EntityLivingBase)attacker).getHeldItemMainhand() : ItemStack.EMPTY;
String withItem = withAttecker + ".item";
if (held != null && held.hasDisplayName() && I18n.canTranslate(withItem)) {
if (held != null && held.hasDisplayName() && I18n.hasKey(withItem)) {
return new TextComponentTranslation(withItem, target.getDisplayName(), attacker.getDisplayName(), held.getTextComponent());
}
if (I18n.canTranslate(withAttecker)) {
if (I18n.hasKey(withAttecker)) {
return new TextComponentTranslation(withAttecker, target.getDisplayName(), attacker.getDisplayName());
}
}
return new TextComponentTranslation(basic, target.getDisplayName());
}
}