Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. package me.gtx.nvidia.mod.mods;
  2.  
  3. import java.util.Iterator;
  4.  
  5. import org.lwjgl.input.Keyboard;
  6.  
  7. import com.darkmagician6.eventapi.EventTarget;
  8. import com.darkmagician6.eventapi.events.EventPacketSent;
  9.  
  10. import me.gtx.nvidia.Category;
  11. import me.gtx.nvidia.mod.Mod;
  12. import net.minecraft.entity.Entity;
  13. import net.minecraft.entity.EntityLivingBase;
  14. import net.minecraft.entity.player.EntityPlayer;
  15. import net.minecraft.network.play.client.C02PacketUseEntity;
  16. import net.minecraft.network.play.client.C03PacketPlayer;
  17. import net.minecraft.util.MathHelper;
  18.  
  19. public class Aura extends Mod {
  20.  
  21.  
  22.  
  23. EntityLivingBase target;
  24. double Reach;
  25. int delay = 0;
  26.  
  27. public Aura() {
  28. super("Aura", "Aura", Keyboard.KEY_R, Category.COMBAT);
  29. }
  30.  
  31. public float[] getRotations(Entity entity) {
  32. if (entity == null) {
  33. return null;
  34. }
  35. double diffX = entity.posX - mc.thePlayer.posX;
  36. double diffZ = entity.posZ - mc.thePlayer.posZ;
  37. double diffY;
  38. if ((entity instanceof EntityPlayer)) {
  39. EntityPlayer elb = (EntityPlayer) entity;
  40. diffY = elb.posY + (elb.getEyeHeight() - 0.4D) - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight());
  41. } else {
  42. diffY = (entity.boundingBox.minY + entity.boundingBox.maxY) / 2.0D
  43. - (mc.thePlayer.posY + mc.thePlayer.getEyeHeight());
  44. }
  45. double dist = MathHelper.sqrt_double(diffX * diffX + diffZ * diffZ);
  46. float yaw = (float) (Math.atan2(diffZ, diffX) * 180.0D / 3.141592653589793D) - 90.0F;
  47. float pitch = (float) -(Math.atan2(diffY, dist) * 180.0D / 3.141592653589793D);
  48.  
  49. return new float[] { yaw, pitch };
  50. }
  51.  
  52. public void Attack(EntityLivingBase e) {
  53. mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(e, C02PacketUseEntity.Action.ATTACK));
  54. mc.thePlayer.swingItem();
  55. }
  56. public static boolean isValid(EntityLivingBase e) {
  57. if(e.isEntityAlive() && e != mc.thePlayer && e!= null) {
  58. return true;
  59. }
  60. return false;
  61. }
  62.  
  63. public void onUpdate() {
  64. if(!this.isToggled()) {
  65. return;
  66. }
  67. ++delay;
  68. if(delay > 3) {
  69. delay = 0;
  70. }
  71. if(isValid(target) && mc.thePlayer.getDistanceToEntity(target) < Reach && delay > 1) {
  72. Attack(target);
  73. }
  74. }
  75. @EventTarget
  76. public void onUpdate(EventPacketSent event) {
  77. if(mc.thePlayer.getDistanceToEntity(target) < Reach) {
  78. float[] rotations = getRotations(target);
  79. C03PacketPlayer packet = (C03PacketPlayer) event.getPacket();
  80. packet.yaw = rotations[0];
  81. packet.pitch = rotations[1];
  82. }
  83. }
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement