Location.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package me.km.api;
  2. import net.minecraft.block.state.IBlockState;
  3. import net.minecraft.util.math.BlockPos;
  4. import net.minecraft.util.math.Vec3d;
  5. import net.minecraft.world.World;
  6. public class Location
  7. {
  8. private final World w;
  9. private final Vec3d pos;
  10. private float yaw;
  11. private float pitch;
  12. public Location(World w, Vec3d pos, float yaw, float pitch)
  13. {
  14. this.w = w;
  15. this.pos = pos;
  16. this.yaw = yaw;
  17. this.pitch = pitch;
  18. }
  19. public Location(World w, Vec3d pos)
  20. {
  21. this(w, pos, 0, 0);
  22. }
  23. public Location(World w, BlockPos pos, float yaw, float pitch)
  24. {
  25. this(w, new Vec3d(pos.getX(), pos.getY(), pos.getZ()), yaw, pitch);
  26. }
  27. public Location(World w, BlockPos pos)
  28. {
  29. this(w, pos, 0, 0);
  30. }
  31. public World getWorld()
  32. {
  33. return w;
  34. }
  35. public Vec3d getPos()
  36. {
  37. return pos;
  38. }
  39. public float getYaw()
  40. {
  41. return yaw;
  42. }
  43. public float getPitch()
  44. {
  45. return pitch;
  46. }
  47. public void setPitch(float pitch)
  48. {
  49. this.pitch = pitch;
  50. }
  51. public void setYaw(float yaw)
  52. {
  53. this.yaw = yaw;
  54. }
  55. public static IBlockState getRelativeBlock(World w, BlockPos pos, int x, int y, int z)
  56. {
  57. return w.getBlockState(pos.add(x, y, z));
  58. }
  59. }