Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.aristhena.lucid.modules.combat;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Comparator;
- import java.util.List;
- import me.aristhena.lucid.eventapi.EventTarget;
- import me.aristhena.lucid.eventapi.events.TickEvent;
- import me.aristhena.lucid.eventapi.events.UpdateEvent;
- import me.aristhena.lucid.management.friend.FriendManager;
- import me.aristhena.lucid.management.module.Mod;
- import me.aristhena.lucid.management.module.Module;
- import me.aristhena.lucid.management.module.ModuleManager;
- import me.aristhena.lucid.management.option.Op;
- import me.aristhena.lucid.management.option.Option;
- import me.aristhena.lucid.management.option.OptionManager;
- import me.aristhena.lucid.management.value.Val;
- import me.aristhena.lucid.modules.movement.Speed;
- import me.aristhena.lucid.modules.movement.Sprint;
- import me.aristhena.lucid.modules.render.Hud;
- import me.aristhena.lucid.util.RotationUtils;
- import me.aristhena.lucid.util.Timer;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.entity.EntityPlayerSP;
- import net.minecraft.client.multiplayer.PlayerControllerMP;
- import net.minecraft.client.multiplayer.WorldClient;
- import net.minecraft.client.network.NetHandlerPlayClient;
- import net.minecraft.client.settings.GameSettings;
- import net.minecraft.client.settings.KeyBinding;
- import net.minecraft.enchantment.EnchantmentHelper;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.monster.EntityMob;
- import net.minecraft.entity.passive.EntityAnimal;
- import net.minecraft.entity.passive.EntityBat;
- import net.minecraft.entity.passive.EntitySquid;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.InventoryPlayer;
- import net.minecraft.inventory.Container;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.ItemSword;
- import net.minecraft.network.play.client.C02PacketUseEntity;
- import net.minecraft.network.play.client.C02PacketUseEntity.Action;
- import net.minecraft.network.play.client.C03PacketPlayer;
- import net.minecraft.network.play.client.C03PacketPlayer.C04PacketPlayerPosition;
- import net.minecraft.network.play.client.C07PacketPlayerDigging;
- import net.minecraft.network.play.client.C07PacketPlayerDigging.Action;
- import net.minecraft.network.play.client.C0APacketAnimation;
- import net.minecraft.network.play.client.C0BPacketEntityAction;
- import net.minecraft.network.play.client.C0BPacketEntityAction.Action;
- import net.minecraft.potion.Potion;
- import net.minecraft.util.BlockPos;
- import net.minecraft.util.EnumFacing;
- @Mod
- public class Aura
- extends Module
- {
- @Op
- private boolean players = true;
- @Op
- private boolean monsters;
- @Op
- private boolean animals;
- @Op
- private boolean bats;
- @Op
- private boolean friend;
- @Op
- private boolean knockback;
- @Op
- private boolean noArmor;
- @Op
- private boolean criticals = true;
- @Op
- private boolean autoBlock = true;
- @Op
- private boolean noSwing;
- @Op
- private boolean dura;
- @Op
- private boolean angle = true;
- @Op
- private boolean lockview;
- @Val(min=0.0D, max=20.0D, increment=0.5D)
- private double speed = 8.0D;
- @Val(min=0.0D, max=8.0D, increment=0.25D)
- private double range = 4.25D;
- @Val(min=0.0D, max=15.0D, increment=1.0D)
- private double blockRange = 8.0D;
- private Timer pseudoTimer = new Timer();
- private Timer angleTimer = new Timer();
- private static EntityLivingBase target;
- public static EntityLivingBase pseudoTarget;
- @EventTarget
- private void onTick(TickEvent event)
- {
- Character colorFormatCharacter = new Character('�');
- if (OptionManager.getOption("Hyphen", ModuleManager.getModule(Hud.class)).value) {
- this.suffix = (colorFormatCharacter + "7 - " + "Tick");
- } else {
- this.suffix = (colorFormatCharacter + "7 " + "Tick");
- }
- }
- @EventTarget
- private void onUpdate(UpdateEvent event)
- {
- switch (event.state)
- {
- case POST:
- event.ground = true;
- target = null;
- List<EntityLivingBase> attackableEntities = new ArrayList();
- for (Object o : this.mc.theWorld.loadedEntityList) {
- if ((o instanceof EntityLivingBase))
- {
- EntityLivingBase entity = (EntityLivingBase)o;
- entity.auraTicks -= 1;
- if (checkValidity(entity)) {
- if (((entity.auraTicks == 10) && (!this.dura)) || (entity.auraTicks == 9) || (entity.auraTicks <= 0)) {
- attackableEntities.add(entity);
- }
- }
- }
- }
- Collections.sort(attackableEntities, new Comparator()
- {
- public int compare(EntityLivingBase o1, EntityLivingBase o2)
- {
- return o1.auraTicks - o2.auraTicks;
- }
- });
- for (EntityLivingBase entity : attackableEntities) {
- if (((pseudoTarget != null) && (pseudoTarget == entity)) || (this.angleTimer.delay(150.0F)))
- {
- if ((pseudoTarget == null) || (pseudoTarget != entity)) {
- this.angleTimer.reset();
- }
- pseudoTarget = target = entity;
- break;
- }
- }
- if ((pseudoTarget != null) && (!checkValidity(pseudoTarget))) {
- pseudoTarget = null;
- }
- if (pseudoTarget != null)
- {
- float[] rotations = RotationUtils.getRotations(pseudoTarget);
- event.yaw = rotations[0];
- event.pitch = rotations[1];
- if (this.lockview)
- {
- this.mc.thePlayer.rotationYaw = rotations[0];
- this.mc.thePlayer.rotationPitch = rotations[1];
- }
- }
- break;
- case PRE:
- if (target != null)
- {
- boolean fakeSprint = (ModuleManager.getModule(Sprint.class).enabled) && (OptionManager.getOption("fake", ModuleManager.getModule(Sprint.class)).value);
- if ((this.mc.thePlayer.getHeldItem() != null) && (this.mc.thePlayer.getHeldItem().getItem() != null) && ((this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword))) {
- this.mc.getNetHandler().addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
- }
- if (!fakeSprint) {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C0BPacketEntityAction(this.mc.thePlayer, C0BPacketEntityAction.Action.STOP_SPRINTING));
- }
- if (this.angle)
- {
- if (this.dura)
- {
- if (target.auraTicks != 10)
- {
- swap(9, this.mc.thePlayer.inventory.currentItem);
- this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer(true));
- attack(target, false);
- attack(target, false);
- attack(target, true);
- swap(9, this.mc.thePlayer.inventory.currentItem);
- this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer(true));
- attack(target, false);
- attack(target, true);
- }
- }
- else
- {
- attack(target, this.criticals);
- attack(target, this.criticals);
- }
- }
- else if (this.dura)
- {
- attack(target, false);
- if (target.auraTicks != 10) {
- attack(target, this.criticals);
- }
- }
- else
- {
- attack(target, this.criticals);
- }
- if (target.auraTicks != 10) {
- target.auraTicks = 20;
- }
- boolean sprint = this.mc.thePlayer.isSprinting();
- if ((sprint) && (!fakeSprint)) {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C0BPacketEntityAction(this.mc.thePlayer, C0BPacketEntityAction.Action.START_SPRINTING));
- }
- }
- else if ((pseudoTarget != null) && (this.pseudoTimer.delay((float)(1000.0D / this.speed))))
- {
- fakeAttack(pseudoTarget);
- this.pseudoTimer.reset();
- }
- double oldRange = this.range;
- this.range = this.blockRange;
- int enemiesArmound = 0;
- for (Object o : this.mc.theWorld.loadedEntityList) {
- if ((o instanceof EntityLivingBase))
- {
- EntityLivingBase entity = (EntityLivingBase)o;
- if (checkValidity(entity)) {
- enemiesArmound++;
- }
- }
- }
- this.range = oldRange;
- if ((enemiesArmound > 0) && (this.mc.thePlayer.getHeldItem() != null) && (this.mc.thePlayer.getHeldItem().getItem() != null) && ((this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword)) && ((this.mc.gameSettings.keyBindUseItem.pressed) || (this.autoBlock))) {
- this.mc.thePlayer.setItemInUse(this.mc.thePlayer.getHeldItem(), this.mc.thePlayer.getHeldItem().getMaxItemUseDuration());
- }
- break;
- }
- }
- protected void swap(int slot, int hotbarNum)
- {
- this.mc.playerController.windowClick(this.mc.thePlayer.inventoryContainer.windowId, slot, hotbarNum, 2, this.mc.thePlayer);
- }
- private void fakeAttack(EntityLivingBase ent)
- {
- fakeSwingItem();
- float sharpLevel = EnchantmentHelper.func_152377_a(this.mc.thePlayer.getHeldItem(), ent.getCreatureAttribute());
- boolean vanillaCrit = (this.mc.thePlayer.fallDistance > 0.0F) && (!this.mc.thePlayer.onGround) && (!this.mc.thePlayer.isOnLadder()) && (!this.mc.thePlayer.isInWater()) && (!this.mc.thePlayer.isPotionActive(Potion.blindness)) && (this.mc.thePlayer.ridingEntity == null);
- if ((this.criticals) || (vanillaCrit)) {
- this.mc.thePlayer.onCriticalHit(ent);
- }
- if (sharpLevel > 0.0F) {
- this.mc.thePlayer.onEnchantmentCritical(ent);
- }
- this.pseudoTimer.reset();
- }
- private void attack(EntityLivingBase ent, boolean crit)
- {
- swingItem();
- if (crit) {
- crit();
- } else {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer());
- }
- float sharpLevel = EnchantmentHelper.func_152377_a(this.mc.thePlayer.getHeldItem(), ent.getCreatureAttribute());
- boolean vanillaCrit = (this.mc.thePlayer.fallDistance > 0.0F) && (!this.mc.thePlayer.onGround) && (!this.mc.thePlayer.isOnLadder()) && (!this.mc.thePlayer.isInWater()) && (!this.mc.thePlayer.isPotionActive(Potion.blindness)) && (this.mc.thePlayer.ridingEntity == null);
- this.mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(ent, C02PacketUseEntity.Action.ATTACK));
- if ((crit) || (vanillaCrit)) {
- this.mc.thePlayer.onCriticalHit(ent);
- }
- if (sharpLevel > 0.0F) {
- this.mc.thePlayer.onEnchantmentCritical(ent);
- }
- }
- private void fakeSwingItem()
- {
- if (!this.noSwing) {
- this.mc.thePlayer.fakeSwingItem();
- }
- }
- private void swingItem()
- {
- if (this.noSwing) {
- this.mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation());
- } else {
- this.mc.thePlayer.swingItem();
- }
- }
- private void crit()
- {
- double posY = this.mc.thePlayer.posY + Speed.yOffset;
- this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.mc.thePlayer.posX, posY + 0.0625D, this.mc.thePlayer.posZ, true));
- this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.mc.thePlayer.posX, posY, this.mc.thePlayer.posZ, false));
- this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.mc.thePlayer.posX, posY + 1.1E-5D, this.mc.thePlayer.posZ, false));
- this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.mc.thePlayer.posX, posY, this.mc.thePlayer.posZ, false));
- }
- private boolean checkValidity(EntityLivingBase entity)
- {
- if (entity == this.mc.thePlayer) {
- return false;
- }
- if (!entity.isEntityAlive()) {
- return false;
- }
- if (this.mc.thePlayer.getDistanceToEntity(entity) > this.range) {
- return false;
- }
- if ((entity instanceof EntityPlayer))
- {
- if (this.players)
- {
- EntityPlayer player = (EntityPlayer)entity;
- if ((this.friend) && (FriendManager.isFriend(player.getCommandSenderName()))) {
- return true;
- }
- if (FriendManager.isFriend(player.getCommandSenderName())) {
- return false;
- }
- if ((this.noArmor) && (!hasArmor(player))) {
- return false;
- }
- return true;
- }
- return false;
- }
- if ((this.monsters) && ((entity instanceof EntityMob))) {
- return true;
- }
- if ((this.animals) && (((entity instanceof EntityAnimal)) || ((entity instanceof EntitySquid)))) {
- return true;
- }
- if ((this.bats) && ((entity instanceof EntityBat))) {
- return true;
- }
- return false;
- }
- private boolean hasArmor(EntityPlayer player)
- {
- ItemStack boots = player.inventory.armorInventory[0];
- ItemStack pants = player.inventory.armorInventory[1];
- ItemStack chest = player.inventory.armorInventory[2];
- ItemStack head = player.inventory.armorInventory[3];
- if ((boots != null) || (pants != null) || (chest != null) || (head != null)) {
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement