-
Notifications
You must be signed in to change notification settings - Fork 89
Static Pane
Languages: Dutch (Nederlands)
A static Pane is a pane which allows you to add items in a specific position, relative to the pane. It's the easiest pane there is and it's very similar to how you would normally add items to an inventory. Just specify the item and the position and you're done.
You can create a Static Pane simply by calling the constructor for it:
StaticPane pane = new StaticPane(0, 0, 9, 6);
To add items to the pane, simply call addItem with the desired item and the position in the pane:
pane.addItem(new GuiItem(new ItemStack(Material.STONE)), 0, 0);
This adds a block of stone in the top-left corner of the pane. Do note that every position is relative to the pane, so if your pane is at position (1,1) and your item is at position (0,0), your item will ultimately end up in position (1,1). If you want to know exactly how GUI items work, check the GUI Item page.
You can fill the entire pane by using the fillWith
method. This will fill every empty spot with the specified ItemStack.
You can also flip the items in the pane horizontally or vertically or both at the same time. When flipping the items horizontally all items are moved along the x-axis and when flipping the items vertically all items are moved along the y-axis. You can flip the pane horizontally and vertically respectively as follows:
pane.flipHorizontally(true);
pane.flipVertically(true);
Last thing you can do with this pane is set its rotation. There are four different rotations; 0, 90, 180, 270. These rotations are in degrees. Every rotation that is or exceeds 360 will be trimmed to fall into the bounds [0,360) (e.g. 540 becomes 180). Only panes which have the same length as height can use the rotation (this is due to how two dimensional rotations on a grid work). Each rotation is applied clockwise, if you want a counter-clockwise rotation, you'll have to calculate the amount of degrees the pane would be rotated if you went clockwise. You can set the rotation as follows:
pane.setRotation(90);
Everything shown at Panes can be used on the Static Pane as well.
The element name for a Static Pane is staticpane
so use that when you want a Static Pane inside your XML file.
<staticpane x="0" y="0" length="9" height="6"/>
You can flip the pane horizontally and/or vertically by adding the following attributes to your pane:
<staticpane x="0" y="0" length="9" height="6" flipHorizontally="true"/>
<staticpane x="0" y="0" length="9" height="6" flipVertically="true"/>
You can also set another optional attribute which is the rotation. If you want to rotate the pane, you can set the rotate
attribute to the amount of degrees you'd like the pane to be rotated. By default the pane has no rotation (0 degrees).
<staticpane x="0" y="0" length="9" height="6" rotate="90"/>