Location.java 1.5 KB

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