From 80cf905eb03516c7a305fd9a4baca25571c7ec7a Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 29 Sep 2020 19:18:37 +0200 Subject: [PATCH] Add a ravager behaviour --- .../entity/behaviour/EntityBehaviour.java | 1 + .../entity/behaviour/RavagerBehaviour.java | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/java/com/minelittlepony/unicopia/entity/behaviour/RavagerBehaviour.java 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)); + } + } + } +}