added ability to modify age of entities

This commit is contained in:
gnembon committed 2020-02-10 00:51:56 -04:00
1 parent 770ba7ced1
commit 229a82da90
2 files changed
+7 -3

No files matched your search

@@ -2244,9 +2244,12 @@ public class CarpetExpression
* <h3><code>modify(e, 'accelerate', x, y, z), modify(e, 'accelerate', l(x, y, z) )</code></h3>
* <p>Adds a vector to the motion vector. Most realistic way to apply a force to an entity.</p>
* <h3><code>modify(e, 'custom_name'), modify(e, 'custom_name', name )</code></h3>
* <h3><code>modify(e, 'pickup_delay')</code></h3>
* <h3><code>modify(e, 'breeding_age')</code></h3>
* <h3><code>modify(e, 'despawn_timer')</code></h3>
* <h3><code>modify(e, 'age', number)</code></h3>
* <p>Modifies entity's internal age counter. Fiddling with this will affect directly
* behaviours of complex entities, so use it with caution.</p>
* <h3><code>modify(e, 'pickup_delay', number)</code></h3>
* <h3><code>modify(e, 'breeding_age', number)</code></h3>
* <h3><code>modify(e, 'despawn_timer', number)</code></h3>
* <p>Sets a custom despawn timer value.</p>
* <h3><code>modify(e, 'dismount')</code></h3>
* <p>Dismounts riding entity.</p>
@@ -517,6 +517,7 @@ public class EntityValue extends Value
private static final Map<String, BiConsumer<Entity, Value>> featureModifiers = new HashMap<String, BiConsumer<Entity, Value>>() {{
put("remove", (entity, value) -> entity.remove());
put("age", (e, v) -> e.age = Math.abs((int)NumericValue.asNumber(v).getLong()) );
put("health", (e, v) -> { if (e instanceof LivingEntity) ((LivingEntity) e).setHealth((float) NumericValue.asNumber(v).getDouble()); });
put("kill", (e, v) -> e.kill());
put("location", (e, v) ->