Advertisement
Guest User

Untitled

a guest
May 30th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.06 KB | None | 0 0
  1. package me.aristhena.lucid.modules.combat;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Collections;
  5. import java.util.Comparator;
  6. import java.util.List;
  7. import me.aristhena.lucid.eventapi.EventTarget;
  8. import me.aristhena.lucid.eventapi.events.TickEvent;
  9. import me.aristhena.lucid.eventapi.events.UpdateEvent;
  10. import me.aristhena.lucid.management.friend.FriendManager;
  11. import me.aristhena.lucid.management.module.Mod;
  12. import me.aristhena.lucid.management.module.Module;
  13. import me.aristhena.lucid.management.module.ModuleManager;
  14. import me.aristhena.lucid.management.option.Op;
  15. import me.aristhena.lucid.management.option.Option;
  16. import me.aristhena.lucid.management.option.OptionManager;
  17. import me.aristhena.lucid.management.value.Val;
  18. import me.aristhena.lucid.modules.movement.Speed;
  19. import me.aristhena.lucid.modules.movement.Sprint;
  20. import me.aristhena.lucid.modules.render.Hud;
  21. import me.aristhena.lucid.util.RotationUtils;
  22. import me.aristhena.lucid.util.Timer;
  23. import net.minecraft.client.Minecraft;
  24. import net.minecraft.client.entity.EntityPlayerSP;
  25. import net.minecraft.client.multiplayer.PlayerControllerMP;
  26. import net.minecraft.client.multiplayer.WorldClient;
  27. import net.minecraft.client.network.NetHandlerPlayClient;
  28. import net.minecraft.client.settings.GameSettings;
  29. import net.minecraft.client.settings.KeyBinding;
  30. import net.minecraft.enchantment.EnchantmentHelper;
  31. import net.minecraft.entity.EntityLivingBase;
  32. import net.minecraft.entity.monster.EntityMob;
  33. import net.minecraft.entity.passive.EntityAnimal;
  34. import net.minecraft.entity.passive.EntityBat;
  35. import net.minecraft.entity.passive.EntitySquid;
  36. import net.minecraft.entity.player.EntityPlayer;
  37. import net.minecraft.entity.player.InventoryPlayer;
  38. import net.minecraft.inventory.Container;
  39. import net.minecraft.item.ItemStack;
  40. import net.minecraft.item.ItemSword;
  41. import net.minecraft.network.play.client.C02PacketUseEntity;
  42. import net.minecraft.network.play.client.C02PacketUseEntity.Action;
  43. import net.minecraft.network.play.client.C03PacketPlayer;
  44. import net.minecraft.network.play.client.C03PacketPlayer.C04PacketPlayerPosition;
  45. import net.minecraft.network.play.client.C07PacketPlayerDigging;
  46. import net.minecraft.network.play.client.C07PacketPlayerDigging.Action;
  47. import net.minecraft.network.play.client.C0APacketAnimation;
  48. import net.minecraft.network.play.client.C0BPacketEntityAction;
  49. import net.minecraft.network.play.client.C0BPacketEntityAction.Action;
  50. import net.minecraft.potion.Potion;
  51. import net.minecraft.util.BlockPos;
  52. import net.minecraft.util.EnumFacing;
  53.  
  54. @Mod
  55. public class Aura
  56. extends Module
  57. {
  58. @Op
  59. private boolean players = true;
  60. @Op
  61. private boolean monsters;
  62. @Op
  63. private boolean animals;
  64. @Op
  65. private boolean bats;
  66. @Op
  67. private boolean friend;
  68. @Op
  69. private boolean knockback;
  70. @Op
  71. private boolean noArmor;
  72. @Op
  73. private boolean criticals = true;
  74. @Op
  75. private boolean autoBlock = true;
  76. @Op
  77. private boolean noSwing;
  78. @Op
  79. private boolean dura;
  80. @Op
  81. private boolean angle = true;
  82. @Op
  83. private boolean lockview;
  84. @Val(min=0.0D, max=20.0D, increment=0.5D)
  85. private double speed = 8.0D;
  86. @Val(min=0.0D, max=8.0D, increment=0.25D)
  87. private double range = 4.25D;
  88. @Val(min=0.0D, max=15.0D, increment=1.0D)
  89. private double blockRange = 8.0D;
  90. private Timer pseudoTimer = new Timer();
  91. private Timer angleTimer = new Timer();
  92. private static EntityLivingBase target;
  93. public static EntityLivingBase pseudoTarget;
  94.  
  95. @EventTarget
  96. private void onTick(TickEvent event)
  97. {
  98. Character colorFormatCharacter = new Character('�');
  99. if (OptionManager.getOption("Hyphen", ModuleManager.getModule(Hud.class)).value) {
  100. this.suffix = (colorFormatCharacter + "7 - " + "Tick");
  101. } else {
  102. this.suffix = (colorFormatCharacter + "7 " + "Tick");
  103. }
  104. }
  105.  
  106. @EventTarget
  107. private void onUpdate(UpdateEvent event)
  108. {
  109. switch (event.state)
  110. {
  111. case POST:
  112. event.ground = true;
  113. target = null;
  114.  
  115. List<EntityLivingBase> attackableEntities = new ArrayList();
  116. for (Object o : this.mc.theWorld.loadedEntityList) {
  117. if ((o instanceof EntityLivingBase))
  118. {
  119. EntityLivingBase entity = (EntityLivingBase)o;
  120.  
  121. entity.auraTicks -= 1;
  122. if (checkValidity(entity)) {
  123. if (((entity.auraTicks == 10) && (!this.dura)) || (entity.auraTicks == 9) || (entity.auraTicks <= 0)) {
  124. attackableEntities.add(entity);
  125. }
  126. }
  127. }
  128. }
  129. Collections.sort(attackableEntities, new Comparator()
  130. {
  131. public int compare(EntityLivingBase o1, EntityLivingBase o2)
  132. {
  133. return o1.auraTicks - o2.auraTicks;
  134. }
  135. });
  136. for (EntityLivingBase entity : attackableEntities) {
  137. if (((pseudoTarget != null) && (pseudoTarget == entity)) || (this.angleTimer.delay(150.0F)))
  138. {
  139. if ((pseudoTarget == null) || (pseudoTarget != entity)) {
  140. this.angleTimer.reset();
  141. }
  142. pseudoTarget = target = entity;
  143. break;
  144. }
  145. }
  146. if ((pseudoTarget != null) && (!checkValidity(pseudoTarget))) {
  147. pseudoTarget = null;
  148. }
  149. if (pseudoTarget != null)
  150. {
  151. float[] rotations = RotationUtils.getRotations(pseudoTarget);
  152.  
  153. event.yaw = rotations[0];
  154. event.pitch = rotations[1];
  155. if (this.lockview)
  156. {
  157. this.mc.thePlayer.rotationYaw = rotations[0];
  158. this.mc.thePlayer.rotationPitch = rotations[1];
  159. }
  160. }
  161. break;
  162. case PRE:
  163. if (target != null)
  164. {
  165. boolean fakeSprint = (ModuleManager.getModule(Sprint.class).enabled) && (OptionManager.getOption("fake", ModuleManager.getModule(Sprint.class)).value);
  166. if ((this.mc.thePlayer.getHeldItem() != null) && (this.mc.thePlayer.getHeldItem().getItem() != null) && ((this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword))) {
  167. this.mc.getNetHandler().addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
  168. }
  169. if (!fakeSprint) {
  170. this.mc.thePlayer.sendQueue.addToSendQueue(new C0BPacketEntityAction(this.mc.thePlayer, C0BPacketEntityAction.Action.STOP_SPRINTING));
  171. }
  172. if (this.angle)
  173. {
  174. if (this.dura)
  175. {
  176. if (target.auraTicks != 10)
  177. {
  178. swap(9, this.mc.thePlayer.inventory.currentItem);
  179. this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer(true));
  180. attack(target, false);
  181. attack(target, false);
  182. attack(target, true);
  183.  
  184. swap(9, this.mc.thePlayer.inventory.currentItem);
  185. this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer(true));
  186. attack(target, false);
  187. attack(target, true);
  188. }
  189. }
  190. else
  191. {
  192. attack(target, this.criticals);
  193. attack(target, this.criticals);
  194. }
  195. }
  196. else if (this.dura)
  197. {
  198. attack(target, false);
  199. if (target.auraTicks != 10) {
  200. attack(target, this.criticals);
  201. }
  202. }
  203. else
  204. {
  205. attack(target, this.criticals);
  206. }
  207. if (target.auraTicks != 10) {
  208. target.auraTicks = 20;
  209. }
  210. boolean sprint = this.mc.thePlayer.isSprinting();
  211. if ((sprint) && (!fakeSprint)) {
  212. this.mc.thePlayer.sendQueue.addToSendQueue(new C0BPacketEntityAction(this.mc.thePlayer, C0BPacketEntityAction.Action.START_SPRINTING));
  213. }
  214. }
  215. else if ((pseudoTarget != null) && (this.pseudoTimer.delay((float)(1000.0D / this.speed))))
  216. {
  217. fakeAttack(pseudoTarget);
  218. this.pseudoTimer.reset();
  219. }
  220. double oldRange = this.range;
  221. this.range = this.blockRange;
  222.  
  223. int enemiesArmound = 0;
  224. for (Object o : this.mc.theWorld.loadedEntityList) {
  225. if ((o instanceof EntityLivingBase))
  226. {
  227. EntityLivingBase entity = (EntityLivingBase)o;
  228. if (checkValidity(entity)) {
  229. enemiesArmound++;
  230. }
  231. }
  232. }
  233. this.range = oldRange;
  234. 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))) {
  235. this.mc.thePlayer.setItemInUse(this.mc.thePlayer.getHeldItem(), this.mc.thePlayer.getHeldItem().getMaxItemUseDuration());
  236. }
  237. break;
  238. }
  239. }
  240.  
  241. protected void swap(int slot, int hotbarNum)
  242. {
  243. this.mc.playerController.windowClick(this.mc.thePlayer.inventoryContainer.windowId, slot, hotbarNum, 2, this.mc.thePlayer);
  244. }
  245.  
  246. private void fakeAttack(EntityLivingBase ent)
  247. {
  248. fakeSwingItem();
  249.  
  250. float sharpLevel = EnchantmentHelper.func_152377_a(this.mc.thePlayer.getHeldItem(), ent.getCreatureAttribute());
  251. 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);
  252. if ((this.criticals) || (vanillaCrit)) {
  253. this.mc.thePlayer.onCriticalHit(ent);
  254. }
  255. if (sharpLevel > 0.0F) {
  256. this.mc.thePlayer.onEnchantmentCritical(ent);
  257. }
  258. this.pseudoTimer.reset();
  259. }
  260.  
  261. private void attack(EntityLivingBase ent, boolean crit)
  262. {
  263. swingItem();
  264. if (crit) {
  265. crit();
  266. } else {
  267. this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer());
  268. }
  269. float sharpLevel = EnchantmentHelper.func_152377_a(this.mc.thePlayer.getHeldItem(), ent.getCreatureAttribute());
  270. 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);
  271. this.mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(ent, C02PacketUseEntity.Action.ATTACK));
  272. if ((crit) || (vanillaCrit)) {
  273. this.mc.thePlayer.onCriticalHit(ent);
  274. }
  275. if (sharpLevel > 0.0F) {
  276. this.mc.thePlayer.onEnchantmentCritical(ent);
  277. }
  278. }
  279.  
  280. private void fakeSwingItem()
  281. {
  282. if (!this.noSwing) {
  283. this.mc.thePlayer.fakeSwingItem();
  284. }
  285. }
  286.  
  287. private void swingItem()
  288. {
  289. if (this.noSwing) {
  290. this.mc.thePlayer.sendQueue.addToSendQueue(new C0APacketAnimation());
  291. } else {
  292. this.mc.thePlayer.swingItem();
  293. }
  294. }
  295.  
  296. private void crit()
  297. {
  298. double posY = this.mc.thePlayer.posY + Speed.yOffset;
  299.  
  300. this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.mc.thePlayer.posX, posY + 0.0625D, this.mc.thePlayer.posZ, true));
  301. this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.mc.thePlayer.posX, posY, this.mc.thePlayer.posZ, false));
  302. this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.mc.thePlayer.posX, posY + 1.1E-5D, this.mc.thePlayer.posZ, false));
  303. this.mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.mc.thePlayer.posX, posY, this.mc.thePlayer.posZ, false));
  304. }
  305.  
  306. private boolean checkValidity(EntityLivingBase entity)
  307. {
  308. if (entity == this.mc.thePlayer) {
  309. return false;
  310. }
  311. if (!entity.isEntityAlive()) {
  312. return false;
  313. }
  314. if (this.mc.thePlayer.getDistanceToEntity(entity) > this.range) {
  315. return false;
  316. }
  317. if ((entity instanceof EntityPlayer))
  318. {
  319. if (this.players)
  320. {
  321. EntityPlayer player = (EntityPlayer)entity;
  322. if ((this.friend) && (FriendManager.isFriend(player.getCommandSenderName()))) {
  323. return true;
  324. }
  325. if (FriendManager.isFriend(player.getCommandSenderName())) {
  326. return false;
  327. }
  328. if ((this.noArmor) && (!hasArmor(player))) {
  329. return false;
  330. }
  331. return true;
  332. }
  333. return false;
  334. }
  335. if ((this.monsters) && ((entity instanceof EntityMob))) {
  336. return true;
  337. }
  338. if ((this.animals) && (((entity instanceof EntityAnimal)) || ((entity instanceof EntitySquid)))) {
  339. return true;
  340. }
  341. if ((this.bats) && ((entity instanceof EntityBat))) {
  342. return true;
  343. }
  344. return false;
  345. }
  346.  
  347. private boolean hasArmor(EntityPlayer player)
  348. {
  349. ItemStack boots = player.inventory.armorInventory[0];
  350. ItemStack pants = player.inventory.armorInventory[1];
  351. ItemStack chest = player.inventory.armorInventory[2];
  352. ItemStack head = player.inventory.armorInventory[3];
  353. if ((boots != null) || (pants != null) || (chest != null) || (head != null)) {
  354. return true;
  355. }
  356. return false;
  357. }
  358. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement