mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Add a ravager behaviour
This commit is contained in:
parent
80b89088ce
commit
80cf905eb0
2 changed files with 24 additions and 0 deletions
|
@ -217,6 +217,7 @@ public class EntityBehaviour<T extends Entity> {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
register(FallingBlockBehaviour::new, EntityType.FALLING_BLOCK);
|
register(FallingBlockBehaviour::new, EntityType.FALLING_BLOCK);
|
||||||
|
register(RavagerBehaviour::new, EntityType.RAVAGER);
|
||||||
register(VillagerBehaviour::new, EntityType.VILLAGER, EntityType.WANDERING_TRADER);
|
register(VillagerBehaviour::new, EntityType.VILLAGER, EntityType.WANDERING_TRADER);
|
||||||
register(SheepBehaviour::new, EntityType.SHEEP);
|
register(SheepBehaviour::new, EntityType.SHEEP);
|
||||||
register(BeeBehaviour::new, EntityType.BEE);
|
register(BeeBehaviour::new, EntityType.BEE);
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue