From f8c8296f29bad631c873f6d98a30cb68b4b11193 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 10 Jan 2020 21:50:03 -0400 Subject: [PATCH] added breeding age, so there is no need to messup with data command for that. --- src/main/java/carpet/script/CarpetExpression.java | 4 +++- src/main/java/carpet/script/value/EntityValue.java | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index 7cf338b0..0dbfa1fe 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -1724,6 +1724,8 @@ public class CarpetExpression *

Eye height of the entity.

*

query(e,'age')

*

Age, in ticks, of the entity, i.e. how long it existed.

+ *

query(e,'breeding_age')

+ *

Breeding age of passive entity, in ticks. If negative it it time to adulthood, if positive, breeding cooldown

*

query(e,'despawn_timer')

*

For living entities - the number of ticks they fall outside of immediate player presence.

*

query(e,'item')

@@ -1825,7 +1827,7 @@ public class CarpetExpression *

Adds a vector to the motion vector. Most realistic way to apply a force to an entity.

*

modify(e, 'custom_name'), modify(e, 'custom_name', name )

*

modify(e, 'pickup_delay')

- *

Sets a custom pickup delay if the entity argument is an item entity

+ *

modify(e, 'breeding_age')

*

modify(e, 'despawn_timer')

*

Sets a custom despawn timer value.

*

modify(e, 'dismount')

diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index e88c4900..f81e6f3d 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -26,6 +26,7 @@ import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.MobEntityWithAi; +import net.minecraft.entity.passive.PassiveEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundTag; import net.minecraft.predicate.entity.EntityPredicates; @@ -245,6 +246,7 @@ public class EntityValue extends Value put("width", (e, a) -> new NumericValue(e.getDimensions(EntityPose.STANDING).width)); put("eye_height", (e, a) -> new NumericValue(e.getStandingEyeHeight())); put("age", (e, a) -> new NumericValue(e.age)); + put("breeding_age", (e, a) -> e instanceof PassiveEntity?new NumericValue(((PassiveEntity) e).getBreedingAge()):Value.NULL); put("despawn_timer", (e, a) -> e instanceof LivingEntity?new NumericValue(((LivingEntity) e).getDespawnCounter()):Value.NULL); put("item", (e, a) -> (e instanceof ItemEntity)?ListValue.fromItemStack(((ItemEntity) e).getStack()):Value.NULL); put("count", (e, a) -> (e instanceof ItemEntity)?new NumericValue(((ItemEntity) e).getStack().getCount()):Value.NULL); @@ -681,6 +683,13 @@ public class EntityValue extends Value // ((MobEntity) e).setTarget(elb); // } //}); + put("breeding_age", (e, v) -> + { + if (e instanceof PassiveEntity) + { + ((PassiveEntity) e).setBreedingAge((int)NumericValue.asNumber(v).getLong()); + } + }); put("talk", (e, v) -> { // attacks indefinitely if (e instanceof MobEntity) @@ -790,8 +799,6 @@ public class EntityValue extends Value if (lv.size() >= 2 && lv.size() <= 5) { String effectName = lv.get(0).getString(); - if (effectName.startsWith("minecraft:")) - effectName = "minecraft:"+effectName; StatusEffect effect = Registry.STATUS_EFFECT.get(new Identifier(effectName)); if (effect == null) throw new InternalExpressionException("Wrong effect name: "+effectName);