Skip to content

Commit 9687cd4

Browse files
committed
feat(display): custom gui example
1 parent 59c3700 commit 9687cd4

File tree

6 files changed

+679
-19
lines changed

6 files changed

+679
-19
lines changed

content/docs/lynx/latest/modules/display/display.mdx

Lines changed: 145 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,33 @@ val display = BlockDisplay(spawnLocation)
5050
display.sendMetaDataUpdate();
5151
```
5252

53+
## Billboard
54+
55+
Display allow you to modify the way they rotation. This is called `Billboard`:
56+
57+
| Name | Example |
58+
|------------|-----------------------------------------------------------------------------------------|
59+
| FIXED | ![Fixed](https://cdn.undefinedcreations.com/lynx/display/billboard-fixed.gif) |
60+
| VERTICAL | ![Vertical](https://cdn.undefinedcreations.com/lynx/display/billboard-vertical.gif) |
61+
| HORIZONTAL | ![Horizontal](https://cdn.undefinedcreations.com/lynx/display/billboard-horizontal.gif) |
62+
| CENTER | ![Center](https://cdn.undefinedcreations.com/lynx/display/billboard-center.gif) |
63+
64+
Here is how you can modify them:
65+
66+
```java tab="Java"
67+
Display display = new TextDisplay(spawnLocation);
68+
display.setBillboard(Display.Billbaord.CENTER)
69+
```
70+
```kotlin tab="Kotlin"
71+
val display = TextDisplay(spawnLocation);
72+
display.setBillboard(Display.Billbaord.CENTER)
73+
```
74+
5375
## Transformation
5476

5577
Display entities using something called `transformation` to be able to do some cool movements.
5678

57-
<Callout title="info">
79+
<Callout title="Tip">
5880
When using `transformation` and you want to see how it will look check out [this cool site](https://misode.github.io/transformation/)
5981
</Callout>
6082

@@ -160,24 +182,129 @@ val display = BlockDisplay(spawnLocation)
160182
display.setInterpolationDelat(20)
161183
```
162184

163-
## Billboard
164185

165-
Display allow you to modify the way they rotation. This is called `Billboard`:
186+
# Implementation
166187

167-
| Name | Example |
168-
|------------|-----------------------------------------------------------------------------------------|
169-
| FIXED | ![Fixed](https://cdn.undefinedcreations.com/lynx/display/billboard-fixed.gif) |
170-
| VERTICAL | ![Vertical](https://cdn.undefinedcreations.com/lynx/display/billboard-vertical.gif) |
171-
| HORIZONTAL | ![Horizontal](https://cdn.undefinedcreations.com/lynx/display/billboard-horizontal.gif) |
172-
| CENTER | ![Center](https://cdn.undefinedcreations.com/lynx/display/billboard-center.gif) |
188+
## TextDisplay
173189

174-
Here is how you can modify them:
190+
TextDisplay is a type of display entity that can display text. This can be useful to display information to the player.
175191

176-
```java tab="Java"
177-
Display display = new TextDisplay(spawnLocation);
178-
display.setBillboard(Display.Billbaord.CENTER)
179-
```
180-
```kotlin tab="Kotlin"
181-
val display = TextDisplay(spawnLocation);
182-
display.setBillboard(Display.Billbaord.CENTER)
183-
```
192+
### Text
193+
194+
There is two ways you can set the text of the entity. The default one is by using a `String` but you can also use an adventure `Component`:
195+
196+
<Tabs items={["Java", "Kotlin"]}>
197+
<Tab value="Java">
198+
```java tab="String"
199+
TextDisplay display = new TextDisplay(spawnLocation);
200+
display.setText("Cool Text");
201+
```
202+
```java tab="Component"
203+
TextDisplay display = new TextDisplay(spawnLocation);
204+
display.setText(Component.text("Cool Text"));
205+
```
206+
</Tab>
207+
<Tab value="Kotlin">
208+
```kotlin tab="String"
209+
val display = TextDisplay(spawnLocation)
210+
display.setText("Cool Text")
211+
```
212+
```kotlin tab="Component"
213+
val display = TextDisplay(spawnLocation)
214+
display.setText(Component.text("Cool Text"))
215+
```
216+
</Tab>
217+
</Tabs>
218+
219+
### Background Color
220+
221+
When setting the background color of a display entity there are two ways of doing it. The first is by using the bukkit `Color`. The next option is using the `ARGB` value.
222+
223+
<Callout title="Information">
224+
If you want a transparent background you can set the `ARBG` value to `0`
225+
</Callout>
226+
227+
<Tabs items={["Java", "Kotlin"]}>
228+
<Tab value="Java">
229+
```java tab="Color"
230+
TextDisplay display = new TextDisplay(spawnLocation);
231+
display.setBackgroundColor(Color.RED);
232+
```
233+
```java tab="ARBG"
234+
TextDisplay display = new TextDisplay(spawnLocation);
235+
display.setBackgroundColor(0);
236+
```
237+
</Tab>
238+
<Tab value="Kotlin">
239+
```java tab="Color"
240+
val display = TextDisplay(spawnLocation)
241+
display.setBackgroundColor(Color.RED)
242+
```
243+
```java tab="ARBG"
244+
val display = TextDisplay(spawnLocation)
245+
display.setBackgroundColor(0)
246+
```
247+
</Tab>
248+
</Tabs>
249+
250+
## Block Display
251+
252+
Next we have block displays. These are used to display blocks.
253+
254+
### Block
255+
256+
There are two ways of setting the block that is being displayed. First you can use `Material` enum, second you can use `BlockData`:
257+
258+
<Tabs items={["Java", "Kotlin"]}>
259+
<Tab value="Java">
260+
```java tab="Material"
261+
BlockDisplay display = new BlockDisplay(spawnLocation);
262+
display.setBlock(Material.STONE);
263+
```
264+
```java tab="BlockData"
265+
BlockDisplay display = new BlockDisplay(spawnLocation);
266+
display.setBlock(Material.STONE.createBlockData());
267+
```
268+
</Tab>
269+
<Tab value="Kotlin">
270+
```java tab="Material"
271+
val display = BlockDisplay(spawnLocation)
272+
display.setBlock(Material.STONE)
273+
```
274+
```java tab="BlockData"
275+
val display = BlockDisplay(spawnLocation)
276+
display.setBlock(Material.STONE.createBlockData())
277+
```
278+
</Tab>
279+
</Tabs>
280+
281+
## Item Display
282+
283+
Lastly we have Item Displays. These display `ItemStacks`
284+
285+
### Item
286+
287+
There are two ways for setting the item that needs to be displayed. First by using `ItemStack`, second you can use `Material` enum:
288+
289+
<Tabs items={["Java", "Kotlin"]}>
290+
<Tab value="Java">
291+
```java tab="ItemStack"
292+
ItemDisplay display = new ItemDisplay(spawnLocation);
293+
display.setItem(new ItemStack(Material.STONE));
294+
```
295+
```java tab="Material"
296+
ItemDisplay display = new ItemDisplay(spawnLocation);
297+
display.setItem(Material.STONE);
298+
```
299+
</Tab>
300+
<Tab value="Kotlin">
301+
```java tab="ItemStack"
302+
val display = ItemDisplay(spawnLocation)
303+
display.setItem(ItemStack(Material.STONE))
304+
```
305+
```java tab="Material"
306+
val display = ItemDisplay(spawnLocation)
307+
display.setItem(Material.STONE)
308+
```
309+
</Tab>
310+
</Tabs>

0 commit comments

Comments
 (0)