added breeding age, so there is no need to messup with data command for that.

This commit is contained in:
gnembon committed 2020-01-10 21:50:03 -04:00
1 parent e44cf0d79b
commit f8c8296f29
2 files changed
+12 -3

No files matched your search

@@ -1724,6 +1724,8 @@ public class CarpetExpression
* <p>Eye height of the entity.</p> * <p>Eye height of the entity.</p>
* <h3><code>query(e,'age')</code></h3> * <h3><code>query(e,'age')</code></h3>
* <p>Age, in ticks, of the entity, i.e. how long it existed.</p> * <p>Age, in ticks, of the entity, i.e. how long it existed.</p>
* <h3><code>query(e,'breeding_age')</code></h3>
* <p>Breeding age of passive entity, in ticks. If negative it it time to adulthood, if positive, breeding cooldown</p>
* <h3><code>query(e,'despawn_timer')</code></h3> * <h3><code>query(e,'despawn_timer')</code></h3>
* <p>For living entities - the number of ticks they fall outside of immediate player presence.</p> * <p>For living entities - the number of ticks they fall outside of immediate player presence.</p>
* <h3><code>query(e,'item')</code></h3> * <h3><code>query(e,'item')</code></h3>
@@ -1825,7 +1827,7 @@ public class CarpetExpression
* <p>Adds a vector to the motion vector. Most realistic way to apply a force to an entity.</p> * <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, 'custom_name'), modify(e, 'custom_name', name )</code></h3>
* <h3><code>modify(e, 'pickup_delay')</code></h3> * <h3><code>modify(e, 'pickup_delay')</code></h3>
* <p>Sets a custom pickup delay if the entity argument is an item entity</p> * <h3><code>modify(e, 'breeding_age')</code></h3>
* <h3><code>modify(e, 'despawn_timer')</code></h3> * <h3><code>modify(e, 'despawn_timer')</code></h3>
* <p>Sets a custom despawn timer value.</p> * <p>Sets a custom despawn timer value.</p>
* <h3><code>modify(e, 'dismount')</code></h3> * <h3><code>modify(e, 'dismount')</code></h3>
@@ -26,6 +26,7 @@ import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.mob.MobEntityWithAi; import net.minecraft.entity.mob.MobEntityWithAi;
import net.minecraft.entity.passive.PassiveEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.predicate.entity.EntityPredicates; 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("width", (e, a) -> new NumericValue(e.getDimensions(EntityPose.STANDING).width));
put("eye_height", (e, a) -> new NumericValue(e.getStandingEyeHeight())); put("eye_height", (e, a) -> new NumericValue(e.getStandingEyeHeight()));
put("age", (e, a) -> new NumericValue(e.age)); 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("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("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); 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); // ((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) -> { put("talk", (e, v) -> {
// attacks indefinitely // attacks indefinitely
if (e instanceof MobEntity) if (e instanceof MobEntity)
@@ -790,8 +799,6 @@ public class EntityValue extends Value
if (lv.size() >= 2 && lv.size() <= 5) if (lv.size() >= 2 && lv.size() <= 5)
{ {
String effectName = lv.get(0).getString(); String effectName = lv.get(0).getString();
if (effectName.startsWith("minecraft:"))
effectName = "minecraft:"+effectName;
StatusEffect effect = Registry.STATUS_EFFECT.get(new Identifier(effectName)); StatusEffect effect = Registry.STATUS_EFFECT.get(new Identifier(effectName));
if (effect == null) if (effect == null)
throw new InternalExpressionException("Wrong effect name: "+effectName); throw new InternalExpressionException("Wrong effect name: "+effectName);