|
| 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 | + |
| 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 |  | |
| 170 | +| VERTICAL |  | |
| 171 | +| HORIZONTAL |  | |
| 172 | +| CENTER |  | |
| 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 | +``` |
0 commit comments