diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java index 971a2341..266ed34d 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java @@ -217,6 +217,7 @@ public class EntityBehaviour { static { register(FallingBlockBehaviour::new, EntityType.FALLING_BLOCK); + register(RavagerBehaviour::new, EntityType.RAVAGER); register(VillagerBehaviour::new, EntityType.VILLAGER, EntityType.WANDERING_TRADER); register(SheepBehaviour::new, EntityType.SHEEP); register(BeeBehaviour::new, EntityType.BEE); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RavagerBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RavagerBehaviour.java new file mode 100644 index 00000000..563febaa --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RavagerBehaviour.java @@ -0,0 +1,23 @@ +package com.minelittlepony.unicopia.entity.behaviour; + +import com.minelittlepony.unicopia.ability.magic.Caster; +import com.minelittlepony.unicopia.ability.magic.Spell; +import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.util.RayTraceHelper; + +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.mob.RavagerEntity; + +public class RavagerBehaviour extends EntityBehaviour { + @Override + public void update(Caster source, RavagerEntity entity, Spell spell) { + + if (source instanceof Pony) { + Pony player = (Pony)source; + + if (player.sneakingChanged() && this.isSneakingOnGround(source)) { + entity.tryAttack(RayTraceHelper.findEntity(source.getEntity(), 6, 1, e -> e instanceof LivingEntity).orElse(entity)); + } + } + } +}