Search in sources :

Example 1 with EntityBookWyrm

use of lykrast.defiledlands.common.entity.passive.EntityBookWyrm in project DefiledLands by Lykrast.

the class ItemBookWyrmAnalyzer method itemInteractionForEntity.

/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity, net.minecraft.util.EnumHand hand) {
    if (entity.world.isRemote) {
        return false;
    }
    if (entity instanceof EntityBookWyrm) {
        EntityBookWyrm target = (EntityBookWyrm) entity;
        String base = "ui.defiledlands.book_wyrm_analyze.";
        player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "health")) + (int) target.getHealth() + "/" + (int) target.getMaxHealth()));
        player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "digest_time")) + target.getDigestTime()));
        player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "max_level")) + target.getMaxLevel()));
        player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "digested")) + target.digested));
        if (target.digesting > 0)
            player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "digesting")) + target.digesting + I18n.translateToLocal(String.format("%s%s", base, "levels"))));
        if (target.isChild()) {
            int minutes = (int) Math.ceil((-target.getGrowingAge()) / 1200.0D);
            player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "maturing")) + minutes + I18n.translateToLocal(String.format("%s%s", base, "minutes"))));
        } else if (target.getGrowingAge() > 0) {
            int minutes = (int) Math.ceil(target.getGrowingAge() / 1200.0D);
            player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "reproduce")) + minutes + I18n.translateToLocal(String.format("%s%s", base, "minutes"))));
        } else
            player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "ready"))));
        if (target.isGolden())
            player.sendMessage(new TextComponentString(I18n.translateToLocal(String.format("%s%s", base, "golden"))));
        return true;
    }
    return false;
}
Also used : EntityBookWyrm(lykrast.defiledlands.common.entity.passive.EntityBookWyrm) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

EntityBookWyrm (lykrast.defiledlands.common.entity.passive.EntityBookWyrm)1 TextComponentString (net.minecraft.util.text.TextComponentString)1