mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-20 03:44:23 +01:00
Minor cleanup
This commit is contained in:
parent
0cb646bb56
commit
61a6a29d14
2 changed files with 14 additions and 15 deletions
|
@ -12,7 +12,7 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
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> bindings = new ArrayList<KeyBinding>();
|
||||||
private static ArrayList<KeyBinding> removed = new ArrayList<KeyBinding>();
|
private static ArrayList<KeyBinding> removed = new ArrayList<KeyBinding>();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.minelittlepony.util;
|
package com.minelittlepony.util;
|
||||||
|
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -8,50 +9,48 @@ import net.minecraft.util.DamageSource;
|
||||||
import net.minecraft.util.EntityDamageSource;
|
import net.minecraft.util.EntityDamageSource;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
import net.minecraft.util.text.translation.I18n;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class MagicalDamageSource extends EntityDamageSource {
|
public class MagicalDamageSource extends EntityDamageSource {
|
||||||
|
|
||||||
public static DamageSource create(String type) {
|
public static DamageSource create(String type) {
|
||||||
return new MagicalDamageSource(type);
|
return new MagicalDamageSource(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DamageSource causePlayerDamage(String type, EntityPlayer player) {
|
public static DamageSource causePlayerDamage(String type, EntityPlayer player) {
|
||||||
return new MagicalDamageSource(type, player);
|
return new MagicalDamageSource(type, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DamageSource causeMobDamage(String type, EntityLivingBase source) {
|
public static DamageSource causeMobDamage(String type, EntityLivingBase source) {
|
||||||
return new MagicalDamageSource(type, source);
|
return new MagicalDamageSource(type, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MagicalDamageSource(String type) {
|
protected MagicalDamageSource(String type) {
|
||||||
this(type, null);
|
this(type, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MagicalDamageSource(String type, Entity source) {
|
protected MagicalDamageSource(String type, Entity source) {
|
||||||
super(type, source);
|
super(type, source);
|
||||||
setMagicDamage();
|
setMagicDamage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITextComponent getDeathMessage(EntityLivingBase target) {
|
public ITextComponent getDeathMessage(EntityLivingBase target) {
|
||||||
Entity attacker = damageSourceEntity instanceof EntityLivingBase ? (EntityLivingBase)damageSourceEntity : target.getRidingEntity();
|
Entity attacker = damageSourceEntity instanceof EntityLivingBase ? (EntityLivingBase)damageSourceEntity : target.getRidingEntity();
|
||||||
String basic = "death.attack." + this.damageType;
|
String basic = "death.attack." + this.damageType;
|
||||||
|
|
||||||
if (attacker != null && attacker instanceof EntityLivingBase) {
|
if (attacker != null && attacker instanceof EntityLivingBase) {
|
||||||
String withAttecker = basic + ".player";
|
String withAttecker = basic + ".player";
|
||||||
ItemStack held = attacker instanceof EntityLivingBase ? ((EntityLivingBase)attacker).getHeldItemMainhand() : ItemStack.EMPTY;
|
ItemStack held = attacker instanceof EntityLivingBase ? ((EntityLivingBase)attacker).getHeldItemMainhand() : ItemStack.EMPTY;
|
||||||
|
|
||||||
String withItem = withAttecker + ".item";
|
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());
|
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(withAttecker, target.getDisplayName(), attacker.getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TextComponentTranslation(basic, target.getDisplayName());
|
return new TextComponentTranslation(basic, target.getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue