Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- }
- public static Queue<Entity> entityList = new ConcurrentLinkedQueue();
- public boolean players = true;
- public boolean mobs;
- public boolean animals;
- public boolean block;
- public double distance = Values.getValues().distance;
- private TimeHelper time = new TimeHelper();
- private TimeHelper blocktime = new TimeHelper();
- private TimeHelper targetSwitchTime = new TimeHelper();
- private TimeHelper angleSwitchTime = new TimeHelper();
- private boolean shouldblock = false;
- public int aps = this.time.convertToMS(Values.getValues().cps);
- public static Entity target = null;
- private boolean wassprint = false;
- private boolean waslistfull = false;
- private boolean wasblock = false;
- private EntityLivingBase nexttarget;
- public static float[] rot = { 0.0F, 0.0F };
- private float lastYaw;
- private float lastPitch;
- public void onPreMotionUpdate()
- {
- if (this.mc.theWorld == null) {
- return;
- }
- this.aps = this.time.convertToMS(Values.getValues().cps);
- this.distance = Values.getValues().distance;
- populateEntityList();
- this.nexttarget = setupForNextEntity();
- try
- {
- if ((entityList.isEmpty()) && (this.lasthit.isDelayComplete(1000L)) && (isSword(this.mc.thePlayer.inventory.getCurrentItem().getItem()))) {
- this.wasblock = this.mc.thePlayer.isBlocking();
- }
- if ((!entityList.isEmpty()) && (Values.getValues().autoblock) && (isSword(this.mc.thePlayer.inventory.getCurrentItem().getItem())))
- {
- this.mc.gameSettings.keyBindUseItem.pressed = true;
- this.waslistfull = true;
- }
- else
- {
- this.waslistfull = false;
- }
- if ((this.lasthit.isDelayComplete(250L)) && (Values.getValues().autoblock) && (!this.lasthit.isDelayComplete(500L)) && (isSword(this.mc.thePlayer.inventory.getCurrentItem().getItem())))
- {
- this.mc.gameSettings.keyBindUseItem.pressed = false;
- for (int i = 0; i <= 2; i++) {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, new BlockPos(0, 0, 0), EnumFacing.DOWN));
- }
- }
- }
- catch (NullPointerException localNullPointerException) {}
- this.lastYaw = this.mc.thePlayer.rotationYaw;
- this.lastPitch = this.mc.thePlayer.rotationPitch;
- if (!this.lasthit.isDelayComplete(2000L))
- {
- this.mc.thePlayer.rotationYaw = rot[0];
- this.mc.thePlayer.rotationPitch = rot[1];
- }
- }
- public void onPostMotionUpdate()
- {
- if (this.mc.theWorld == null) {
- return;
- }
- this.wassprint = this.mc.thePlayer.isSprinting();
- this.mc.thePlayer.setSprinting(false);
- attackEntity(this.nexttarget);
- this.mc.thePlayer.setSprinting(this.wassprint);
- this.mc.thePlayer.rotationYaw = this.lastYaw;
- this.mc.thePlayer.rotationPitch = this.lastPitch;
- }
- public void onDisable()
- {
- try
- {
- if ((Values.getValues().autoblock) && (isSword(this.mc.thePlayer.inventory.getCurrentItem().getItem())))
- {
- this.mc.gameSettings.keyBindUseItem.pressed = false;
- for (int i = 0; i <= 2; i++) {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, new BlockPos(0, 0, 0), EnumFacing.DOWN));
- }
- }
- }
- catch (NullPointerException localNullPointerException) {}
- }
- private void populateEntityList()
- {
- for (Object o : this.mc.theWorld.loadedEntityList)
- {
- Entity e = (Entity)o;
- if (isAttackable(e)) {
- entityList.add(e);
- }
- }
- }
- private TimeHelper lasthit = new TimeHelper();
- boolean editpacket = false;
- private EntityLivingBase lastAttackedTarget;
- public void onPacketSend(Packet packet)
- {
- if ((packet instanceof C03PacketPlayer)) {
- C03PacketPlayer localC03PacketPlayer = (C03PacketPlayer)packet;
- }
- }
- private EntityLivingBase setupForNextEntity()
- {
- Random rand = new Random();
- EntityLivingBase toattack = null;
- try
- {
- for (Entity e : entityList) {
- if (this.time.isDelayComplete(rand.nextInt(this.aps - 53 + 1) + (this.aps - 20))) {
- if ((isViableToAttack((EntityLivingBase)e)) && (isAttackable(e)))
- {
- rot = getAngles(e);
- target = e;
- toattack = (EntityLivingBase)e;
- if (this.mc.thePlayer.isBlocking()) {
- for (int i = 0; i <= 2; i++) {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, new BlockPos(0, 0, 0), EnumFacing.DOWN));
- }
- }
- this.time.setLastMS();
- entityList.remove(e);
- }
- else
- {
- entityList.remove(e);
- }
- }
- }
- }
- catch (NullPointerException localNullPointerException) {}
- return toattack;
- }
- private void attackEntity(EntityLivingBase e)
- {
- try
- {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(e, C02PacketUseEntity.Action.ATTACK));
- this.mc.thePlayer.swingItem();
- this.lasthit.setLastMS();
- if (this.mc.thePlayer.isBlocking()) {
- for (int i = 0; i <= 2; i++) {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(new BlockPos(-1, -1, -1), 255, this.mc.thePlayer.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
- }
- }
- this.targetSwitchTime.setLastMS();
- this.lastAttackedTarget = ((EntityLivingBase)target);
- target = null;
- this.mc.thePlayer.setSprinting(this.wassprint);
- this.nexttarget = null;
- }
- catch (NullPointerException localNullPointerException) {}
- }
- private void attackEntityList()
- {
- Random rand = new Random();
- try
- {
- for (Entity e : entityList) {
- if (this.time.isDelayComplete(rand.nextInt(this.aps - 53 + 1) + (this.aps - 20))) {
- if (isViableToAttack((EntityLivingBase)e))
- {
- rot = getAngles(e);
- this.mc.thePlayer.setSprinting(false);
- target = e;
- if (this.mc.thePlayer.isBlocking()) {
- for (int i = 0; i <= 2; i++) {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, new BlockPos(0, 0, 0), EnumFacing.DOWN));
- }
- }
- this.mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(target, C02PacketUseEntity.Action.ATTACK));
- this.mc.thePlayer.swingItem();
- this.lasthit.setLastMS();
- entityList.remove(e);
- this.time.setLastMS();
- if (this.mc.thePlayer.isBlocking()) {
- for (int i = 0; i <= 2; i++) {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(new BlockPos(-1, -1, -1), 255, this.mc.thePlayer.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F));
- }
- }
- this.targetSwitchTime.setLastMS();
- this.lastAttackedTarget = ((EntityLivingBase)target);
- target = null;
- this.mc.thePlayer.setSprinting(this.wassprint);
- }
- else
- {
- entityList.remove(e);
- }
- }
- }
- }
- catch (NullPointerException localNullPointerException) {}
- }
- private boolean isAttackable(Entity e)
- {
- if (e == null) {
- return false;
- }
- if (((e instanceof EntityPlayer)) && (this.players))
- {
- EntityPlayer p = (EntityPlayer)e;
- if (Friends.isFriend(e.getName())) {
- return false;
- }
- if ((!p.isDead) && (p.ticksExisted > Values.getValues().ticks) && ((!p.isInvisible()) || (Values.getValues().invisibles))) {
- if ((this.mc.thePlayer.getDistanceToEntity(p) <= (this.mc.thePlayer.canEntityBeSeen(p) ? this.distance : 2.8D)) && (p != this.mc.thePlayer)) {
- return true;
- }
- }
- }
- else if ((e instanceof EntityMob))
- {
- EntityMob m = (EntityMob)e;
- if ((!m.isDead) && (m.ticksExisted > Values.getValues().ticks) && ((!m.isInvisible()) || (Values.getValues().invisibles))) {
- if (this.mc.thePlayer.getDistanceToEntity(m) <= (this.mc.thePlayer.canEntityBeSeen(m) ? this.distance : 2.8D)) {
- return true;
- }
- }
- }
- else if ((e instanceof EntityAnimal))
- {
- EntityAnimal a = (EntityAnimal)e;
- if ((!a.isDead) && (a.ticksExisted > Values.getValues().ticks) && ((!a.isInvisible()) || (Values.getValues().invisibles))) {
- if (this.mc.thePlayer.getDistanceToEntity(a) <= (this.mc.thePlayer.canEntityBeSeen(a) ? this.distance : 2.8D)) {
- return true;
- }
- }
- }
- return false;
- }
- public float[] getAngles(Entity entity)
- {
- float xDiff = (float)(entity.posX - this.mc.thePlayer.posX);
- float yDiff = (float)(entity.boundingBox.minY + entity.getEyeHeight() - this.mc.thePlayer.boundingBox.maxY);
- float zDiff = (float)(entity.posZ - this.mc.thePlayer.posZ);
- float yaw = (float)(Math.atan2(zDiff, xDiff) * 180.0D / 3.141592653589793D - 90.0D);
- float pitch = (float)-Math.toDegrees(Math.atan(yDiff / Math.sqrt(zDiff * zDiff + xDiff * xDiff)));
- return new float[] {
- yaw, pitch };
- }
- private float updateRotation(float par1, float par2, float par3)
- {
- float var4 = MathHelper.wrapAngleTo180_float(par2 - par1);
- if (var4 > par3) {
- var4 = par3;
- }
- if (var4 < -par3) {
- var4 = -par3;
- }
- return par1 + var4;
- }
- private boolean isSword(Item item)
- {
- return item instanceof ItemSword;
- }
- public boolean isViableToAttack(EntityLivingBase p)
- {
- double range = this.mc.thePlayer.isSprinting() ? this.distance - 0.20000000298023224D : this.distance;
- float playerYaw = this.lastYaw;
- float desiredYaw = getAngles(p)[0];
- float distYaw = (playerYaw - desiredYaw + 360.0F) % 360.0F;
- if (distYaw > 180.0F) {
- distYaw = 360.0F - distYaw;
- }
- float playerPitch = this.lastPitch;
- float desiredPitch = getAngles(p)[1];
- float distPitch = (playerPitch - desiredPitch + 360.0F) % 360.0F;
- if (distPitch > 180.0F) {
- distPitch = 360.0F - distPitch;
- }
- float distCombined = distYaw + distPitch;
- double maxAngle = 60.0D;
- if ((this.lastYaw != this.mc.thePlayer.rotationYaw) || (this.lastPitch != this.mc.thePlayer.rotationPitch)) {
- maxAngle = 45.0D;
- }
- boolean angleCheck = distCombined < maxAngle;
- if (!angleCheck) {}
- angleCheck = this.angleSwitchTime.isDelayComplete(entityList.size() <= 3 ? 10 : 60);
- if (angleCheck) {
- this.angleSwitchTime.setLastMS();
- }
- return (isAttackable(p)) && (this.mc.thePlayer.getDistanceSqToEntity(p) < range * range) && (
- (p != this.lastAttackedTarget) || (entityList.size() <= 1) || ((this.targetSwitchTime.isDelayComplete(200L)) &&
- ((p.hurtTime <= 2) || (entityList.size() <= 1)) && (
- (angleCheck) || (entityList.size() <= 1))));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement