Advertisement
BHOPPEDD

Untitled

Jun 19th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.24 KB | None | 0 0
  1. package xyz.bhopped.trend.utilities.minecraft;
  2.  
  3. import net.minecraft.client.*;
  4. import net.minecraft.world.*;
  5. import java.math.*;
  6. import net.minecraft.network.play.client.*;
  7. import net.minecraft.network.*;
  8. import net.minecraft.block.*;
  9. import net.minecraft.util.*;
  10.  
  11. public class MovementUtils
  12. {
  13. public Minecraft mc;
  14.  
  15. public MovementUtils() {
  16. this.mc = Minecraft.getMinecraft();
  17. }
  18.  
  19. public void teleport(final double x, final double y, final double z) {
  20. double playerX = Minecraft.thePlayer.posX;
  21. double playerY = Minecraft.thePlayer.posY;
  22. double playerZ = Minecraft.thePlayer.posZ;
  23. double xDistance = x - playerX;
  24. double yDistance = y - playerY;
  25. double zDistance = z - playerZ;
  26. double distance = Math.sqrt(xDistance * xDistance + yDistance * yDistance + zDistance * zDistance);
  27. if (distance < 5.0) {
  28. this.setPosition(x, y, z);
  29. return;
  30. }
  31. distance /= 8.0;
  32. xDistance /= distance;
  33. yDistance /= distance;
  34. zDistance /= distance;
  35. for (int i = 0; i < distance; ++i) {
  36. playerX += xDistance;
  37. playerY += yDistance;
  38. playerZ += zDistance;
  39. this.setPosition(playerX, playerY, playerZ);
  40. try {
  41. Thread.sleep(10L);
  42. }
  43. catch (Exception ex) {}
  44. }
  45. this.setPosition(x, y, z);
  46. }
  47.  
  48. public boolean isInsideBlock() {
  49. for (int x = MathHelper.floor_double(Minecraft.thePlayer.getEntityBoundingBox().minX); x < MathHelper.floor_double(Minecraft.thePlayer.getEntityBoundingBox().maxX) + 1; ++x) {
  50. for (int y = MathHelper.floor_double(Minecraft.thePlayer.getEntityBoundingBox().minY); y < MathHelper.floor_double(Minecraft.thePlayer.getEntityBoundingBox().maxY) + 1; ++y) {
  51. for (int z = MathHelper.floor_double(Minecraft.thePlayer.getEntityBoundingBox().minZ); z < MathHelper.floor_double(Minecraft.thePlayer.getEntityBoundingBox().maxZ) + 1; ++z) {
  52. final Block block = Minecraft.theWorld.getBlockState(new BlockPos(x, y, z)).getBlock();
  53. if (block != null && !(block instanceof BlockAir)) {
  54. AxisAlignedBB boundingBox = block.getCollisionBoundingBox(Minecraft.theWorld, new BlockPos(x, y, z), Minecraft.theWorld.getBlockState(new BlockPos(x, y, z)));
  55. if (block instanceof BlockHopper) {
  56. boundingBox = new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1);
  57. }
  58. if (boundingBox != null && Minecraft.thePlayer.getEntityBoundingBox().intersectsWith(boundingBox)) {
  59. return true;
  60. }
  61. }
  62. }
  63. }
  64. }
  65. return false;
  66. }
  67.  
  68. public void blinkToPos(final double[] startPos, final BlockPos endPos, final double slack) {
  69. double curX = startPos[0];
  70. double curY = startPos[1];
  71. double curZ = startPos[2];
  72. final double endX = endPos.getX() + 0.5;
  73. final double endY = endPos.getY() + 1.0;
  74. final double endZ = endPos.getZ() + 0.5;
  75. double distance = Math.abs(curX - endX) + Math.abs(curY - endY) + Math.abs(curZ - endZ);
  76. int count = 0;
  77. while (distance > slack) {
  78. distance = Math.abs(curX - endX) + Math.abs(curY - endY) + Math.abs(curZ - endZ);
  79. if (count > 120) {
  80. break;
  81. }
  82. final boolean next = false;
  83. final double diffX = curX - endX;
  84. final double diffY = curY - endY;
  85. final double diffZ = curZ - endZ;
  86. final double offset = ((count & 0x1) == 0x0) ? 0.4 : 0.1;
  87. if (diffX < 0.0) {
  88. if (Math.abs(diffX) > offset) {
  89. curX += offset;
  90. }
  91. else {
  92. curX += Math.abs(diffX);
  93. }
  94. }
  95. if (diffX > 0.0) {
  96. if (Math.abs(diffX) > offset) {
  97. curX -= offset;
  98. }
  99. else {
  100. curX -= Math.abs(diffX);
  101. }
  102. }
  103. if (diffY < 0.0) {
  104. if (Math.abs(diffY) > 0.25) {
  105. curY += 0.25;
  106. }
  107. else {
  108. curY += Math.abs(diffY);
  109. }
  110. }
  111. if (diffY > 0.0) {
  112. if (Math.abs(diffY) > 0.25) {
  113. curY -= 0.25;
  114. }
  115. else {
  116. curY -= Math.abs(diffY);
  117. }
  118. }
  119. if (diffZ < 0.0) {
  120. if (Math.abs(diffZ) > offset) {
  121. curZ += offset;
  122. }
  123. else {
  124. curZ += Math.abs(diffZ);
  125. }
  126. }
  127. if (diffZ > 0.0) {
  128. if (Math.abs(diffZ) > offset) {
  129. curZ -= offset;
  130. }
  131. else {
  132. curZ -= Math.abs(diffZ);
  133. }
  134. }
  135. Minecraft.thePlayer.setPosition(curX, curY, curZ);
  136. ++count;
  137. }
  138. }
  139.  
  140. public static double round(final double value, final int places) {
  141. if (places < 0) {
  142. throw new IllegalArgumentException();
  143. }
  144. BigDecimal bd = new BigDecimal(value);
  145. bd = bd.setScale(places, RoundingMode.HALF_UP);
  146. return bd.doubleValue();
  147. }
  148.  
  149. private void setPosition(final double x, final double y, final double z) {
  150. Minecraft.thePlayer.setPosition(x, y, z);
  151. this.mc.getNetHandler().addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(x, y, z, true));
  152. }
  153.  
  154. public boolean shouldSprint() {
  155. final boolean hasFood = Minecraft.thePlayer.getFoodStats().getFoodLevel() > 6;
  156. final boolean isNotCollided = !Minecraft.thePlayer.isCollidedHorizontally;
  157. final boolean isMoving = Minecraft.thePlayer.motionX != 0.0 || Minecraft.thePlayer.motionZ != 0.0;
  158. final boolean isSneaking = !Minecraft.thePlayer.isSneaking();
  159. return hasFood && isSneaking && isNotCollided && isMoving;
  160. }
  161.  
  162. public boolean shouldStep() {
  163. final boolean isCollided = Minecraft.thePlayer.isCollidedHorizontally;
  164. final boolean onGround = Minecraft.thePlayer.onGround;
  165. final boolean onLadder = !Minecraft.thePlayer.isOnLadder();
  166. final boolean isInWater = !Minecraft.thePlayer.isInWater();
  167. return isCollided && onLadder && isInWater && onGround;
  168. }
  169.  
  170. public boolean isInLiquid() {
  171. Minecraft.getMinecraft();
  172. int x = MathHelper.floor_double(Minecraft.thePlayer.boundingBox.minX);
  173. Label_0129: {
  174. break Label_0129;
  175. int i;
  176. do {
  177. Minecraft.getMinecraft();
  178. int z = MathHelper.floor_double(Minecraft.thePlayer.boundingBox.minZ);
  179. Label_0104: {
  180. break Label_0104;
  181. int j;
  182. do {
  183. final int x2 = x;
  184. Minecraft.getMinecraft();
  185. final BlockPos pos = new BlockPos(x2, (int)Minecraft.thePlayer.boundingBox.minY, z);
  186. Minecraft.getMinecraft();
  187. final Block block = Minecraft.theWorld.getBlockState(pos).getBlock();
  188. if (block != null && !(block instanceof BlockAir)) {
  189. return block instanceof BlockLiquid;
  190. }
  191. ++z;
  192. j = z;
  193. Minecraft.getMinecraft();
  194. } while (j < MathHelper.floor_double(Minecraft.thePlayer.boundingBox.maxZ) + 1);
  195. }
  196. ++x;
  197. i = x;
  198. Minecraft.getMinecraft();
  199. } while (i < MathHelper.floor_double(Minecraft.thePlayer.boundingBox.maxX) + 1);
  200. }
  201. return false;
  202. }
  203.  
  204. public boolean isOnAir() {
  205. Minecraft.getMinecraft();
  206. int x = MathHelper.floor_double(Minecraft.thePlayer.boundingBox.minX);
  207. Label_0109: {
  208. break Label_0109;
  209. int i;
  210. do {
  211. Minecraft.getMinecraft();
  212. final int floor_double;
  213. final int z = floor_double = MathHelper.floor_double(Minecraft.thePlayer.boundingBox.minZ);
  214. Minecraft.getMinecraft();
  215. if (floor_double < MathHelper.floor_double(Minecraft.thePlayer.boundingBox.maxZ) + 1) {
  216. final int x2 = x;
  217. Minecraft.getMinecraft();
  218. final BlockPos pos = new BlockPos(x2, (int)Minecraft.thePlayer.posY - 1, z);
  219. Minecraft.getMinecraft();
  220. final Block block = Minecraft.theWorld.getBlockState(pos).getBlock();
  221. return block instanceof BlockAir;
  222. }
  223. ++x;
  224. i = x;
  225. Minecraft.getMinecraft();
  226. } while (i < MathHelper.floor_double(Minecraft.thePlayer.boundingBox.maxX) + 1);
  227. }
  228. return false;
  229. }
  230.  
  231. public int blocksUnderPlayer(final double posX, final double posY, final double posZ) {
  232. int height = 0;
  233. Minecraft.getMinecraft();
  234. int x = MathHelper.floor_double(Minecraft.thePlayer.boundingBox.minX);
  235. Label_0131: {
  236. break Label_0131;
  237. int i;
  238. do {
  239. Minecraft.getMinecraft();
  240. int z = MathHelper.floor_double(Minecraft.thePlayer.boundingBox.minZ);
  241. Label_0105: {
  242. break Label_0105;
  243. int j;
  244. do {
  245. final int x2 = x;
  246. Minecraft.getMinecraft();
  247. final BlockPos pos = new BlockPos(x2, (int)Minecraft.thePlayer.posY - height, z);
  248. Minecraft.getMinecraft();
  249. final Block block = Minecraft.theWorld.getBlockState(pos).getBlock();
  250. if (block instanceof BlockAir) {
  251. ++height;
  252. }
  253. ++z;
  254. j = z;
  255. Minecraft.getMinecraft();
  256. } while (j < MathHelper.floor_double(Minecraft.thePlayer.boundingBox.maxZ) + 1);
  257. }
  258. ++x;
  259. i = x;
  260. Minecraft.getMinecraft();
  261. } while (i < MathHelper.floor_double(Minecraft.thePlayer.boundingBox.maxX) + 1);
  262. }
  263. return height;
  264. }
  265.  
  266. public boolean isOnLiquidOld() {
  267. Minecraft.getMinecraft();
  268. int x = MathHelper.floor_double(Minecraft.thePlayer.boundingBox.minX);
  269. Label_0109: {
  270. break Label_0109;
  271. int i;
  272. do {
  273. Minecraft.getMinecraft();
  274. final int floor_double;
  275. final int z = floor_double = MathHelper.floor_double(Minecraft.thePlayer.boundingBox.minZ);
  276. Minecraft.getMinecraft();
  277. if (floor_double < MathHelper.floor_double(Minecraft.thePlayer.boundingBox.maxZ) + 1) {
  278. final int x2 = x;
  279. Minecraft.getMinecraft();
  280. final BlockPos pos = new BlockPos(x2, (int)Minecraft.thePlayer.posY - 1, z);
  281. Minecraft.getMinecraft();
  282. final Block block = Minecraft.theWorld.getBlockState(pos).getBlock();
  283. return block instanceof BlockLiquid;
  284. }
  285. ++x;
  286. i = x;
  287. Minecraft.getMinecraft();
  288. } while (i < MathHelper.floor_double(Minecraft.thePlayer.boundingBox.maxX) + 1);
  289. }
  290. return false;
  291. }
  292.  
  293. public boolean isOnLiquid() {
  294. Minecraft.getMinecraft();
  295. final AxisAlignedBB par1AxisAlignedBB = Minecraft.thePlayer.boundingBox.offset(0.0, -0.01, 0.0).contract(0.001, 0.001, 0.001);
  296. int var4 = MathHelper.floor_double(par1AxisAlignedBB.minX);
  297. final int var5 = MathHelper.floor_double(par1AxisAlignedBB.maxX + 1.0);
  298. final int var6 = MathHelper.floor_double(par1AxisAlignedBB.minY);
  299. var4 = MathHelper.floor_double(par1AxisAlignedBB.maxY + 1.0);
  300. final int var7 = MathHelper.floor_double(par1AxisAlignedBB.minZ);
  301. final int var8 = MathHelper.floor_double(par1AxisAlignedBB.maxZ + 1.0);
  302. final Vec3 var9 = new Vec3(0.0, 0.0, 0.0);
  303. for (int var10 = var4; var10 < var5; ++var10) {
  304. for (int var11 = var6; var11 < var4; ++var11) {
  305. for (int var12 = var7; var12 < var8; ++var12) {
  306. Minecraft.getMinecraft();
  307. final Block var13 = (Block)Minecraft.theWorld.getBlockState(new BlockPos(var10, var11, var12));
  308. if (!(var13 instanceof BlockAir) && !(var13 instanceof BlockLiquid)) {
  309. return false;
  310. }
  311. }
  312. }
  313. }
  314. return true;
  315. }
  316. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement