/
EntityInterpolationStart.java
56 lines (46 loc) · 2.32 KB
/
EntityInterpolationStart.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.denizenscript.denizen.objects.properties.entity;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.DurationTag;
import org.bukkit.entity.Display;
public class EntityInterpolationStart extends EntityProperty<DurationTag> {
//<--[language]
// @name Display entity interpolation
// @group Minecraft Logic
// @description
// Display entities can interpolate between different properties, providing a smooth transition.
// Interpolation can be started (immediately or with a delay) using <@link mechanism EntityTag.interpolation_start>, and it's duration can be set using <@link mechanism EntityTag.interpolation_duration>.
// The following properties can be interpolated: <@link mechanism EntityTag.scale>, <@link mechanism EntityTag.translation>, <@link mechanism EntityTag.shadow_radius>, <@link mechanism EntityTag.shadow_strength>, <@link mechanism EntityTag.opacity>.
// -->
// <--[property]
// @object EntityTag
// @name interpolation_start
// @input DurationTag
// @description
// The delay between a display entity receiving an update to an interpolated value(s) to it starting its interpolation.
// Interpolation is started whenever this value is set. If no changes were made to the entity in the same tick, it will (visually) redo its last interpolation.
// See also <@link language Display entity interpolation>.
// -->
public static boolean describes(EntityTag entity) {
return entity.getBukkitEntity() instanceof Display;
}
@Override
public DurationTag getPropertyValue() {
return new DurationTag((long) as(Display.class).getInterpolationDelay());
}
@Override
public boolean isDefaultValue(DurationTag value) {
return value.getTicksAsInt() == 0;
}
@Override
public void setPropertyValue(DurationTag value, Mechanism mechanism) {
as(Display.class).setInterpolationDelay(value.getTicksAsInt());
}
@Override
public String getPropertyId() {
return "interpolation_start";
}
public static void register() {
autoRegister("interpolation_start", EntityInterpolationStart.class, DurationTag.class, false);
}
}