-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
EntityShotAtAngle.java
81 lines (67 loc) · 2.7 KB
/
EntityShotAtAngle.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.denizenscript.denizen.objects.properties.entity;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.properties.Property;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import org.bukkit.entity.Firework;
public class EntityShotAtAngle implements Property {
public static boolean describes(ObjectTag entity) {
return entity instanceof EntityTag && ((EntityTag) entity).getBukkitEntity() instanceof Firework;
}
public static EntityShotAtAngle getFrom(ObjectTag entity) {
if (!describes(entity)) {
return null;
}
else {
return new EntityShotAtAngle((EntityTag) entity);
}
}
public static final String[] handledMechs = new String[] {
"shot_at_angle"
};
public EntityShotAtAngle(EntityTag entity) {
this.entity = entity;
}
EntityTag entity;
public Firework getFirework() {
return (Firework) entity.getBukkitEntity();
}
@Override
public String getPropertyString() {
return getFirework().isShotAtAngle() ? "true" : "false";
}
@Override
public String getPropertyId() {
return "shot_at_angle";
}
public static void register() {
// <--[tag]
// @attribute <EntityTag.shot_at_angle>
// @returns ElementTag(Boolean)
// @mechanism EntityTag.shot_at_angle
// @group properties
// @description
// Returns true if the Firework entity is 'shot at angle', meaning it should render facing the direction it's moving. If false, will be angled straight up.
// -->
PropertyParser.registerTag(EntityShotAtAngle.class, ElementTag.class, "shot_at_angle", (attribute, object) -> {
return new ElementTag(object.getFirework().isShotAtAngle());
});
}
@Override
public void adjust(Mechanism mechanism) {
// <--[mechanism]
// @object EntityTag
// @name shot_at_angle
// @input ElementTag(Boolean)
// @description
// Set to true if the Firework entity should be 'shot at angle', meaning it should render facing the direction it's moving. If false, will be angled straight up.
// @tags
// <EntityTag.shot_at_angle>
// -->
if (mechanism.matches("shot_at_angle") && mechanism.requireBoolean()) {
getFirework().setShotAtAngle(mechanism.getValue().asBoolean());
}
}
}