Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Исходник Mops client src exp 3.1 base

зачем сливать эти калловые массы на 3.1
1776801791483.png
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
/del
 
Скажите кодеру что он лучший кодер и точно не юзает чат лгбт и точно не еблан и точно умеет писать код и что таргетхуд очень крутой и это все не баг а фича
 
кодер выпустил upd с новой килкой, вот вам ее код

spooky aura:
Expand Collapse Copy
package im.expensive.functions.impl.combat;

import com.google.common.eventbus.Subscribe;
import im.expensive.Expensive;
import im.expensive.command.friends.FriendStorage;
import im.expensive.events.EventInput;
import im.expensive.events.EventMotion;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.api.Setting;
import im.expensive.functions.api.impl.BooleanSetting;
import im.expensive.functions.api.impl.ModeListSetting;
import im.expensive.functions.api.impl.ModeSetting;
import im.expensive.functions.api.impl.SliderSetting;
import im.expensive.utils.math.SensUtils;
import im.expensive.utils.math.StopWatch;
import im.expensive.utils.player.InventoryUtil;
import im.expensive.utils.player.MoveUtils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.IPacket;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.ITag;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

@FunctionRegister(name = "KillAura", type = Category.Combat)
public class KillAura extends Function {
  private final ModeSetting type = new ModeSetting(", ", new String[] { ", ", ", "new" });
 
  public ModeSetting getType() {
    return this.type;
  }
 
  private final SliderSetting attackRange = new SliderSetting(", 3.0F, 3.0F, 6.0F, 0.1F);
 
  private final SliderSetting rotationSpeed = new SliderSetting(", 8.0F, 0.5F, 50.0F, 0.5F);
 
  private final SliderSetting critDelayRandomization = new SliderSetting(", 50.0F, 0.0F, 100.0F, 1.0F);
 
  private final BooleanSetting shieldBreak = new BooleanSetting(", Boolean.valueOf(false));
 
  final ModeListSetting targets = new ModeListSetting(", new BooleanSetting[] { new BooleanSetting(",
          Boolean.valueOf(true)), new BooleanSetting(",
          Boolean.valueOf(true)), new BooleanSetting(",
          Boolean.valueOf(false)), new BooleanSetting(",
          Boolean.valueOf(false)), new BooleanSetting(",
          Boolean.valueOf(false)), new BooleanSetting(",
          Boolean.valueOf(true)), new BooleanSetting(",
          Boolean.valueOf(true)) });
 
  final ModeListSetting options = new ModeListSetting(", new BooleanSetting[] { new BooleanSetting(",
          
          Boolean.valueOf(true)), new BooleanSetting(",
          Boolean.valueOf(true)), new BooleanSetting(",
          Boolean.valueOf(true)), new BooleanSetting(",
          Boolean.valueOf(false)), new BooleanSetting(",
          Boolean.valueOf(false)), new BooleanSetting(",
          Boolean.valueOf(true)), new BooleanSetting(",
          Boolean.valueOf(true)) });
 
  public ModeListSetting getOptions() {
    return this.options;
  }
 
  final ModeSetting correctionType = new ModeSetting(", ", new String[] { ", "});
 
  private final StopWatch stopWatch = new StopWatch();
 
  public StopWatch getStopWatch() {
    return this.stopWatch;
  }
 
  private final StopWatch spookyWatch = new StopWatch();
 
  private final StopWatch critDelayWatch = new StopWatch();
 
  private Vector2f rotateVector = new Vector2f(0.0F, 0.0F);
 
  private LivingEntity target;
 
  private Entity selected;
 
  public LivingEntity getTarget() {
    return this.target;
  }
 
  int ticks = 0;
 
  boolean isRotated;
 
  final AutoPotion autoPotion;
 
  private final Random random = new Random();
 
  private float randomYawOffset = 0.0F;
 
  private float randomPitchOffset = 0.0F;
 
  private long lastRandomUpdate = 0L;
 
  private int spookyOffsetMs = 0;
 
  private final List<Integer> lastDelays = new ArrayList<>();
 
  private int lastCritDelay = 0;
 
  private boolean isWaitingForCrit = false;
 
  private float smoothHeadYaw = 0.0F;
 
  private float smoothHeadPitch = 0.0F;
 
  float lastYaw;
 
  float lastPitch;
 
  public KillAura(AutoPotion autoPotion) {
    this.autoPotion = autoPotion;
    addSettings(new Setting[] { (Setting)this.type, (Setting)this.attackRange, (Setting)this.rotationSpeed, (Setting)this.critDelayRandomization, (Setting)this.targets, (Setting)this.options, (Setting)this.correctionType });
  }
 
  private float randomLerp(float min, float max) {
    return min + this.random.nextFloat() * (max - min);
  }
 
  private float lerp(float a, float b, float t) {
    return a + (b - a) * t;
  }
 
  private int generateRandomCritDelay() {
    float percent = this.type.is("new") ? 10.0F : ((Float)this.critDelayRandomization.get()).floatValue();
    if (percent <= 0.01F)
      return 0;
    int maxDelay = (int)(500.0F * percent / 100.0F);
    if (maxDelay < 1)
      maxDelay = 1;
    int newDelay = this.random.nextInt(maxDelay + 1);
    if (this.lastDelays.size() >= 2) {
      int last1 = ((Integer)this.lastDelays.get(this.lastDelays.size() - 1)).intValue();
      int last2 = ((Integer)this.lastDelays.get(this.lastDelays.size() - 2)).intValue();
      if (newDelay == last1 || newDelay == last2)
        for (int attempt = 0; attempt < 20; attempt++) {
          int alternativeDelay = this.random.nextInt(maxDelay + 1);
          if (alternativeDelay != last1 && alternativeDelay != last2) {
            newDelay = alternativeDelay;
            break;
          }
        } 
    } else if (this.lastDelays.size() >= 1) {
      int last1 = ((Integer)this.lastDelays.get(this.lastDelays.size() - 1)).intValue();
      if (newDelay == last1) {
        newDelay = this.random.nextInt(maxDelay + 1);
        if (newDelay == last1 && maxDelay > 0)
          newDelay = (newDelay + 1) % (maxDelay + 1);
      }
    }
    this.lastDelays.add(Integer.valueOf(newDelay));
    while (this.lastDelays.size() > 2)
      this.lastDelays.remove(0);
    this.lastCritDelay = newDelay;
    return newDelay;
  }
 
  @Subscribe
  public void onInput(EventInput eventInput) {
    if (((Boolean)this.options.getValueByName(").get()).booleanValue() && this.correctionType
      .is(") && this.target != null && mc.player != null)
      MoveUtils.fixMovement(eventInput, this.rotateVector.x);
  }
 
  @Subscribe
  public void onUpdate(EventUpdate e) {
    if ((((Boolean)this.options.getValueByName(").get()).booleanValue() && (this.target == null || !isValid(this.target))) ||
      !((Boolean)this.options.getValueByName(").get()).booleanValue())
      updateTarget();
    if (this.target != null && (!this.autoPotion.isState() || !this.autoPotion.isActive())) {
      this.isRotated = false;
      if (this.type.is(") || this.type.is("new")) {
        if (System.currentTimeMillis() - this.lastRandomUpdate > 100L) {
          this.randomYawOffset = randomLerp(-1.5F, 1.5F);
          this.randomPitchOffset = randomLerp(-1.0F, 1.0F);
          this.lastRandomUpdate = System.currentTimeMillis();
        }
        if (!this.isRotated)
          updateRotation(false, 80.0F, 35.0F);
        this.smoothHeadYaw = lerp(this.smoothHeadYaw, this.rotateVector.x, 0.15F);
        this.smoothHeadPitch = lerp(this.smoothHeadPitch, this.rotateVector.y, 0.15F);
        float attackStrength = mc.player.getCooledAttackStrength(
            ((Boolean)this.options.getValueByName(").get()).booleanValue() ?
            Expensive.getInstance().getTpsCalc().getAdjustTicks() : 1.5F);
        boolean critOk = (!((Boolean)this.options.getValueByName(").get()).booleanValue() || isCritCondition());
        if (attackStrength >= 0.92F && critOk) {
          if (!this.isWaitingForCrit) {
            int delay = generateRandomCritDelay();
            if (delay <= 0) {
              updateAttackSpooky();
            } else {
              this.isWaitingForCrit = true;
              this.critDelayWatch.setLastMS(delay);
            }
          } else if (this.critDelayWatch.hasTimeElapsed()) {
            updateAttackSpooky();
            this.isWaitingForCrit = false;
          }
        } else {
          this.isWaitingForCrit = false;
        }
      } else {
        if (shouldPlayerFalling() && this.stopWatch.hasTimeElapsed()) {
          updateAttack();
          this.ticks = 2;
        }
        if (this.type.is(")) {
          if (this.ticks > 0) {
            updateRotation(true, 180.0F, 90.0F);
            this.ticks--;
          } else {
            reset();
          }
        } else if (!this.isRotated) {
          updateRotation(false, 80.0F, 35.0F);
        }
      }
    } else {
      this.stopWatch.setLastMS(0L);
      this.spookyWatch.setLastMS(0L);
      this.critDelayWatch.setLastMS(0L);
      this.isWaitingForCrit = false;
      reset();
    }
  }
 
  @Subscribe
  private void onWalking(EventMotion e) {
    if (this.target == null || (this.autoPotion.isState() && this.autoPotion.isActive()))
      return;
    float yaw = this.rotateVector.x;
    float pitch = this.rotateVector.y;
    e.setYaw(yaw);
    e.setPitch(pitch);
    if (this.type.is(") || this.type.is("new")) {
      mc.player.rotationYawHead = this.smoothHeadYaw;
      mc.player.renderYawOffset = this.smoothHeadYaw;
      mc.player.rotationPitchHead = this.smoothHeadPitch;
    } else {
      mc.player.rotationYawHead = yaw;
      mc.player.renderYawOffset = yaw;
      mc.player.rotationPitchHead = pitch;
    }
  }
 
  private void updateTarget() {
    List<LivingEntity> targets = new ArrayList<>();
    for (Entity entity : mc.world.getAllEntities()) {
      if (entity instanceof LivingEntity) {
        LivingEntity living = (LivingEntity)entity;
        if (isValid(living))
          targets.add(living);
      }
    }
    if (targets.isEmpty()) {
      this.target = null;
      return;
    }
    if (targets.size() == 1) {
      this.target = targets.get(0);
      return;
    }
    targets.sort(Comparator.<LivingEntity>comparingDouble(object -> {
            if (object instanceof PlayerEntity) {
              PlayerEntity player = (PlayerEntity)object;
              return -getEntityArmor(player);
            }
            if (object instanceof LivingEntity) {
              LivingEntity base = (LivingEntity)object;
              return -base.getTotalArmorValue();
            }
            return 0.0D;
          }).thenComparing((object, object2) -> {
            double d2 = getEntityHealth((LivingEntity)object);
            double d3 = getEntityHealth((LivingEntity)object2);
            return Double.compare(d2, d3);
          }).thenComparing((object, object2) -> {
            double d2 = mc.player.getDistance((Entity)object);
            double d3 = mc.player.getDistance((Entity)object2);
            return Double.compare(d2, d3);
          }));
    this.target = targets.get(0);
  }
 
  private void updateRotation(boolean attack, float rotationYawSpeed, float rotationPitchSpeed) {
    float clampedYaw, maxYawStep, yaw, clampedPitch, maxPitchStep, pitch, f1, gcd, f2, f3;
    double heightOffset = (this.type.is(") || this.type.is("new")) ? (this.target.getHeight() * 0.9D) : (this.target.getHeight() * mc.player.getDistanceEyePos(this.target) / ((Float)this.attackRange.get()).floatValue());
    Vector3d vec = (this.type.is(") || this.type.is("new")) ? this.target.getPositionVec().add(0.0D, heightOffset, 0.0D).subtract(mc.player.getEyePosition(1.0F)) : this.target.getPositionVec().add(0.0D, MathHelper.clamp(mc.player.getPosYEye() - this.target.getPosY(), 0.0D, heightOffset), 0.0D).subtract(mc.player.getEyePosition(1.0F));
    this.isRotated = true;
    float yawToTarget = (float)MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(vec.z, vec.x)) - 90.0D);
    float pitchToTarget = (float)-Math.toDegrees(Math.atan2(vec.y, Math.hypot(vec.x, vec.z)));
    if (this.type.is(") || this.type.is("new")) {
      yawToTarget += this.randomYawOffset;
      pitchToTarget += this.randomPitchOffset;
    }
    float yawDelta = MathHelper.wrapDegrees(yawToTarget - this.rotateVector.x);
    float pitchDelta = MathHelper.wrapDegrees(pitchToTarget - this.rotateVector.y);
    int roundedYaw = (int)yawDelta;
    float speed = this.type.is("new") ? 48.0F : ((Float)this.rotationSpeed.get()).floatValue();
    if (speed < 0.5F)
      speed = 0.5F;
    switch ((String)this.type.get()) {
      case ":
        clampedYaw = Math.min(Math.max(Math.abs(yawDelta), 1.0F), speed);
        clampedPitch = Math.min(Math.max(Math.abs(pitchDelta), 1.0F), rotationPitchSpeed);
        if (attack && this.selected != this.target && ((Boolean)this.options.getValueByName(").get()).booleanValue()) {
          clampedPitch = Math.max(Math.abs(pitchDelta), 1.0F);
        } else {
          clampedPitch /= 3.0F;
        }
        if (Math.abs(clampedYaw - this.lastYaw) <= 3.0F)
          clampedYaw = this.lastYaw + 3.1F;
        f1 = this.rotateVector.x + ((yawDelta > 0.0F) ? clampedYaw : -clampedYaw);
        f2 = MathHelper.clamp(this.rotateVector.y + ((pitchDelta > 0.0F) ? clampedPitch : -clampedPitch), -89.0F, 89.0F);
        f3 = SensUtils.getGCDValue();
        f1 -= (f1 - this.rotateVector.x) % f3;
        f2 -= (f2 - this.rotateVector.y) % f3;
        this.rotateVector = new Vector2f(f1, f2);
        this.lastYaw = clampedYaw;
        this.lastPitch = clampedPitch;
        if (((Boolean)this.options.getValueByName(").get()).booleanValue())
          mc.player.rotationYawOffset = f1;
        break;
      case ":
      case "new":
        maxYawStep = Math.min(Math.abs(yawDelta), speed);
        maxPitchStep = Math.min(Math.abs(pitchDelta), rotationPitchSpeed / 3.0F);
        maxYawStep = Math.min(maxYawStep, speed);
        maxPitchStep = Math.min(maxPitchStep, speed / 2.0F);
        f1 = this.rotateVector.x + ((yawDelta > 0.0F) ? maxYawStep : -maxYawStep);
        f2 = MathHelper.clamp(this.rotateVector.y + ((pitchDelta > 0.0F) ? maxPitchStep : -maxPitchStep), -89.0F, 89.0F);
        f3 = SensUtils.getGCDValue();
        f1 -= (f1 - this.rotateVector.x) % f3;
        f2 -= (f2 - this.rotateVector.y) % f3;
        this.rotateVector = new Vector2f(f1, f2);
        this.lastYaw = maxYawStep;
        this.lastPitch = maxPitchStep;
        if (((Boolean)this.options.getValueByName(").get()).booleanValue())
          mc.player.rotationYawOffset = f1;
        break;
      case ":
        yaw = this.rotateVector.x + roundedYaw;
        pitch = MathHelper.clamp(this.rotateVector.y + pitchDelta, -90.0F, 90.0F);
        gcd = SensUtils.getGCDValue();
        yaw -= (yaw - this.rotateVector.x) % gcd;
        pitch -= (pitch - this.rotateVector.y) % gcd;
        this.rotateVector = new Vector2f(yaw, pitch);
        if (((Boolean)this.options.getValueByName(").get()).booleanValue())
          mc.player.rotationYawOffset = yaw;
        break;
    }
  }
 
  private boolean isCritCondition() {
    boolean cancelReason = ((mc.player.isInWater() && mc.player.areEyesInFluid((ITag)FluidTags.WATER)) || mc.player.isInLava() || mc.player.isOnLadder() || mc.player.isPassenger() || mc.player.abilities.isFlying);
    return (!cancelReason && !mc.player.isOnGround() && mc.player.fallDistance > 0.0F);
  }
 
  private void updateAttack() {
    if (this.target == null)
      return;
    if (mc.player.getDistance((Entity)this.target) > ((Float)this.attackRange.get()).floatValue())
      return;
    if (((Boolean)this.options.getValueByName(").get()).booleanValue())
      updateRotation(true, 60.0F, 35.0F);
    if (mc.player.isBlocking() && ((Boolean)this.options.getValueByName(").get()).booleanValue())
      mc.playerController.onStoppedUsingItem((PlayerEntity)mc.player);
    this.stopWatch.setLastMS(500L);
    mc.playerController.attackEntity((PlayerEntity)mc.player, (Entity)this.target);
    mc.player.swingArm(Hand.MAIN_HAND);
    LivingEntity livingEntity = this.target;
    if (livingEntity instanceof PlayerEntity) {
      PlayerEntity player = (PlayerEntity)livingEntity;
      if (((Boolean)this.options.getValueByName(").get()).booleanValue())
        breakShieldPlayer(player);
    }
  }
 
  private void updateAttackSpooky() {
    if (this.target == null)
      return;
    if (mc.player.getDistance((Entity)this.target) > ((Float)this.attackRange.get()).floatValue())
      return;
    if (((Boolean)this.options.getValueByName(").get()).booleanValue())
      updateRotation(true, 60.0F, 35.0F);
    if (mc.player.isBlocking() && ((Boolean)this.options.getValueByName(").get()).booleanValue())
      mc.playerController.onStoppedUsingItem((PlayerEntity)mc.player);
    this.spookyWatch.setLastMS(500L);
    mc.playerController.attackEntity((PlayerEntity)mc.player, (Entity)this.target);
    mc.player.swingArm(Hand.MAIN_HAND);
    LivingEntity livingEntity = this.target;
    if (livingEntity instanceof PlayerEntity) {
      PlayerEntity player = (PlayerEntity)livingEntity;
      if (((Boolean)this.options.getValueByName(").get()).booleanValue())
        breakShieldPlayer(player);
    }
  }
 
  private boolean shouldPlayerFalling() {
    boolean cancelReason = ((mc.player.isInWater() && mc.player.areEyesInFluid((ITag)FluidTags.WATER)) || mc.player.isInLava() || mc.player.isOnLadder() || mc.player.isPassenger() || mc.player.abilities.isFlying);
    float attackStrength = mc.player.getCooledAttackStrength(
        ((Boolean)this.options.getValueByName(").get()).booleanValue() ?
        Expensive.getInstance().getTpsCalc().getAdjustTicks() : 1.5F);
    if (attackStrength < 0.92F)
      return false;
    if (!cancelReason && ((Boolean)this.options.getValueByName(").get()).booleanValue())
      return (!mc.player.isOnGround() && mc.player.fallDistance > 0.0F);
    return true;
  }
 
  private boolean isValid(LivingEntity entity) {
    if (entity instanceof net.minecraft.client.entity.player.ClientPlayerEntity)
      return false;
    if (entity.ticksExisted < 3)
      return false;
    if (mc.player.getDistance((Entity)entity) > ((Float)this.attackRange.get()).floatValue())
      return false;
    if (entity instanceof PlayerEntity) {
      PlayerEntity p = (PlayerEntity)entity;
      if (AntiBot.isBot((Entity)entity))
        return false;
      if (!((Boolean)this.targets.getValueByName(").get()).booleanValue() && FriendStorage.isFriend(p.getName().getString()))
        return false;
      if (p.getName().getString().equalsIgnoreCase(mc.player.getName().getString()))
        return false;
    }
    if (entity instanceof PlayerEntity && !((Boolean)this.targets.getValueByName(").get()).booleanValue())
      return false;
    if (entity instanceof PlayerEntity && entity.getTotalArmorValue() == 0 && !((Boolean)this.targets.getValueByName(").get()).booleanValue())
      return false;
    if (entity instanceof PlayerEntity && entity.isInvisible() && entity.getTotalArmorValue() == 0 && !((Boolean)this.targets.getValueByName(").get()).booleanValue())
      return false;
    if (entity instanceof PlayerEntity && entity.isInvisible() && !((Boolean)this.targets.getValueByName(").get()).booleanValue())
      return false;
    if (entity instanceof net.minecraft.entity.monster.MonsterEntity && !((Boolean)this.targets.getValueByName(").get()).booleanValue())
      return false;
    if (entity instanceof net.minecraft.entity.passive.AnimalEntity && !((Boolean)this.targets.getValueByName(").get()).booleanValue())
      return false;
    return (!entity.isInvulnerable() && entity.isAlive() && !(entity instanceof net.minecraft.entity.item.ArmorStandEntity));
  }
 
  private void breakShieldPlayer(PlayerEntity entity) {
    if (entity.isBlocking()) {
      int invSlot = InventoryUtil.getInstance().getAxeInInventory(false);
      int hotBarSlot = InventoryUtil.getInstance().getAxeInInventory(true);
      if (hotBarSlot == -1 && invSlot != -1) {
        int bestSlot = InventoryUtil.getInstance().findBestSlotInHotBar();
        mc.playerController.windowClick(0, invSlot, 0, ClickType.PICKUP, (PlayerEntity)mc.player);
        mc.playerController.windowClick(0, bestSlot + 36, 0, ClickType.PICKUP, (PlayerEntity)mc.player);
        mc.player.connection.sendPacket((IPacket)new CHeldItemChangePacket(bestSlot));
        mc.playerController.attackEntity((PlayerEntity)mc.player, (Entity)entity);
        mc.player.swingArm(Hand.MAIN_HAND);
        mc.player.connection.sendPacket((IPacket)new CHeldItemChangePacket(mc.player.inventory.currentItem));
        mc.playerController.windowClick(0, bestSlot + 36, 0, ClickType.PICKUP, (PlayerEntity)mc.player);
        mc.playerController.windowClick(0, invSlot, 0, ClickType.PICKUP, (PlayerEntity)mc.player);
      }
      if (hotBarSlot != -1) {
        mc.player.connection.sendPacket((IPacket)new CHeldItemChangePacket(hotBarSlot));
        mc.playerController.attackEntity((PlayerEntity)mc.player, (Entity)entity);
        mc.player.swingArm(Hand.MAIN_HAND);
        mc.player.connection.sendPacket((IPacket)new CHeldItemChangePacket(mc.player.inventory.currentItem));
      }
    }
  }
 
  private void reset() {
    if (((Boolean)this.options.getValueByName(").get()).booleanValue())
      mc.player.rotationYawOffset = -2.14748365E9F;
    this.rotateVector = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
    this.smoothHeadYaw = mc.player.rotationYaw;
    this.smoothHeadPitch = mc.player.rotationPitch;
  }
 
  public void onEnable() {
    super.onEnable();
    reset();
    this.target = null;
    this.spookyOffsetMs = 0;
    this.lastDelays.clear();
    this.lastCritDelay = 0;
    this.isWaitingForCrit = false;
    this.stopWatch.setLastMS(0L);
    this.spookyWatch.setLastMS(0L);
    this.critDelayWatch.setLastMS(0L);
  }
 
  public void onDisable() {
    super.onDisable();
    reset();
    this.stopWatch.setLastMS(0L);
    this.spookyWatch.setLastMS(0L);
    this.critDelayWatch.setLastMS(0L);
    this.target = null;
    this.lastDelays.clear();
    this.lastCritDelay = 0;
    this.isWaitingForCrit = false;
  }
 
  private double getEntityArmor(PlayerEntity entityPlayer2) {
    double d2 = 0.0D;
    for (int i2 = 0; i2 < 4; i2++) {
      ItemStack is = (ItemStack)entityPlayer2.inventory.armorInventory.get(i2);
      if (is.getItem() instanceof ArmorItem)
        d2 += getProtectionLvl(is);
    }
    return d2;
  }
 
  private double getProtectionLvl(ItemStack stack) {
    Item item = stack.getItem();
    if (item instanceof ArmorItem) {
      ArmorItem i = (ArmorItem)item;
      double dmg = i.getDamageReduceAmount();
      if (stack.isEnchanted())
        dmg += EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, stack) * 0.25D;
      return dmg;
    }
    return 0.0D;
  }
 
  private double getEntityHealth(LivingEntity ent) {
    if (ent instanceof PlayerEntity) {
      PlayerEntity player = (PlayerEntity)ent;
      return (player.getHealth() + player.getAbsorptionAmount()) * getEntityArmor(player) / 20.0D;
    }
    return (ent.getHealth() + ent.getAbsorptionAmount());
  }
}
 
Назад
Сверху Снизу