mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +01:00
Added a villager behaviour
This commit is contained in:
parent
085c9dac2f
commit
dc982b000c
2 changed files with 27 additions and 0 deletions
|
@ -176,6 +176,7 @@ public class EntityBehaviour<T extends Entity> {
|
|||
}
|
||||
|
||||
static {
|
||||
register(VillagerBehaviour::new, EntityType.VILLAGER, EntityType.WANDERING_TRADER);
|
||||
register(SheepBehaviour::new, EntityType.SHEEP);
|
||||
register(EndermanBehaviour::new, EntityType.ENDERMAN);
|
||||
register(SpellcastingIllagerBehaviour::new, EntityType.ILLUSIONER, EntityType.EVOKER);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue