Add a ravager behaviour

This commit is contained in:
Sollace 2020-09-29 19:18:37 +02:00
parent 80b89088ce
commit 80cf905eb0
2 changed files with 24 additions and 0 deletions

View file

@ -217,6 +217,7 @@ public class EntityBehaviour<T extends Entity> {
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);

View file

@ -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<RavagerEntity> {
@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));
}
}
}
}