fork download
  1. //https://b...content-available-to-author-only...g.com/browse/MC-52274
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. System.out.println("Coord\tOffset\tVanilla\tFixed");
  6.  
  7. offsetText(2, 1);
  8. offsetText(1.5, 1);
  9. offsetText(1, 1);
  10. offsetText(0.5, 1);
  11. offsetText(0, 1);
  12. offsetText(-.5, 1);
  13. offsetText(-1, 1);
  14. offsetText(-1.5, 1);
  15. offsetText(-2, 1);
  16. offsetText(2, 0);
  17. offsetText(1.5, 0);
  18. offsetText(1, 0);
  19. offsetText(0.5, 0);
  20. offsetText(0, 0);
  21. offsetText(-.5, 0);
  22. offsetText(-1, 0);
  23. offsetText(-1.5, 0);
  24. offsetText(-2, 0);
  25. offsetText(2, -1);
  26. offsetText(1.5, -1);
  27. offsetText(1, -1);
  28. offsetText(0.5, -1);
  29. offsetText(0, -1);
  30. offsetText(-.5, -1);
  31. offsetText(-1, -1);
  32. offsetText(-1.5, -1);
  33. offsetText(-2, -1);
  34. }
  35.  
  36. /**
  37. * Prints info about the given offset attempt.
  38. */
  39. public static void offsetText(double coord, int offset) {
  40. System.out.println(coord + "\t" + offset + "\t" +
  41. getOffsetPosVanilla(coord, offset) + "\t" +
  42. getOffsetPosFixed(coord, offset));
  43. }
  44.  
  45. /**
  46. * Current implementation
  47. */
  48. public static int getOffsetPosVanilla(double coord, int offset) {
  49. return (int)(coord + (double)offset);
  50. }
  51.  
  52. /**
  53. * Fixed implementation
  54. */
  55. public static int getOffsetPosFixed(double coord, int offset) {
  56. return floorDouble(coord + offset);
  57. }
  58.  
  59. /**
  60. * net.minecraft.util.MathHelper's floor_double method, for utility purposes
  61. */
  62. public static int floorDouble(double p_76128_0_) {
  63. int var2 = (int)p_76128_0_;
  64. return p_76128_0_ < (double)var2 ? var2 - 1 : var2;
  65. }
  66. }
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
Coord	Offset	Vanilla	Fixed
2.0	1	3	3
1.5	1	2	2
1.0	1	2	2
0.5	1	1	1
0.0	1	1	1
-0.5	1	0	0
-1.0	1	0	0
-1.5	1	0	-1
-2.0	1	-1	-1
2.0	0	2	2
1.5	0	1	1
1.0	0	1	1
0.5	0	0	0
0.0	0	0	0
-0.5	0	0	-1
-1.0	0	-1	-1
-1.5	0	-1	-2
-2.0	0	-2	-2
2.0	-1	1	1
1.5	-1	0	0
1.0	-1	0	0
0.5	-1	0	-1
0.0	-1	-1	-1
-0.5	-1	-1	-2
-1.0	-1	-2	-2
-1.5	-1	-2	-3
-2.0	-1	-3	-3