Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. public class KillPoint extends Module {
  2. private EntityLivingBase target;
  3. private long current, last;
  4. private int delay = 8;
  5. private float yaw, pitch;
  6. private boolean others;
  7. public KillPoint() {
  8. super("KillPoint", Keyboard.CHAR_NONE, Category.PLAYER);
  9. }
  10.  
  11. public void onEnable() {
  12. super.onEnable();
  13. }
  14.  
  15. public void onDisable() {
  16. super.onDisable();
  17. }
  18.  
  19. @EventTarget
  20. public void onPre(EventMotion event) {
  21. if(event.getType().equals(Type.PRE)) {
  22. target = getClosest(mc.playerController.getBlockReachDistance());
  23. if(target == null)
  24. return;
  25. updateTime();
  26. yaw = mc.thePlayer.rotationYaw;
  27. pitch = mc.thePlayer.rotationPitch;
  28. if(current - last > 1000 / delay) {
  29. teleport(target);
  30. resetTime();
  31. }
  32. }
  33. }
  34. @EventTarget
  35. public void onPost(EventMotion event) {
  36. if(event.getType().equals(Type.POST)) {
  37. if(target == null)
  38. return;
  39. mc.thePlayer.rotationYaw = yaw;
  40. mc.thePlayer.rotationPitch = pitch;
  41. }
  42. }
  43.  
  44. private void teleport(Entity entity) {
  45. double newX;
  46. double newZ;
  47. float yaw = target.getRotationYawHead();
  48. if(yaw < 0) yaw += 360;
  49. newX = Math.cos(Math.toRadians(yaw));
  50. newZ = Math.sin(Math.toRadians(yaw));
  51. double newD;
  52. EnumFacing Face = target.getHorizontalFacing();
  53. if(Face.EAST != null) {
  54. mc.thePlayer.setPositionAndRotation(target.posX - 2.5, target.posY, target.posZ, -90, 0);
  55. }
  56. if(Face.SOUTH != null) {
  57. mc.thePlayer.setPositionAndRotation(target.posX, target.posY, target.posZ - 2.5, 0, 0);
  58. }
  59. if(Face.WEST != null) {
  60. mc.thePlayer.setPositionAndRotation(target.posX + 2.5, target.posY, target.posZ, 90, 0);
  61. }
  62. if(Face.NORTH != null) {
  63. mc.thePlayer.setPositionAndRotation(target.posX, target.posY, target.posZ + 2.5, 180, 0);
  64. } else {
  65. mc.thePlayer.setPositionAndRotation(target.posX + newX, target.posY, target.posZ + newZ, target.getRotationYawHead(), target.cameraPitch);
  66. }
  67. toggle();
  68. }
  69.  
  70. private void updateTime() {
  71. current = (System.nanoTime() / 1000000L);
  72. }
  73.  
  74. private void resetTime() {
  75. last = (System.nanoTime() / 1000000L);
  76. }
  77.  
  78. private EntityLivingBase getClosest(double range) {
  79. double dist = range;
  80. EntityLivingBase target = null;
  81. for(Object object : mc.theWorld.loadedEntityList) {
  82. Entity entity = (Entity)object;
  83. if(entity instanceof EntityLivingBase) {
  84. EntityLivingBase player = (EntityLivingBase)entity;
  85. if(canAttack(player)) {
  86. if(!(player instanceof EntityMob) && (!(player instanceof EntityAnimal) || others)) {
  87. double currentDist = mc.thePlayer.getDistanceToEntity(player);
  88. if(currentDist <= dist) {
  89. dist = currentDist;
  90. target = player;
  91. }
  92. }
  93. }
  94. }
  95. }
  96. return target;
  97. }
  98.  
  99. private boolean canAttack(EntityLivingBase player) {
  100. return player != mc.thePlayer && player.isEntityAlive() && mc.thePlayer.getDistanceToEntity(player) <= mc.playerController.getBlockReachDistance() && player.ticksExisted > 30;
  101. }
  102.  
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement