Advertisement
Guest User

Nullpointerexception

a guest
Oct 20th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. velocity = new Vector(0,0,0);
  2. Vector finalVector;
  3. Location newBlockLocation = null;
  4. Block skylineBlock;
  5. World playerWorld = player.getWorld();
  6.  
  7. while (!(player.isSneaking())) {
  8.  
  9. Location skylinePosition;
  10. Location skylinePositionM;
  11. playerLocation = player.getLocation();
  12.  
  13. if (newBlockLocation == null) {
  14. newBlockLocation = blockLocation;
  15. } else {
  16. newBlockLocation = playerLocation.clone().add(0, 2, 0);
  17. }
  18.  
  19. int vX = velocity.getBlockX();
  20. int vZ = velocity.getBlockZ();
  21. finalVector = null;
  22.  
  23. if (vX == 0 && vZ == 0) {
  24. player.sendMessage(ChatColor.YELLOW + "Boucle 1");
  25. skylinePosition = newBlockLocation.clone().add(-1, -1, -1);
  26. skylinePositionM = newBlockLocation.clone().add(1,1,1);
  27. int xM = skylinePositionM.getBlockX();
  28. for (int x=skylinePosition.getBlockX();x<=xM;x++) {
  29. int yM = skylinePositionM.getBlockY();
  30. player.sendMessage(ChatColor.YELLOW + "for x = " + x);
  31. for (int y=skylinePosition.getBlockY();y<=yM;y++) {
  32. int zM = skylinePositionM.getBlockZ();
  33. player.sendMessage(ChatColor.YELLOW + "for y = " + y);
  34. for (int z=skylinePosition.getBlockZ();z<=zM;z++) {
  35. player.sendMessage(ChatColor.YELLOW + "for z = " + z);
  36. skylineBlock = playerWorld.getBlockAt(x,y,z);
  37. if (skylineBlock.getLocation() == newBlockLocation) {
  38.  
  39. } else
  40. if (items.contains(skylineBlock.getType())) {
  41. listLocation.add(skylineBlock.getLocation()); //DOESN'T WORK SHIT. (nullpointerexception)
  42. if (listLocation.size() == 2) {
  43. Vector vec1 = ((listLocation.get(0)).clone().subtract(skylinePosition)).toVector();
  44. Vector vec2 = ((listLocation.get(1)).clone().subtract(skylinePosition)).toVector();
  45.  
  46. if (vec1.angle(playerDir) <= Math.PI/2 || vec1.angle(playerDir) > -Math.PI/2) {
  47. finalVector = vec1;
  48. } else {
  49. finalVector = vec2;
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement