Skip to content

Commit 1b6c377

Browse files
committed
add more DisplayEntity Data
- interpolation - shadow radius/strength - view range
1 parent ab0f557 commit 1b6c377

File tree

2 files changed

+84
-5
lines changed

2 files changed

+84
-5
lines changed

src/main/java/org/spongepowered/api/data/Keys.java

+25
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,16 @@ public final class Keys {
14221422
*/
14231423
public static final Key<Value<InstrumentType>> INSTRUMENT_TYPE = Keys.key(ResourceKey.sponge("instrument_type"), InstrumentType.class);
14241424

1425+
/**
1426+
* The interpolation delay of a {@link DisplayEntity}
1427+
*/
1428+
public static final Key<Value<Ticks>> INTERPOLATION_DELAY = Keys.key(ResourceKey.sponge("interpolation_delay"), Ticks.class);
1429+
1430+
/**
1431+
* The interpolation duration of a {@link DisplayEntity}
1432+
*/
1433+
public static final Key<Value<Ticks>> INTERPOLATION_DURATION = Keys.key(ResourceKey.sponge("interpolation_duration"), Ticks.class);
1434+
14251435
/**
14261436
* Whether a {@link BlockTypes#DAYLIGHT_DETECTOR} {@link BlockState} is inverted.
14271437
*/
@@ -2717,6 +2727,16 @@ public final class Keys {
27172727
*/
27182728
public static final Key<Value<SerializationBehavior>> SERIALIZATION_BEHAVIOR = Keys.key(ResourceKey.sponge("serialization_behavior"), SerializationBehavior.class);
27192729

2730+
/**
2731+
* The shadow radius of a {@link DisplayEntity}
2732+
*/
2733+
public static final Key<Value<Double>> SHADOW_RADIUS = Keys.key(ResourceKey.sponge("shadow_radius"), Double.class);
2734+
2735+
/**
2736+
* The shadow strength duration of a {@link DisplayEntity}
2737+
*/
2738+
public static final Key<Value<Double>> SHADOW_STRENGTH = Keys.key(ResourceKey.sponge("shadow_strength"), Double.class);
2739+
27202740
/**
27212741
* The shooter of a {@link Projectile}.
27222742
*/
@@ -3132,6 +3152,11 @@ public final class Keys {
31323152
*/
31333153
public static final Key<Value<Integer>> VIEW_DISTANCE = Keys.key(ResourceKey.sponge("view_distance"), Integer.class);
31343154

3155+
/**
3156+
* The view range of a {@link DisplayEntity}
3157+
*/
3158+
public static final Key<Value<Double>> VIEW_RANGE = Keys.key(ResourceKey.sponge("view_range"), Double.class);
3159+
31353160
/**
31363161
* The type of a {@link Villager} or {@link ZombieVillager}.
31373162
*/

src/main/java/org/spongepowered/api/entity/display/DisplayEntity.java

+59-5
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,42 @@
2626

2727
import org.spongepowered.api.data.Keys;
2828
import org.spongepowered.api.entity.Entity;
29+
import org.spongepowered.api.util.Ticks;
30+
import org.spongepowered.api.util.Transform;
2931

3032
import java.util.Optional;
3133

3234
public interface DisplayEntity extends Entity {
3335

34-
// TODO rotation/transformation?
36+
/**
37+
* Returns the transform.
38+
* <p>
39+
* Supports interpolation.
40+
* </p>
41+
*
42+
* @return the transform
43+
*/
44+
default Transform transform() {
45+
return this.require(Keys.TRANSFORM);
46+
}
3547

36-
// TODO interpolation? textopacity/backgroundcolor
48+
/**
49+
* Returns the duration of the interpolation
50+
*
51+
* @return the duration of the interpolation
52+
*/
53+
default Ticks interpolationDuration() {
54+
return this.require(Keys.INTERPOLATION_DURATION);
55+
}
56+
57+
/**
58+
* Returns the delay to the start of the interpolation
59+
*
60+
* @return the delay to the start of the interpolation
61+
*/
62+
default Ticks interpolationDelay() {
63+
return this.require(Keys.INTERPOLATION_DELAY);
64+
}
3765

3866
default BillboardType billboardType() {
3967
return this.require(Keys.BILLBOARD_TYPE);
@@ -57,10 +85,36 @@ default Optional<Integer> blockLight() {
5785
return this.get(Keys.BLOCK_LIGHT);
5886
}
5987

60-
// TODO view_range float/double
6188

62-
// TODO shadow radius float/double 0=noshadow
63-
// TODO shadow strength float/double 1=default
89+
/**
90+
* Returns the shadow radius.
91+
*
92+
* @return the shadow radius.
93+
*/
94+
default Double shadowRadius() {
95+
return this.require(Keys.SHADOW_RADIUS);
96+
}
97+
98+
/**
99+
* Returns the shadow strength or darkness.
100+
* <p>Vanilla defaults to 1</p>
101+
*
102+
* @return the shadow strength.
103+
*/
104+
default Double shadowStrength() {
105+
return this.require(Keys.SHADOW_STRENGTH);
106+
}
107+
108+
109+
/**
110+
* Returns the range at which the display entity is rendered.
111+
*
112+
* @return the view range
113+
*/
114+
default Double viewRange() {
115+
return this.require(Keys.VIEW_RANGE);
116+
}
117+
64118
// TODO bounding box (maybe BASE_SIZE if this is not smth. else in the entity)
65119
// TODO glow_color_override -1 = use team color
66120

0 commit comments

Comments
 (0)