Is there an object which contains the World, Location and Direction information?

Bukkit stores direction, location and the world all in one class.
Is there a similar object within the API I could use, or will I have to utilize my own?

1 Like

This doesn’t store the Direction or World.

Check again, buddy. Location includes both the Extent and the Vector(s).

1 Like

It does not store the direction (rotation), though.

1 Like

Vector3d IS rotation.

That’s not what I want.

I’m not sure what it is you want.

From the Location class, you can get the World (Extent) and the Direction (Vector3d). What am I missing, here?

No, you get the World (Extent) and the X, Y, Z coordinates. You do not get the direction…

1 Like

Locations don’t have a direction, however Players do, player.getRotation()

Vector3d is not created by Sponge. The way they utilize it, however, gives the direction. Read the Javadocs, in my last post.

Locations can have a direction/rotation.

Yes, Vector3d can represent direction, but in the Location class, it doesn’t.

1 Like

Then, in the Location class, what does it represent? You can get the block location, but according to the javadocs with Vector3d, it just says Get the underlying location, which, admittedly, doesn’t explain much.

The vector represents the x y z coords, the extent is the world.

1 Like


@FerusGrim why did you block me on skype dude? I wasn’t being harsh, you was telling me to read the docs which I clearly had done. I understand the Entity class holds the information, but that’s not what I’m looking for…

Try using Direction.getClosest(entity.getRotation()) to get the closest horizontal direction and to convert it back to Vector3, use toVector3d(). Not tested.

You can also use Quaternoid but I highly doubt that’s what you want.

Lmao, that’s not even close. The reason I want it for is probably stupid.

I want one class, maybe called ‘SpawnLocation’ which stores the World UUID, Location coordinates and the Direction values. I want it so I can just go ahead and Serialize the SpawnLocation object, as well as instantiate it from the serialization automagically using Gson. haha, that’s all I want it for :stuck_out_tongue:

Back to your question: Just create your own class that stores the location and the rotation.

Okay, I really wish sponge stored this :’(

What you are wanting is typically thought of as Transform.

Transform would comprise the Location, Rotation (Direction or Quaternion or Vector3d or etc) and sometimes a scale.

I may consider adding something like it to the API for entities.