Skip to content
ColonelHedgehog edited this page Jan 27, 2015 · 1 revision

Coordinates

How coordinates work

Coordinates are very similar to Bukkit's Location class. You specify the Menu, X, and Y values.

Menu

Think of the Menu like the World in a Location. Remember, when comparing Coordinates with different menu values, you might get an exception. Never create a new Menu just for coordinates!

Also see: Menu.

X

X is an int variable. This is how many spaces from the top left to the top right your object is at. Refer to the diagram below.

Y

Same as X, except this is how many spaces from the top left to the bottom left your object is at. Coupled with X, this forms a location. Refer to the diagram below.

Diagram

This is an example of a 9 x 6 (54-slot) inventory. Like all inventories, the X max is always constant. The Y max may vary from size to size.

Reference

Initializers

Type A

Coordinates(Menu menu, int x, int y);

menu: The menu acociated with the coordinates. x: The X position, from the top left to top right. Minimum value is 1, maximum value is 9. y: The Y position, from the top left to the bottom left. Minimum value is 1, maximum value will depend on the size of the inventory. You can figure out the maximum size by using this equasion: inventorysize / 9

Type B

Coordinates(Menu menu, int slot);

menu: The menu acociated with the coordinates. slot: The inventory slot number. Ranges from 0 to the size of the inventory minus 1.

Methods

getX();

Return type: int
Modifiers: public

Returns the X coordinate.

getY();

Return type: int
Modifiers: public

Returns the Y coordinate.

getMenu();

Return type: Menu
Modifiers: public

Returns the Menu that the coordinates are mapped on.

asSlotNumber();

Return type: int
Modifiers: public

Converts the X and Y coordinates into an inventory index/slot number.

Clone this wiki locally