Skip to content

Commit 59c3700

Browse files
committed
feat(lynx): start on display entities
1 parent 7a4f358 commit 59c3700

File tree

4 files changed

+327
-21
lines changed

4 files changed

+327
-21
lines changed

content/docs/lynx/latest/getting-started/lynx-setup.mdx

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,61 @@ Here is a list of all the current modules:
2323

2424
First add the repository:
2525

26-
```groovy tab="Gradle Groovy DSL"
27-
maven {
28-
name = "undefined-repo"
29-
url = "https://repo.undefinedcreations.com/releases"
30-
}
31-
```
32-
```kotlin tab="Gradle Kotlin DSL"
33-
maven {
34-
name = "undefined-repo"
35-
url = uri("https://repo.undefinedcreations.com/releases")
36-
}
37-
```
38-
```xml tab="Maven"
39-
<repository>
40-
<id>lynx</id>
41-
<name>Lynx Repository</name>
42-
<url>https://repo.undefinedcreation.com/releases</url>
43-
</repository>
44-
```
26+
<Tabs items={["Releases", "Snapshots"]}>
27+
<Tab value="Releases">
28+
[![Latest Version](https://img.shields.io/badge/dynamic/xml?label=Latest%20Version&style=for-the-badge&logo=gradle&url=https%3A%2F%2Frepo.undefinedcreations.com%2Freleases%2Fcom%2Fundefined%2Flynx%2Fmaven-metadata.xml&query=%2F%2Fmetadata%2F%2Fversioning%2F%2Flatest)](https://github.com/UndefinedCreations/Lynx/releases)
29+
```groovy tab="Gradle Groovy DSL"
30+
maven {
31+
name = "undefined-repo"
32+
url = "https://repo.undefinedcreations.com/releases"
33+
}
34+
```
35+
```kotlin tab="Gradle Kotlin DSL"
36+
maven {
37+
name = "undefined-repo"
38+
url = uri("https://repo.undefinedcreations.com/releases")
39+
}
40+
```
41+
```xml tab="Maven"
42+
<repository>
43+
<id>lynx</id>
44+
<name>Lynx Repository</name>
45+
<url>https://repo.undefinedcreation.com/releases</url>
46+
</repository>
47+
```
48+
49+
50+
</Tab>
51+
<Tab value="Snapshots">
52+
53+
[![Latest Snapshot](https://img.shields.io/badge/dynamic/xml?label=Latest%20Version&style=for-the-badge&logo=gradle&url=https%3A%2F%2Frepo.undefinedcreations.com%2Fsnapshots%2Fcom%2Fundefined%2Flynx%2Fmaven-metadata.xml&query=%2F%2Fmetadata%2F%2Fversioning%2F%2Flatest)](https://github.com/UndefinedCreations/Lynx)
54+
55+
Lynx snapshots are version that aren't fully done and are created for testing uses.
56+
57+
```groovy tab="Gradle Groovy DSL"
58+
maven {
59+
name = "undefined-snapshots"
60+
url = "https://repo.undefinedcreations.com/snapshots"
61+
}
62+
```
63+
```kotlin tab="Gradle Kotlin DSL"
64+
maven {
65+
name = "undefined-snapshots"
66+
url = uri("https://repo.undefinedcreations.com/snapshots")
67+
}
68+
```
69+
```xml tab="Maven"
70+
<repository>
71+
<id>lynx-snapshots</id>
72+
<name>Lynx Repository</name>
73+
<url>https://repo.undefinedcreation.com/snapshots</url>
74+
</repository>
75+
```
76+
77+
</Tab>
78+
</Tabs>
79+
4580

46-
[![Latest Version](https://img.shields.io/badge/dynamic/xml?label=Latest%20Version&style=for-the-badge&logo=gradle&url=https%3A%2F%2Frepo.undefinedcreations.com%2Freleases%2Fcom%2Fundefined%2Flynx%2Fmaven-metadata.xml&query=%2F%2Fmetadata%2F%2Fversioning%2F%2Flatest)](https://github.com/UndefinedCreations/Lynx/releases)
4781

4882
Then add the library to your dependencies:
4983

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
title: Display
3+
---
4+
5+
All the three display entities are extensions of the [`Display`](https://github.com/UndefinedCreations/Lynx/blob/master/modules/display/src/main/kotlin/com/undefined/lynx/display/implementions/Display.kt) class.
6+
We will first look into this class and what methods it has.
7+
8+
# Display
9+
10+
## Teleportation
11+
12+
When moving the location of the display entity you will need to teleport it using `teleport(Location)`:
13+
14+
```java tab="Java"
15+
Display display = new BlockDisplay(spawnLocation);
16+
display.teleport(newLocation);
17+
```
18+
```kotlin tab="Kotlin"
19+
val display = BlockDisplay(spawnLocation)
20+
display.teleport(newLocation)
21+
```
22+
23+
### Teleportation Delay
24+
25+
<Callout title="info">
26+
This is only supported from version 1.20.2 up
27+
</Callout>
28+
29+
Teleportation delay will add a delay to when the teleportation happens in ticks:
30+
31+
```java tab="Java"
32+
Display display = new BlockDisplay(spawnLocation);
33+
display.setTeleportDelay(20);
34+
```
35+
```kotlin tab="Kotlin"
36+
val display = BlockDisplay(spawnLocation)
37+
display.setTeleportDelay(20)
38+
```
39+
40+
## Meta Data
41+
42+
Entity metadata is all the information of the entity. Some examples are `scale` and `translation`. By default, when modifying these it will send the modified metadata, but you are able to send them manually as well:
43+
44+
```java tab="Java"
45+
Display display = new BlockDisplay(spawnLocation);
46+
display.sendMetaDataUpdate();
47+
```
48+
```kotlin tab="Kotlin"
49+
val display = BlockDisplay(spawnLocation)
50+
display.sendMetaDataUpdate();
51+
```
52+
53+
## Transformation
54+
55+
Display entities using something called `transformation` to be able to do some cool movements.
56+
57+
<Callout title="info">
58+
When using `transformation` and you want to see how it will look check out [this cool site](https://misode.github.io/transformation/)
59+
</Callout>
60+
61+
### Scale
62+
63+
When setting the scale requires the new `x`, `y` and `z` scale. You can change the scale by setting all three manually or using a `Vector3f`:
64+
65+
<Tabs items={["Java", "Kotlin"]}>
66+
<Tab value="Java">
67+
```java tab="Simple"
68+
Display display = new BlockDisplay(spawnLocation);
69+
display.setScale(2f, 5f, 2.5f);
70+
```
71+
```java tab="Vector3f"
72+
Display display = new BlockDisplay(spawnLocation);
73+
display.setScale(new Vector3f(2f, 5f, 2.5f));
74+
```
75+
</Tab>
76+
<Tab value="Kotlin">
77+
```kotlin tab="Simple"
78+
val display = BlockDisplay(spawnLocation);
79+
display.setScale(2f, 5f, 2.5f);
80+
```
81+
```kotlin tab="Vector3f"
82+
val display = BlockDisplay(spawnLocation);
83+
display.setScale(Vector3f(2f, 5f, 2.5f));
84+
```
85+
</Tab>
86+
</Tabs>
87+
88+
### Rotation
89+
90+
Display entities have their own type of rotation separate from the location. They both have `leftRotation` and `rightRotation`. These rotations use `quaternionf`:
91+
92+
```java tab="Java"
93+
Display display = new BlockDisplay(spawnLocation);
94+
display.setLeftRotation(1.0, 1.0, 1.0, 1.0)
95+
display.setRightRotation(1.0, 1.0, 1.0, 1.0)
96+
```
97+
```kotlin tab="Kotlin"
98+
Display display = new BlockDisplay(spawnLocation);
99+
display.setLeftRotation(1.0, 1.0, 1.0, 1.0)
100+
display.setRightRotation(1.0, 1.0, 1.0, 1.0)
101+
```
102+
103+
### Translation
104+
105+
The displays translation is like an offset from its true location. You are able to use `x`, `y` and `z` to modify them, but you can also use `Vector3f`:
106+
107+
<Tabs items={["Java", "Kotlin"]}>
108+
<Tab value="Java">
109+
```java tab="Simple"
110+
Display display = new BlockDisplay(spawnLocation);
111+
display.setTranslation(2.0, 5.0, 2.5);
112+
```
113+
```java tab="Vector3f"
114+
Display display = new BlockDisplay(spawnLocation);
115+
display.setTranslation(new Vector3f(2.0, 5.0, 2.5));
116+
```
117+
</Tab>
118+
<Tab value="Kotlin">
119+
```kotlin tab="Simple"
120+
val display = BlockDisplay(spawnLocation);
121+
display.setTranslation(2.0, 5.0, 2.5);
122+
```
123+
```kotlin tab="Vector3f"
124+
val display = BlockDisplay(spawnLocation);
125+
display.setTranslation(Vector3f(2.0, 5.0, 2.5));
126+
```
127+
</Tab>
128+
</Tabs>
129+
130+
### Interpolation Duration
131+
132+
Interpolation duration is the time it will take to do the last `transformation` modification. It will interpolate all the points from the old to new point.
133+
Here we will show a quick example of moving a `BlockDisplay` one block to the side in 20 ticks:
134+
135+
```java tab="Java"
136+
Display display = new BlockDisplay(spawnLocation);
137+
display.setBlock(Material.STONE);
138+
display.setInterpolationDuration(20);
139+
display.setTranslation(0.0, 0.0, 1.0);
140+
```
141+
```kotlin tab="Kotlin"
142+
val display = BlockDisplay(spawnLocation)
143+
display.setBlock(Material.STONE)
144+
display.setInterpolationDuration(20)
145+
display.setTranslation(0.0, 0.0, 1.0)
146+
```
147+
148+
![Block Interpolation](https://cdn.undefinedcreations.com/lynx/display/block-interpation.gif)
149+
150+
### Interpolation Delay
151+
152+
Interpolation delay is the time it will take to start the last `transformation` modification in ticks.
153+
154+
```java tab="Java"
155+
Display display = new BlockDisplay(spawnLocation);
156+
display.setInterpolationDelat(20);
157+
```
158+
```kotlin tab="Kotlin"
159+
val display = BlockDisplay(spawnLocation)
160+
display.setInterpolationDelat(20)
161+
```
162+
163+
## Billboard
164+
165+
Display allow you to modify the way they rotation. This is called `Billboard`:
166+
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) |
173+
174+
Here is how you can modify them:
175+
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+
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"title": "Display",
33
"defaultOpen": false,
4-
"pages": ["index", "gameProfile", "name", "skin", "cape", "events", "examples"]
4+
"pages": ["spawning-display", "display", "name", "skin", "cape", "events", "examples"]
55
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Spawning Entities
3+
---
4+
5+
Lynx allows you to spawn full packet based display entities. The power of using packet based entity is that you are able to modify them asynchronously creating less lag for the server.
6+
7+
We will be showing you have to spawn them into your world.
8+
9+
# Text Display
10+
11+
```java tab="Java"
12+
Location spawnLocation = player.getLocation();
13+
14+
TextDisplay text = new TextDisplay(spawnLocation);
15+
```
16+
```kotlin tab="Kotlin"
17+
val spawnLocation = player.location
18+
19+
val text = TextDisplay(spawnLocation)
20+
```
21+
22+
# Block Display
23+
24+
```java tab="Java"
25+
Location spawnLocation = player.getLocation();
26+
27+
BlockDisplay block = new BlockDisplay(spawnLocation);
28+
```
29+
```kotlin tab="Kotlin"
30+
val spawnLocation = player.location
31+
32+
val block = BlockDisplay(spawnLocation)
33+
```
34+
35+
# Item Display
36+
37+
```java tab="Java"
38+
Location spawnLocation = player.getLocation();
39+
40+
ItemDisplay item = new ItemDisplay(spawnLocation);
41+
```
42+
```kotlin tab="Kotlin"
43+
val spawnLocation = player.location
44+
45+
val item = ItemDisplay(spawnLocation)
46+
```
47+
48+
# Interaction
49+
50+
<Callout title="info">
51+
Any interaction entity isn't an Display Entity witch means it won't have all the same methods as the other entity above.
52+
</Callout>
53+
54+
```java tab="Java"
55+
Location spawnLocation = player.getLocation();
56+
57+
Interaction interaction = new Interaction(spawnLocation);
58+
```
59+
```kotlin tab="Kotlin"
60+
val spawnLocation = player.location
61+
62+
val interaction = Interaction(spawnLocation)
63+
```
64+
65+
# Visible To
66+
67+
When spawning in your entity you have the option to modify to whom the entity is visible to.
68+
69+
This option is a list of players. If this list is `null` witch it is by default it will make the entity global.
70+
71+
Here is an example make an `TextDisplay` only show to a player called `TheRedMagic`:
72+
73+
```java tab="Java"
74+
Location spawnLocation = player.getLocation();
75+
76+
List<Player> visibleTo = new ArrayList<>();
77+
visibleTo.add(Bukkit.getPlayer("TheRedMagic"));
78+
79+
TextDisplay text = new TextDisplay(spawnLocation, visibleTo);
80+
```
81+
```kotlin tab="Kotlin"
82+
val spawnLocation = player.location
83+
val visibleToList = listOf(Bukkit.getPlayer("TheRedMagic"))
84+
85+
val text = TextDisplay(
86+
location = spawnLocation,
87+
visibleTo = visibleToList
88+
)
89+
```

0 commit comments

Comments
 (0)