Added a villager behaviour

This commit is contained in:
Sollace 2020-09-24 21:02:03 +02:00
parent 085c9dac2f
commit dc982b000c
2 changed files with 27 additions and 0 deletions

View file

@ -176,6 +176,7 @@ public class EntityBehaviour<T extends Entity> {
} }
static { static {
register(VillagerBehaviour::new, EntityType.VILLAGER, EntityType.WANDERING_TRADER);
register(SheepBehaviour::new, EntityType.SHEEP); register(SheepBehaviour::new, EntityType.SHEEP);
register(EndermanBehaviour::new, EntityType.ENDERMAN); register(EndermanBehaviour::new, EntityType.ENDERMAN);
register(SpellcastingIllagerBehaviour::new, EntityType.ILLUSIONER, EntityType.EVOKER); register(SpellcastingIllagerBehaviour::new, EntityType.ILLUSIONER, EntityType.EVOKER);

View file

@ -0,0 +1,26 @@
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 net.minecraft.entity.passive.AbstractTraderEntity;
import net.minecraft.sound.SoundEvents;
public class VillagerBehaviour extends EntityBehaviour<AbstractTraderEntity> {
@Override
public void update(Caster<?> source, AbstractTraderEntity entity, Spell spell) {
if (source instanceof Pony) {
Pony player = (Pony)source;
if (player.sneakingChanged() && player.getOwner().isSneaking()) {
entity.setHeadRollingTimeLeft(40);
if (!entity.world.isClient()) {
entity.playSound(SoundEvents.ENTITY_VILLAGER_NO, 1, 1);
}
}
}
}
}