Skip to content

Commit 529b0e2

Browse files
authored
docs: custom items and item positioning
1 parent 6af7573 commit 529b0e2

File tree

6 files changed

+152
-12
lines changed

6 files changed

+152
-12
lines changed
14.7 KB
Loading
9.01 KB
Loading
12.9 KB
Loading

docs/assets/positioning/row-1.png

12.9 KB
Loading

docs/assets/positioning/skip-1.png

8.18 KB
Loading

docs/shop.md

Lines changed: 152 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Shop
22

3-
Screaming BedWars plugin uses our own lib called SimpleInventories to create and render inventory-based guis, and therefore shops. This article will show you some basics of this format. Check [this wiki](https://github.com/ScreamingSandals/SimpleInventories/wiki) for more advanced variables.
3+
The Screaming BedWars plugin uses our custom library, **SimpleInventories**, to create and render inventory-based GUIs, including shops. This article covers the basics of the shop item format. For more advanced features, see the [SimpleInventories Wiki](https://github.com/ScreamingSandals/SimpleInventories/wiki).
44

55
## Creating a new item
66

7-
To create a new item, first you need to know internal item's name. You can use [Minecraft Wiki](https://minecraft.wiki) to get the specific resource name. The name usually starts with `minecraft:`, this part can be omitted from the final name.
7+
To create a new item, you need to know the item's internal name. You can look it up on the [Minecraft Wiki](https://minecraft.wiki). The name usually starts with `minecraft:`, but this prefix can be omitted.
88

9-
You can also use modern names in legacy environments (1.8.8-1.12.2). If the modern name does not work, check [this page](https://helpch.at/docs/1.12.2/org/bukkit/Material.html) for old names. Old names are deprecated and they may not be supported in future releases of BedWars.
9+
In legacy environments (1.8.81.12.2), you can also use modern names. If they don’t work, refer to [this page](https://helpch.at/docs/1.12.2/org/bukkit/Material.html) for old material names. Keep in mind that old names are deprecated and may not be supported in future BedWars releases.
1010

11-
There are two supported formats of items. We call them `short stack` and `long stack`.
11+
There are two supported formats for defining items: `short stack` and `long stack`.
1212

1313
### Using short stack
1414

15-
This format can describe only material name, amount, display name and lore. Except for material name, every part is optional. Each part is divided using semicolon.
15+
The short stack format supports only the material name, amount, display name, and lore. Except for the material, all parts are optional and separated by semicolons (`;`).
1616

1717
```yaml
1818
items:
@@ -22,7 +22,7 @@ items:
2222
- tnt;3;Trinitrotoluene;Does explode
2323
```
2424
25-
To specify price and make the item buyable, suffix this format with `for <amount> <resource>`:
25+
To make the item purchasable, add `for <amount> <resource>`:
2626

2727
```yaml
2828
items:
@@ -32,7 +32,7 @@ items:
3232
- tnt;3;Trinitrotoluene;Does explode for 9 iron
3333
```
3434

35-
In order to be able to specify other attributes (for example `properties`), we have to convert this from string to map. This is done by splitting the string into variables `stack` and `price`:
35+
In order to use additional attributes (like `properties` used for [Special items](specials.md)), simply convert the string format into a map with `stack` and `price` keys:
3636

3737
```yaml
3838
items:
@@ -48,7 +48,9 @@ items:
4848

4949
### Using long stack
5050

51-
Long stack allows you to create items with enchantments and other attributes. Let's see the previous example rewritten in this format:
51+
The long stack format allows full control over the item—enchantments, lore, display name, etc.
52+
53+
Let's see the previous example rewritten using long stacks:
5254

5355
```yaml
5456
items:
@@ -72,7 +74,7 @@ items:
7274
price: 9 iron
7375
```
7476

75-
As we can see, the `stack` attribute is now a map, which allows more attributes to be present. For example, we can enchant our Super Pickaxe with Fortune III.
77+
Now, let's enchant our Super Pickaxe with Fortune III.
7678

7779
```yaml
7880
- stack:
@@ -83,13 +85,13 @@ As we can see, the `stack` attribute is now a map, which allows more attributes
8385
price: 5 gold
8486
```
8587

86-
The enchantment names can be found [here](https://www.digminecraft.com/lists/enchantment_list_pc.php).
88+
For enchantment names, refer to [this list](https://www.digminecraft.com/lists/enchantment_list_pc.php).
8789

88-
For list of all available options visit [this page](https://github.com/ScreamingSandals/SimpleInventories/wiki/Variable:-stack).
90+
See [this page](https://github.com/ScreamingSandals/SimpleInventories/wiki/Variable:-stack) for a complete list of available options.
8991

9092
## Using item as a category
9193

92-
You can use any item as a category (even if the item is in another category). Players can then click on that item to open the category. The format is very similar, the only thing you have to specify is a list called `items`, where you put items of that specific category. Format of items in `items` is same as format in the base `data` list.
94+
You can use any item as a category entry (even if the item is in another category). When players click the item, it opens the corresponding subcategory. This is simply done by adding a new list to our item called `items`. The format of `items` inside a category is the same as in the base `data` list.
9395

9496
```yaml
9597
- stack:
@@ -101,3 +103,141 @@ You can use any item as a category (even if the item is in another category). Pl
101103
- wooden_pickaxe for 10 gold
102104
- golden_pickaxe for 20 gold
103105
```
106+
107+
## Custom items
108+
109+
Sometimes, you may want to sell items that cannot be represented with long stack options alone. In such cases, use the `tag` field to define additional item data using SNBT (stringified NBT) format.
110+
111+
Example:
112+
113+
```yaml
114+
- stack:
115+
type: diamond_pickaxe
116+
tag: '{Enchantments:[{lvl:3,id:fortune}]}'
117+
```
118+
119+
This creates a diamond pickaxe with Fortune III. Keep in mind the tag format depends on the Minecraft version.
120+
121+
### Tag in newer versions
122+
123+
Since Minecraft 1.20.5, item data uses the new data components format. Here's how the same pickaxe would be defined in Minecraft 1.21.4:
124+
125+
```yaml
126+
- stack:
127+
type: diamond_pickaxe
128+
tag: '{enchantments:{levels:{fortune:3}}}'
129+
```
130+
131+
Note that this SNBT format required by `tag` differs slightly from the command format nowadays used in-game:
132+
133+
```
134+
/give @a diamond_pickaxe[enchantments={levels:{fortune:3}}]
135+
```
136+
137+
To convert such a command into valid tag format:
138+
139+
1. Extract the bracketed part:
140+
```
141+
[enchantments={levels:{fortune:3}}]
142+
```
143+
2. Replace `[` at the beginning with `{` and `]` at the end with `}`:
144+
```
145+
{enchantments={levels:{fortune:3}}}
146+
```
147+
3. Replace all top-level `=` signs with `:`:
148+
```snbt
149+
{enchantments:{levels:{fortune:3}}}
150+
```
151+
152+
Now you've got a valid value for the `tag` key.
153+
154+
### Upgrading items with tag
155+
156+
Because tags are version-specific, upgrading the server may break older tags. Since Screaming BedWars 0.2.27, you can add a `DataVersion` field to let the game upgrade the tag:
157+
158+
```yaml
159+
- stack:
160+
type: diamond_pickaxe
161+
DataVersion: 1343
162+
tag: '{Enchantments:[{lvl:3,id:fortune}]}'
163+
```
164+
165+
Here, `1343` is the data version for Minecraft `1.12.2`. The tag will be upgraded when having server on newer versions everytime the server is loaded. The file itself remains unchanged.
166+
167+
You can find Minecraft data versions on [this wiki page](https://minecraft.wiki/w/Data_version).
168+
169+
## Item Positioning
170+
171+
By default, items are rendered in order from left to right, top to bottom. However, SimpleInventories (and therefore Screaming BedWars) allows you to control the layout using positioning directives. These can help with alignment, spacing, and organizing items into rows, columns, or even multiple pages.
172+
173+
### `skip`
174+
175+
Skips a number of slots before placing the next item.
176+
177+
```yaml
178+
- stack: chest for 1 bronze
179+
skip: 3
180+
```
181+
182+
![Showcase of skip](assets/positioning/skip-1.png)
183+
184+
### `column` and `row`
185+
186+
Use these to place an item in a specific column or row. `column` starts from `0`, while `row` starts from `1`.
187+
For `column`, you can also use special values: `left`, `center`, and `right` instead of a number.
188+
189+
```yaml
190+
- stack: iron_block for 10 gold
191+
column: 1
192+
- stack: glowstone for 5 iron
193+
row: 4
194+
column: center
195+
```
196+
197+
![Showcase of column](assets/positioning/column-1.png)
198+
199+
![Showcase of row](assets/positioning/row-1.png)
200+
201+
### `linebreak`
202+
203+
Forces the next item to be placed on a new row. Think of it as pressing "Enter" after an item.
204+
205+
There are three valid values for `linebreak`:
206+
* `before` - Breaks the line before the item is rendered
207+
* `after` - Breaks the line after the item is rendered
208+
* `both` - Applies both `before` and `after`
209+
210+
```yaml
211+
- stack: ender_chest for 5 iron
212+
linebreak: before
213+
```
214+
215+
![Showcase of linebreak](assets/positioning/linebreak-1.png)
216+
217+
### `pagebreak`
218+
219+
Forces the next item to be placed on a new page.
220+
221+
Like `linebreak`, `pagebreak` accepts three values:
222+
* `before` - Breaks the page before the item is rendered
223+
* `after` - Breaks the page after the item is rendered
224+
* `both` - Applies both `before` and `after`
225+
226+
```yaml
227+
- stack: gunpowder for 5 iron
228+
pagebreak: before
229+
row: 3
230+
```
231+
232+
![Showcase of pagebreak](assets/positioning/pagebreak-1.png)
233+
234+
### absolute (not recommended)
235+
236+
Places an item at an exact slot index (starting from `0`). This bypasses all automatic positioning logic and should only be used if you need full manual control.
237+
238+
```yaml
239+
- stack: obsidian for 20 gold
240+
absolute: 13
241+
```
242+
243+
This can make layouts harder to maintain and **is not recommended** unless absolutely necessary.

0 commit comments

Comments
 (0)